Retaining Date Taken on Extracted MP4s

Started by diyguy, December 14, 2024, 08:31:32 AM

Previous topic - Next topic

diyguy

I'm trying to extract the Motionphoto as an mp4 from the jpg photos on my Samsung Galaxy phone. I've copied a file containing a motionphoto to a folder on my C: drive.  By doing some searching I've found that I can use following to successfully extract the mp4.

exiftool -b -W %d%f_%t%-c.%s -EmbeddedVideoFile /ExifTesting/P1/

However, the Datemodified is changed to today's date rather than the original date the photo was taken.  I searched for a way to maintaining the date taken and found several references to including -P in the command line string.
I tried the following, but that didn't preserve the Datemodified as the original date:

exiftool -P -b -W %d%f_%t%-c.%s -EmbeddedVideoFile /ExifTesting/P1/

I also tried inserting the -P in various other points in the command line string but still didn't have success in maintaining the Datemodified as the original Datetaken. 

Obviously I'm a newbie at this, but can someone help me with what I'm doing wrong?  Thanks in advance. 

Phil Harvey

You would need to run a second command to copy the date/time from the original file.  This will be tricky because you need to know the file name to do this:

exiftool -tagsfromfile sourcefile.jpg -filemodifydate destfile.mp4

Perhaps with a different naming scheme this would be easier, but I don't have much time right now to think about 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

The -P (-preserve) option only affects edits to the original JPEG file. It doesn't operate on the newly created mp4.

I would probably try this command
exiftool -ext mp4 -TagsFromFile %d%f_EmbeddedVideoFile.jpg -FileModifyDate /path/to/files/

The only problem I can see would be if there was more than one video embedded in the jpeg, because then you would have to deal with the copy number. Though I don't think that there ever is more than one video. If there is, the command can be adjusted to account for this.
"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

diyguy

#3
Thank you for your prompt responses.  I tried to follow this advice, attempting to specifically enter what StarGeek indicated, but I'm afraid I interpreted it incorrectly and got 'Error opening file' messages each time.  I have attached an image (hopefully!) to show the resulting cmd prompt error message.  I believe your instructions were to try to extract the 'date taken' from the original jpg file and edit the 'Date modified' of the mp4 file. 

I have also attached an Windows Explorer screenshot showing the original jpg file and the extracted .mp4 file sitting in a folder/subfolder called ExifTesting/P5/ .  Note that for the .mp4 file, it does show the desired 'date taken' in the 'Date' column (Oct 27/2024), but it shows today's date in the 'Date modified' column.  The desire is to have both the 'Date' and 'Date Modified' column show the same original date the photo was taken.  Therefore somewhere in the metadata for the mp4 file, the date taken is still retained.  Would it be possible to get that Oct 27/2024 date taken from within the mp4 file itself so that there isn't an issue with trying to match the filename with the original jpg file (since I will have hundreds of these to modify and I'd like to do them in batch mode if possible). 

Thank you for your insight, it is greatly appreciated!

Cmd Prompt Screenshot 2024-12-14 113602.jpg
Windows Explorer Screenshot 2024-12-14 113507.jpg

StarGeek

You didn't use the command I listed. You inserted stuff in between %d%f_EmbeddedVideoFile and .jpg
"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

diyguy

Thanks for hanging in there with me!  In response to your Post #4, I tried it 2 different ways, and the first time I thought I didn't put anything between %d%f_EmbeddedVideoFile and .jpg and it didn't work, therefore the second time I tried inserting the filename. 

I have done some further investigating based on more searching within the forum (and finding your responses to some other inquiries).   Now that I realized that it is just a matter of copying a date within the mp4 file itself, I was able to get the following to work successfully:

C:\>exiftool "-filemodifydate<quicktime:createdate" c:\exiftesting\p5\

This changed the mp4 modified date to the original date that the photo was taken.  Success!   Thanks for your inputs.   Exiftool is a great tool, I just need to keep working on learning the syntax.   

Windows Explorer Success in Changing Date Modified to Date Taken Screenshot 2024-12-14 140413.jpg

diyguy

Sorry, but I just noticed that I thought I had success per my previous post but it was close but not quite right.  I didn't notice until after I posted that while the date was correct, the time was shifted (since I am not on UTC).  StarGeek, you had covered this on another post, so I wanted to update the command line that correctly changed the Date modified to the Date the original photo was taken in case anyone else is trying to do this:

C:\>exiftool "-filemodifydate<quicktime:createdate" -api QuickTimeUTC c:\exiftesting\p6\

Now the date and time match per the Windows Explorer screenprint.  Thanks again for all the time you put into answering all these questions! 
Windows Explorer Success In Changing Date Modified to Date Taken with time correction Screenshot 2024-12-14 142350.jpg

StarGeek

Ah, sorry, I didn't think it through all the way. The source file doesn't have _EmbeddedVideoFile in the filename and that needs to be removed. It should have been
-TagsFromFile %d%-.18f.jpg
which would have removed 18 characters from the end of the base filename, i.e. removes _EmbeddedVideoFile, to get the original JPEG name.

But since the video has the correct date already embedded, which I'm a little surprised at, that is a simpler solution.
"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