Copy file creation date to metadata in ffmpeg

ffmpegtimestamps

I would like to copy the file creation date of an mp4 file into the file's metadata. I'm pretty sure this can be done with ffmpeg and some nifty Linux commands.

Best Answer

You can set metadata with ffmpeg via the -metadata parameter.
MP4s support the year attribute according to this, but i only got it to work with the "date" field which is shown in VLC (if it is only a year) and in mplayer and winamp without a problem as full date.
I found the date attribute by setting the year via VLC and dumping the metadata with ffmpeg

To set the date to the time of the last modification (as complete date like 2014-11-13 use something like:

ffmpeg -i inputfile.mp4 -metadata date="$(stat --printf='%y' inputfile.mp4 | cut -d ' ' -f1)" -codec copy outputfile.mp4

The last modified detection could most definetly done nicer, plus i am not sure how spread the usage of the date metadata is, but it worked in my testcase.

Related Question