如何设置报头元数据为编码视频

How to set header metadata to encoded video?

本文关键字:元数据 编码 视频 报头 何设置 设置      更新时间:2023-10-16

我正在将一些图像编码为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);

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

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