Copy GPS to Geolocation city tags in movies

Started by wywh, June 13, 2024, 05:20:17 PM

Previous topic - Next topic

wywh

What is the best way to copy GPS to geolocation city tags in movies?

This command does not work because it overwrites existing Keys:GPSCoordinates with the Geolocation GPS which might be several kilometers away from the initial spot:

exiftool -overwrite_original '-Keys:XMP-photoshop:XMP-iptcCore:Geolocate<GPSPosition' movie.mp4
I tried to omit overwriting it with '--Keys:GPSCoordinates' but that did not seem to work.

Is this the best way to do it:

exiftool -overwrite_original '-Keys:XMP-photoshop:XMP-iptcCore:Geolocate<GPSPosition' -TagsFromFile @ -Keys:GPSCoordinates movie.mp4
None of my apps read XMP in movies so I might omit 'XMP-photoshop:XMP-iptcCore' from that command.

With images this is not a problem and this works OK (I do not write IPTC because it lacks CountryCode and it might be better to stop writing also IPTC anyway):

exiftool -overwrite_original '-XMP:Geolocate<GPSPosition' image.jpg
- Matti

StarGeek

Quote from: wywh on June 13, 2024, 05:20:17 PM(I do not write IPTC because it lacks CountryCode and it might be better to stop writing also IPTC anyway)

IPTC:Country-PrimaryLocationCode is the equivalent of XMP-iptcCore:CountryCode, but I agree with the second point.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

Quote from: StarGeek on June 13, 2024, 05:46:11 PMIPTC:Country-PrimaryLocationCode is the equivalent of XMP-iptcCore:CountryCode

Thanks for the note. My app does not read that IPTC tag while it does read the corresponding XMP tag. FWIW there is a warning if two letter code is used:

exiftool -overwrite_original -IPTC:Country-PrimaryLocationCode=US image.jpg
Warning: [Minor] String too short for IPTC:Country-PrimaryLocationCode (padded) - image.jpg

- Matti

Phil Harvey

Hi Matti,

Quote from: wywh on June 13, 2024, 05:20:17 PMIs this the best way to do it:

exiftool -overwrite_original '-Keys:XMP-photoshop:XMP-iptcCore:Geolocate<GPSPosition' -TagsFromFile @ -Keys:GPSCoordinates movie.mp4

I think what you want is simply:

exiftool -overwrite_original '-Geolocate<GPSPosition' movie.mp4
As per the table here, this will write:

XMP:City
XMP:State
XMP:CountryCode
XMP:Country
Keys:LocationName

Which should do the same thing as your command.

You raise an interesting point about Keys overwriting Keys:GPSCoordinates when input coordinates are specified.  I should 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 ($).

wywh

Quote from: Phil Harvey on June 13, 2024, 08:46:04 PMI think what you want is simply:

exiftool -overwrite_original '-Geolocate<GPSPosition' movie.mp4

Thanks for reminding me that this feature was added in 12.81.

The same simple command works also for images:

exiftool -overwrite_original '-Geolocate<GPSPosition' image.jpg
- Matti


Phil Harvey

I'll patch ExifTool 12.88 to write Keys:GPSPosition only when an input city name is provided, and Keys:LocationName only with input GPS when the Keys group is specified.

- 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 June 14, 2024, 09:42:01 AMI'll patch ExifTool 12.88 to write Keys:GPSPosition only when an input city name is provided, and Keys:LocationName only with input GPS when the Keys group is specified.

Thanks, that works great for Keys:Coordinates with exiftool v12.88. I did a quick test:

Write a GPS that is several kilometers from the geolocation spot:

exiftool -overwrite_original '-Keys:GPSCoordinates=-14.2, -75.7' movie.mp4

exiftool -a -G1 -s -Location:All -n movie.mp4
[Keys]          GPSCoordinates                  : -14.2 -75.7

exiftool -api geolocation '-geolocation*' movie.mp4
Geolocation City                : Santiago
Geolocation Region              : Ica
Geolocation Subregion           : Provincia de Ica
Geolocation Country Code        : PE
Geolocation Country             : Peru
Geolocation Time Zone           : America/Lima
Geolocation Feature Code        : PPL
Geolocation Feature Type        : Populated Place
Geolocation Population          : 10000
Geolocation Position            : -14.1847, -75.7113
Geolocation Distance            : 2.09 km
Geolocation Bearing             : 323

If GPS is used as input, exiftool v12.88 Geolocate command no longer overwrites that GPS:

exiftool -overwrite_original '-Geolocate<GPSPosition' movie.mp4

exiftool -a -G1 -s -Location:All -n movie.mp4
[Keys]          GPSCoordinates                  : -14.2 -75.7
[Keys]          LocationName                    : Santiago, Ica, Peru
[XMP-iptcCore]  CountryCode                     : PE
[XMP-photoshop] City                            : Santiago
[XMP-photoshop] Country                         : Peru
[XMP-photoshop] State                           : Ica

If City is used as input, then GPS is moved to the geolocation spot:

exiftool -overwrite_original '-Keys:Geolocate=Santiago,Ica' movie.mp4

exiftool -a -G1 -s -Location:All -n movie.mp4
[Keys]          GPSCoordinates                  : -14.1847 -75.7113
[Keys]          LocationName                    : Santiago, Ica, Peru
[XMP-iptcCore]  CountryCode                     : PE
[XMP-photoshop] City                            : Santiago
[XMP-photoshop] Country                         : Peru
[XMP-photoshop] State                           : Ica

If 'Keys' is omitted from the command, then ItemList:GPSCoordinates and XMP are used as a default. Would it be better to use Keys or UserData as a more common default for movie GPS? None of my apps read ItemList or XMP GPS in movies.

exiftool -overwrite_original '-Geolocate=Santiago,Ica' movie.mp4

exiftool -a -G1 -s -Location:All -n movie.mp4                   
[ItemList]      GPSCoordinates                  : -14.1847 -75.7113
[XMP-exif]      GPSLatitude                     : -14.1847
[XMP-exif]      GPSLongitude                    : -75.7113

- Matti

Phil Harvey

Hi Matti,

I had to pick one, and Keys seemed like the one to use.

Of course, you can always use the API Geolocation option then copy Geolocation tags to wherever you want.  The -geolocate feature is only to make things easier for people, but it isn't as flexible as doing it the other way.

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