ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: NHGuy78 on June 01, 2022, 11:37:58 AM

Title: FFMpeg video conversion, copy Creation date to new video format
Post by: NHGuy78 on June 01, 2022, 11:37:58 AM
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,
Title: Re: FFMpeg video conversion, copy Creation date to new video format
Post by: Phil Harvey on June 01, 2022, 01:36:28 PM
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 (https://exiftool.org/faq.html#Q3) for help with this.

- Phil
Title: Re: FFMpeg video conversion, copy Creation date to new video format
Post by: StarGeek on June 01, 2022, 02:08:37 PM
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
Title: Re: FFMpeg video conversion, copy Creation date to new video format
Post by: NHGuy78 on June 01, 2022, 02:45:18 PM
Thank you both, this really helped.
Title: Re: FFMpeg video conversion, copy Creation date to new video format
Post by: wywh on June 02, 2022, 10:04:25 AM
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