How to change metadata with ffmpeg/avconv without creating a new file? How to change metadata with ffmpeg/avconv without creating a new file? python python

How to change metadata with ffmpeg/avconv without creating a new file?


You can do this with FFmpeg like so:

ffmpeg -i input.avi -metadata key=value -codec copy output.avi

Example:

$ du -h test.mov  27M    test.mov$ ffprobe -loglevel quiet -show_format out.mov | grep title    # nothing found$ ffmpeg -loglevel quiet -i test.mov -codec copy -metadata title="My title" out.mov$ du -h out.mov 27M    out.mov$ ffprobe -loglevel quiet -show_format out.mov | grep titleTAG:title=My title

See the documentation for -metadata and on stream copying for more information.

Note also that not all formats allow setting arbitrary metadata, for, e.g., Quicktime doing -metadata title="my title" does what you'd expect, but -metadata foo=bux does nothing.


I asked on the mailing list of avconv and got the following answer:

„No, it's not possible [to change the metadata without creating a new file], neither libavformat API nor avconv design allows for in-place editing of files.“


You can also make something like this that deletes the file on success and rename the output

ffmpeg -i default.mp4 -metadata title="my title" -codec copy output.mp4 && mv output.mp4 default.mp4