FFMpeg video conversion, copy Creation date to new video format

Started by NHGuy78, June 01, 2022, 11:37:58 AM

Previous topic - Next topic

NHGuy78

I have a folder of AVI files that I'm converting to MP4 format. The command that I use works great with the exception that it does NOT copy the date modified/date created tags.

Here's the command I run for FFMPEG:
FOR /F "tokens=*" %G IN ('dir /b *.avi') DO ffmpeg -i "%G" -map_metadata 0 -c copy -movflags faststart -c:v libx264 -c:a aac -pix_fmt yuv420p "%~nG.mp4"
That looks at ALL files in the folder that are avi and converts. Someone mentioned that EXIFTool could be used to look at the avi files in the dir and copy the needed tags to the new mp4. Is that possible? if so, how?

Thank you in advance,

Phil Harvey

The general syntax is:

exiftool -tagsfromfile %d%f.AVI "-DSTTAG1<SRCTAG1" "-DSTTAG2<SRCTAG2" ... -ext mp4 DIR

Where DSTTAGx/SRCTAGx are the destination and source tag names.  You may need to specify the destination group as well.  See FAQ 3 for help with this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Odds are the tags you want to copy are the FileCreateDate and FileModifyDate as AVIs don't always have embedded date/time tags.

Run this command to see all the time related tags in the file
exiftool -time:all -G -a -s file.avi

If the time stamps you are looking for are the file system tags, then you could use this command to copy them, assuming the AVIs are in the same directory as the MP4s.
exiftool -TagsFromFile %d%f.AVI -FileCreateDate -FileModifyDate -ext mp4 DIR
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype


wywh

There are some ffmpeg commands that might preserve metadata but in my experience at least macOS 12 QuickTime does not read them well ('-movflags use_metadata_tags' preserves 'Keys:GPSCoordinates' but QuickTime does not read it, '-map_metadata 0' preserves 'QuickTime:CreateDate').

So I'd not try to include metadata in ffmpeg. Do it all later in exiftool with '-TagsFromFile' if the originals have relevant tags to copy.

With the .avi I'd first copy the fragile FileCreateDate or FileModifyDate (or some other .avi date) to the more robust .avi filename. Then encode with ffmpeg while preserving date in the filename. Then copy the date from the filename to .mp4 metadata dates in exiftool:

exiftool -api QuickTimeUTC=1 '-AllDates<FileName' '-Track*Date<FileName' '-Media*Date<FileName' -execute '-FileCreateDate<FileName' '-FileModifyDate<FileName' -common_args -m -P -overwrite_original_in_place -wm w .

For pre-1970 dates, remove '-wm w' and add '-Keys:CreationDate<FileName' before '-execute'.

I add GPS and Title, Description, Author and Keywords to some selected .mp4, .m4v and .mov but I guess .avi does not have them.

- Matti