macOS Photos app ignores GPS Data on mp4 file import

Started by gpsaddict, November 21, 2023, 05:53:24 PM

Previous topic - Next topic

gpsaddict

Greetings everyone,

Having dedicated an entire day to resolving a persistent issue, I find myself reaching out to this community in the hope that someone might offer a solution.

Here's the challenge at hand:

In my Mac Photos app, I've encountered a situation where videos from my iPhone are consuming a significant amount of space. To address this, I've been exporting the original, untouched files and converting them to h.265 mp4 using Shutter Encoder while preserving metadata. However, upon re-importing these files back into the Photos app, I've noticed a peculiar issue — no location data is displayed. It appears as though the Photos app is ignoring the GPS information from the converted files. This behavior persists even when inspecting the file in Quicktime Player and accessing the information panel, where no GPS data is shown.

Curiously, when I use Terminal with ExifTool to retrieve metadata, the location data is indeed present. Same when importing into Google Photos. Right after uploading I can see the correct location.

I hope someone can help me to figure out what exactly is the problem here.

Phil Harvey

Maybe try copying the GPS from the original using ExifTool before importing the video.  Some software is very particular about the number of digits in the GPS coordinates, I have seen this before, and the way that ExifTool writes this may be more compatible with Apple Photos.

exiftool -tagsfromfile SOURCEFILE "-all:gps*" TARGETFILE

- 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 ($).

gpsaddict

Thank you Phil. I did as you said and ExifTool does it successful, but when I open the updated file in Quicktime Player or import it in Photos app, it won't read the GPS data.

wywh

Photos.app reads GPS location from 'Keys:GPSCoordinates' from .mp4, .m4v and .mov (or 'UserData:GPSCoordinates' from .mov). Keys overrides UserData if both exist. Photos ignores this UserData tag in .mp4 and .m4v.

- Matti

gpsaddict

After converting the file I look up the location data with exiftool -a -G1 -s -n -ee -Location:all

This is what the tool says:

[Keys]          GPSCoordinates                  : 52.5335 12.9967 46.347
[Composite]     GPSAltitude                     : 46.347
[Composite]     GPSAltitudeRef                  : 0
[Composite]     GPSLatitude                     : 52.5335
[Composite]     GPSLongitude                    : 12.9967
[Composite]     GPSPosition                     : 52.5335 12.9967

But when I import it to Apple Photos, no GPS is shown.

wywh

Yes, I see the same thing:

Original where QuickTime Player and Photos read GPS:

exiftool -a -G1:07 -s -n  -Location:All movie.mp4
[Keys:ID-location2eISO6709] GPSCoordinates      : 41 -74

Re-encoded with Shutter Encoder to .h265 with "Preserve metadata" seems to have the same details:

exiftool -a -G1:07 -s -n  -Location:All movie_H.265.mp4
[Keys:ID-location2eISO6709] GPSCoordinates      : 41 -74

But macOS 14 QuickTime Player or Photos does not read GPS from the re-encoded movie because obviously some detail (QuickTime:HandlerType or some offset?) is not correct for those apps.

But this fixes it (I have to clear that "substandard" GPS before it works):

exiftool -overwrite_original -Keys:GPSCoordinates= movie_H.265.mp4                       
    1 image files updated
exiftool -overwrite_original -TagsFromFile movie.mp4 -Keys:GPSCoordinates movie_H.265.mp4

This is why I always use exiftool to copy metadata to the re-encoded movies.

- Matti

gpsaddict

#6
Perfect! This is working  :) Thank you!

Could you please help me finding a workflow for doing this to around 1000 video files? I have the original .mov files and the converted .mp4 files in one folder (but could easily put them in two seperate folders). .mov and .mp4 files have the same filename. Only the extension mov/mp4 is different.

PS: Would is also be possible to include all original metadata from the source file? I noticed that camera information is also not imported in the Photos app - only the original picture taken date seems to work. Is it maybe better to NOT preserve metadata from Shutter Encoder and copy the metadata via ExifTool?

To be honest, I think if someone could create a simple script for this (something like: select original folder, select target folder), it could be quite popular to Photos app users.

wywh

Try something like this (backup the originals before doing this, just in case):

Copy all from .mov to a same name .mp4 in the same folder and set file dates (all Track*Date, Media*Date, Keys might not be updated if they do not exist in the source):

exiftool -m -overwrite_original -api QuickTimeUTC=1 -api LargeFileSupport=1 -TagsFromFile '%-.0f.mov' -All:All '-FileCreateDate<QuickTime:CreateDate' '-FileModifyDate<QuickTime:CreateDate' *.mp4
If Shutter Encoder has written metadata to the movie, it seems you have to clear the Keys first because otherwise Apple's apps do not read them  (be careful not to delete tags from the originals!):

exiftool -m -overwrite_original -api LargeFileSupport=1 -Keys:All= *.mp4
I usually check which tags the original has and selectively copy only the desired tags with something like:

Copy some 'Keys' from .mov to a same name .m4v in the same folder:

exiftool -m -P -overwrite_original -api LargeFileSupport=1 -TagsFromFile '%-.0f.mov' -Keys:GPSCoordinates -Keys:Make -Keys:Model -Keys:Software *.mp4
- Matti

gpsaddict

