Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set header metadata to encoded video?

Tags:

c++

c

ffmpeg

I'm encoding some images into an h264 video inside an mp4 container. I'm essentially using the ffmpeg example muxing.c. The thing is I'm trying to set some metadata in the mp4 container such as artist, title, etc...

I thought using the following would work but it didn't:

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);

After the whole video is created I don't see any metadata written to the video file. Any pointers how to actually do this properly?

like image 939
Jona Avatar asked Jun 10 '13 12:06

Jona


People also ask

Do MP4 files have metadata?

MP4 files can contain metadata as defined by the format standard, and in addition, can contain Extensible Metadata Platform (XMP) metadata.


1 Answers

The solution was to actually use the metadata variable from AVFormatContext instead of creating my own AVDictionary and passing it to the avformat_write_header function.

like image 170
Jona Avatar answered Oct 13 '22 06:10

Jona