元数据不显示 ffmpeg C++

Kai*_*dul 1 c++ linux ffmpeg window

我正在将 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);
Run Code Online (Sandbox Code Playgroud)

我还尝试查看该文件是否包含任何使用 linux 中的元mediainfo数据exiftools。我也尝试过ffmpeg -i output.mov,但没有显示元数据。

有什么问题?价值还好吗flags?我需要为不同的平台(windows/linux)设置不同的标志吗?0av_dict_set

我看到这个链接,它指出对于 Windows,我必须使用id3v2_version 3并使-write_id3v1 1元数据正常工作。如果是这样,我该如何在 C++ 中做到这一点?

Max*_*ito 5

我有与您的代码类似的内容,但我将其添加AVDictionary到我的AVFormatContext 元数据参数中,这样对我有用。这是基于您的代码的片段。

AVDictionary *pMetaData = NULL;
av_dict_set(&pMetaData, "title", "Cloud Recording", 0);
m_pFormatCtx->metadata = pMetaData;
avformat_write_header(m_pFormatCtx, NULL);
Run Code Online (Sandbox Code Playgroud)