#8
Thank you so much. I'm not at home at the moment but will test it later. Just one question: how do I point ExifTool to the folder with the files instead of a single file?

Is it for example filepath/*.mp4

Update: I figured it out and it's working. I just had to understand some context related things that I have to put the filepath in front of '%-.0f.mov' and in front of *.mp4.

Thank you so much. I'm sure this will help some other people as well!

wywh

This seems to work (somebody please chime in if there is something to be corrected). source_folder with .mov and destination_folder with .mp4 on the Desktop, replace 'user' with your username or otherwise adjust the paths.

Copy all from .mov to same name .mp4 in a different folder and set file dates (all Track*Date, Media*Date, Keys might not be updated if they do not exist in the source):

exiftool -m -overwrite_original -api QuickTimeUTC=1 -api LargeFileSupport=1 -ext mp4 -TagsFromFile '/Users/user/Desktop/source_folder/%-.0f.mov' -All:All '-FileCreateDate<QuickTime:CreateDate' '-FileModifyDate<QuickTime:CreateDate' '/Users/user/Desktop/destination_folder'
- Matti

Phil Harvey

Thanks Matti for solving this, I wouldn't have been able to figure this out myself.

Would it be possible to attach the exiftool -v3 output for a file that Photos doesn't like, and the same one after fixing GPSCoordinates with ExifTool?  I would like to see if I can figure out what the problem was.

- 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 ($).

wywh

Quote from: Phil Harvey on November 22, 2023, 10:52:02 AMWould it be possible to attach the exiftool -v3 output for a file that Photos doesn't like, and the same one after fixing GPSCoordinates with ExifTool?

macOS 14 QuickTime Player displays all following tags, and Photos.app displays Date, Title, Description, Keywords, and GPS in the original 2001-0101-1200-00.mp4.

[Keys]          Author                          : Author
[Keys]          CreationDate                    : 2001:01:01 12:00:00+02:00
[Keys]          Description                     : Description
[Keys]          Keywords                        : Keywords 1,Keywords 2
[Keys]          GPSCoordinates                  : -36.6101 -66.91515 119.9
[Keys]          Title                           : Title

I re-encoded the original to H.265 with Shutter Encoder's "Preserve metadata" option. BTW it encodes with ffmpeg and seems to have exiftool built-in.

But in the re-encoded .mp4 none of those tags are displayed anymore (unfixed.txt).

I could fix it with:

exiftool -Keys:All= 2001-0101-1200-00_H.265.mp4
    1 image files updated

exiftool -overwrite_original -api QuickTimeUTC=1 -api LargeFileSupport=1 -TagsFromFile 2001-0101-1200-00.mp4 -All:All 2001-0101-1200-00_H.265.mp4
    1 image files updated

The Keys had to be cleared first for the fix to succeed (fixed.txt).

The movies are so small that I attached them as well. I hope this helps.

unfixed.txt
fixed.txt
2001-0101-1200-00.mp4.zip
2001-0101-1200-00_H.265.mp4.zip   

p.s. thanks for these 20 years with exiftool!

- Matti

gpsaddict

#12
Quote from: wywh on November 22, 2023, 09:49:50 AMThis seems to work (somebody please chime in if there is something to be corrected). source_folder with .mov and destination_folder with .mp4 on the Desktop, replace 'user' with your username or otherwise adjust the paths.

Copy all from .mov to same name .mp4 in a different folder and set file dates (all Track*Date, Media*Date, Keys might not be updated if they do not exist in the source):

exiftool -m -overwrite_original -api QuickTimeUTC=1 -api LargeFileSupport=1 -ext mp4 -TagsFromFile '/Users/user/Desktop/source_folder/%-.0f.mov' -All:All '-FileCreateDate<QuickTime:CreateDate' '-FileModifyDate<QuickTime:CreateDate' '/Users/user/Desktop/destination_folder'
- Matti

I'm sorry, I'm currently learning on the fly the commands for working with terminal and ExifTools without any pre-knowledge.

How do I have to use the string instead or in addition to the 3 strings from above that worked for adding GPS?

PS: Regarding my question: I tried it with the string and GPS wasn't included.

wywh

Quote from: gpsaddict on November 22, 2023, 11:57:11 AMI tried it with the string and GPS wasn't included

I am sorry but could you re-phrase the question and explain what you were trying to do? What "strings", what did not include GPS where??  ???

gpsaddict

Of course, sorry. I lack coding experience or any background with the tool what adds some complexity for me.

Regarding my question: You provided a solution that worked for me, and subsequently, you shared the following code:

exiftool -m -overwrite_original -api QuickTimeUTC=1 -api LargeFileSupport=1 -ext mp4 -TagsFromFile '/Users/user/Desktop/source_folder/%-.0f.mov' -All:All '-FileCreateDate<QuickTime:CreateDate' '-FileModifyDate<QuickTime:CreateDate' '/Users/user/Desktop/destination_folder'

I thought it might be a more refined version of the previous solution. After testing it by creating two folders on my desktop, etc., I noticed that the resulting files did not contain GPS data. I don't understand if and how I can modify the command you wrote (is this the correct term? I've been using 'string,' akin to constructing a Google search with operators) to include the GPS data. I thought it's a "one-line solution". Sorry, it's challenging to describe without the knowledge of how to write commands in Terminal with ExifTool. I hope that makes sense.