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

时间:2013-06-10 12:44:54

标签: c++ c ffmpeg

我正在将一些图像编码到mp4容器内的h264视频中。我基本上使用的是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);

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

1 个答案:

答案 0 :(得分:7)

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