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?
MP4 files can contain metadata as defined by the format standard, and in addition, can contain Extensible Metadata Platform (XMP) metadata.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With