<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div id="divRplyFwdMsg" dir="ltr">
<div> </div>
</div>
<div dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
 > 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.<br>
<br>
I found the answer by myself, after looking at the binary ffmpeg that has the same problem if doing:<br>
<br>
ffmpeg -i input.mp4 -metadata hello='world' -c copy output.mp4<br>
<br>
... there is a lot more information in the net about the command line tools than the libraries :)
<br>
<br>
... I found here:<br>
<br>
<a href="https://superuser.com/questions/1208273/how-to-add-new-and-non-defined-metadata-to-an-mp4-file" id="LPlnk270779">https://superuser.com/questions/1208273/how-to-add-new-and-non-defined-metadata-to-an-mp4-file</a><br>
<br>
...that to output user metadatas ffmpeg need the option:<br>
<br>
-movflags use_metadata_tags<br>
<br>
... so I changed the avformat_write_header() call this way:<br>
<br>
<div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Menlo, Monaco, "Courier New", monospace; font-weight: normal; font-size: 14px; line-height: 21px;">
<span><span>                </span><span style="color: rgb(220, 220, 170);">av_dict_set</span><span>(&</span><span style="color: rgb(156, 220, 254);">options</span><span>,
</span><span style="color: rgb(206, 145, 120);">"movflags"</span><span>, </span><span style="color: rgb(206, 145, 120);">"use_metadata_tags"</span><span>,
</span><span style="color: rgb(181, 206, 168);">0</span><span>);</span></span>
<div><span style="color: rgb(106, 153, 85);">                /* Write the stream header, if any. */</span></div>
<div><span>                </span><span style="color: rgb(86, 156, 214);">int</span><span> </span><span style="color: rgb(156, 220, 254);">ret</span><span> =
</span><span style="color: rgb(220, 220, 170);">avformat_write_header</span><span>(</span><span style="color: rgb(156, 220, 254);">oc_</span><span>, &</span><span style="color: rgb(156, 220, 254);">options</span><span>);</span></div>
<div><span style="color: rgb(106, 153, 85);">                // dictionary is copied inside write_header, we should free here our copy</span></div>
<span><span>                </span><span style="color: rgb(220, 220, 170);">av_dict_free</span><span>(&</span><span style="color: rgb(156, 220, 254);">options</span><span>);</span></span></div>
<br>
... and now my metadatsa appear on the output file!<br>
<br>
I hope this can be helpful for ppl having problems with this, that is not a very obvious behaviour.<br>
</div>
</div>
</body>
</html>