[Libav-user] Add metadata to the container when encoding a video file
Gabriele Greco
gabriele.greco at hudl.com
Fri May 21 16:14:54 EEST 2021
> I have some problems adding metadata to a mp4 or mov container, not sure if it's a problem in avformat or if I'm doing something wrong.
I found the answer by myself, after looking at the binary ffmpeg that has the same problem if doing:
ffmpeg -i input.mp4 -metadata hello='world' -c copy output.mp4
... there is a lot more information in the net about the command line tools than the libraries :)
... I found here:
https://superuser.com/questions/1208273/how-to-add-new-and-non-defined-metadata-to-an-mp4-file
...that to output user metadatas ffmpeg need the option:
-movflags use_metadata_tags
... so I changed the avformat_write_header() call this way:
av_dict_set(&options, "movflags", "use_metadata_tags", 0);
/* Write the stream header, if any. */
int ret = avformat_write_header(oc_, &options);
// dictionary is copied inside write_header, we should free here our copy
av_dict_free(&options);
... and now my metadatsa appear on the output file!
I hope this can be helpful for ppl having problems with this, that is not a very obvious behaviour.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20210521/ef186d5b/attachment.htm>
More information about the Libav-user
mailing list