[英]Metadata is not showing ffmpeg C++
I am muxing h264 encoded video data and PCM g711 encoded audio data into a .mov
media container. 我将h264编码的视频数据和PCM g711编码的音频数据混合到.mov
媒体容器中。 I am trying to write metadata on header but the metadata is not showing when I go to file->right click->properties->details on windows and likewise in Ubuntu. 我正在尝试在标头上写元数据,但是当我在Windows上以及在Ubuntu中同样转到文件->右键单击->属性->详细信息时,元数据未显示。 This is my code - 这是我的代码-
// Instead of creating new AVDictionary object, I also tried following way
// stated here: http://stackoverflow.com/questions/17024192/how-to-set-header-metadata-to-encoded-video
// but no luck
AVDictionary* pMetaData = m_pFormatCtx->metadata;
av_dict_set(&pMetaData, "title", "Cloud Recording", 0);
av_dict_set(&pMetaData, "artist", "Foobar", 0);
av_dict_set(&pMetaData, "copyright", "Foobar", 0);
av_dict_set(&pMetaData, "filename", m_sFilename.c_str(), 0);
time_t now = time(0);
struct tm tStruct = *localtime(&now);
char date[100];
strftime(date, sizeof(date), "%c", &tStruct); // i.e. Thu Aug 23 14:55:02 2001
av_dict_set(&pMetaData, "date", date, 0);
av_dict_set(&pMetaData, "creation_time", date, 0);
av_dict_set(&pMetaData, "comment", "This video has been created using Eyeball MSDK", 0);
// ....................
// .................
/* write the stream header, if any */
int ret = avformat_write_header(m_pFormatCtx, &pMetaData);
I also tried to see if the file contains any metadata using mediainfo
and exiftools
in linux. 我还尝试在Linux中使用mediainfo
和exiftools
来查看文件是否包含任何元数据。 Also I tried ffmpeg -i output.mov
but no metadata is shown. 我也尝试了ffmpeg -i output.mov
但是没有显示元数据。
Whats the problem? 有什么问题? Is the flags
value 0
in av_dict_set
okay? av_dict_set
的flags
值是否为0
? DO I need to set different flags for different platform (windows/linux) ? 我是否需要为不同的平台(Windows / Linux)设置不同的标志?
I saw this link and it stated that for windows, I have to use id3v2_version 3
and -write_id3v1 1
to make metadata working. 我看到了此链接 ,并指出对于Windows,必须使用id3v2_version 3
和-write_id3v1 1
才能使元数据正常工作。 If so, how can I do this in C++? 如果是这样,如何在C ++中做到这一点?
I have something similar to your code, but I'm adding the AVDictionary
to my AVFormatContext
metadata parameter and it works for me that way. 我有一些与您的代码相似的东西,但是我将AVDictionary
添加到了我的AVFormatContext
元数据参数中,并且它对我AVFormatContext
。 Here's a snippet based on your code. 这是根据您的代码片段。
AVDictionary *pMetaData = NULL;
av_dict_set(&pMetaData, "title", "Cloud Recording", 0);
m_pFormatCtx->metadata = pMetaData;
avformat_write_header(m_pFormatCtx, NULL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.