I believe I've figured it out! 
Apple iphone movie "create date" is wrong which is used by Adobe Lightroom cleared up my main issue (which metadata tag that Adobe Lightroom uses to show the correct time/date). The solution: copy CreationDate over to all XMP date tags using EXIFtool, like this:
But that was only half the problem!
FFMPEG doesn't copy all the metadata from the original H265 video using -map_metadata 0 after all, confirmed in How to prevent FFmpeg from dropping metadata?
The correct command to use with FFMPEG is -movflags use_metadata_tags as a step before the EXIFtool task of writing those XMP date tags, like this:
However... someone in that thread pointed out that FFMPEG writes the metadata in a non-standard way.
So although my tests show that the above to work in Lightroom (show the correct time/date), the better solution will probably be using the following 3 steps (compared to the above, this slightly bigger job also results in more metadata (such as "Apple" and "iPhone") to be shown in Lightroom as well.
I believe the working solution then will be (I still need to do some extensive testing with multiple H265 files and also fine-tune the H264 converting as there are some minor issues with pixel size etc.):
1) Convert the H265 video to H264 but without any metadata-transferring:
2) copy all metadata from the original (H265) file to the converted (H264) file:
I can also check to see if the CreationDate has been added:
And/or check all the time tags:
3) Finally, copy the CreationDate tag to all XMP date tags:
@!!! : How should I modify your script in post #7 to include the above? I'm especially concerned about the syntax of step 2 (copying from the original file). Is this just a matter of using the "$f" string again?
Apple iphone movie "create date" is wrong which is used by Adobe Lightroom cleared up my main issue (which metadata tag that Adobe Lightroom uses to show the correct time/date). The solution: copy CreationDate over to all XMP date tags using EXIFtool, like this:
Bash:
$ exiftool -m -P -overwrite_original '-XMP:AllDates<CreationDate' FILENAME.mp4
$
But that was only half the problem!
FFMPEG doesn't copy all the metadata from the original H265 video using -map_metadata 0 after all, confirmed in How to prevent FFmpeg from dropping metadata?
The correct command to use with FFMPEG is -movflags use_metadata_tags as a step before the EXIFtool task of writing those XMP date tags, like this:
Bash:
export PATH="$PATH:/usr/local/bin"
for f in "$@"
do
ffmpeg -i "$f" -c:v libx264 -crf 18 -preset slow -c:a copy -movflags use_metadata_tags "${f%.*}_CONVERTED.mp4"
done
However... someone in that thread pointed out that FFMPEG writes the metadata in a non-standard way.
So although my tests show that the above to work in Lightroom (show the correct time/date), the better solution will probably be using the following 3 steps (compared to the above, this slightly bigger job also results in more metadata (such as "Apple" and "iPhone") to be shown in Lightroom as well.
I believe the working solution then will be (I still need to do some extensive testing with multiple H265 files and also fine-tune the H264 converting as there are some minor issues with pixel size etc.):
1) Convert the H265 video to H264 but without any metadata-transferring:
Bash:
export PATH="$PATH:/usr/local/bin"
for f in "$@"
do
ffmpeg -i "$f" -c:v libx264 "${f%.*}_converted_noMetadata.mp4"
done
2) copy all metadata from the original (H265) file to the converted (H264) file:
Bash:
$ exiftool -tagsfromfile ORIGINAL.mov CONVERTED.mp4
$
I can also check to see if the CreationDate has been added:
Bash:
$ exiftool -a -G1 -s -CreationDate CONVERTED.mp4
$
And/or check all the time tags:
Bash:
$ exiftool -a -G1 -time:all CONVERTED.mp4
$
3) Finally, copy the CreationDate tag to all XMP date tags:
Bash:
$ exiftool -m -P -overwrite_original '-XMP:AllDates<CreationDate' CONVERTED.mp4
$
@!!! : How should I modify your script in post #7 to include the above? I'm especially concerned about the syntax of step 2 (copying from the original file). Is this just a matter of using the "$f" string again?
Last edited: