【发布时间】:2015-11-11 18:25:24
【问题描述】:
我正在将 h264 编码的视频数据和 PCM g711 编码的音频数据混合到一个.mov 媒体容器中。我正在尝试在标题上写入元数据,但是当我在 Windows 和 Ubuntu 中转到文件->右键单击->属性->详细信息时,元数据没有显示。这是我的代码 -
// 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);
我还尝试在 linux 中使用 mediainfo 和 exiftools 查看文件是否包含任何元数据。我也试过ffmpeg -i output.mov,但没有显示元数据。
有什么问题? flags 中的 0 值 av_dict_set 可以吗?我需要为不同的平台(windows/linux)设置不同的标志吗?
我看到this link,它说对于Windows,我必须使用id3v2_version 3 和-write_id3v1 1 来使元数据工作。如果是这样,我该如何在 C++ 中做到这一点?
【问题讨论】: