如何将标头元数据设置为编码video?

我正在将一些图像编码到mp4容器内的h264video中。 我基本上使用的是ffmpeg示例muxing.c。 问题是我正在尝试在mp4容器中设置一些元数据,如艺术家,标题等……

我认为使用以下方法可行,但它没有:

AVDictionary *opts = NULL; av_dict_set(&opts, "title", "Super Lucky Dude", 0); av_dict_set(&opts, "author", "Jacky Chan", 0); av_dict_set(&opts, "album", "Chinese Movie", 0); av_dict_set(&opts, "year", "05/10/2013", 0); av_dict_set(&opts, "comment", "This video was created using example app.", 0); av_dict_set(&opts, "genre", "Action", 0); // Write the stream header, if any. ret = avformat_write_header(oc, &opts); 

创建整个video后,我没有看到任何元数据写入video文件。 任何指针如何正确地做到这一点?

解决方案是实际使用AVFormatContextmetadata变量,而不是创建自己的AVDictionary并将其传递给avformat_write_header function