ExifTool Forum

ExifTool => Newbies => Topic started by: MikeM on January 18, 2023, 06:30:46 AM

Title: Replacing/appending gps track of a mp4
Post by: MikeM on January 18, 2023, 06:30:46 AM
Hi, I'm wondering if it is possible to replace or append a CAMM gps track to mp4 (or really any gps format...).
I got tags by doing
exiftool -ee -G3 --Track1:* --Track2:* -api LargeFileSupport=1 -X VID.mp4 > tags.txt
which outputs for example
<Track3:SampleTime>0:01:03</Track3:SampleTime>
 <Track3:SampleDuration>0.01 s</Track3:SampleDuration>
 <Track3:GPSDateTime>2018:06:04 08:43:04.1Z</Track3:GPSDateTime>
 <Track3:GPSMeasureMode>3-Dimensional Measurement</Track3:GPSMeasureMode>
 <Track3:GPSLatitude>XX deg XX&#39; 7.67&quot; N</Track3:GPSLatitude>
 <Track3:GPSLongitude>XX deg XX&#39; 41.66&quot; E</Track3:GPSLongitude>
 <Track3:GPSAltitude>37.8 m</Track3:GPSAltitude>
 <Track3:GPSHorizontalAccuracy>0.579999983310699</Track3:GPSHorizontalAccuracy>
 <Track3:GPSVerticalAccuracy>0.579999983310699</Track3:GPSVerticalAccuracy>
 <Track3:GPSVelocityEast>-2.20491433143616</Track3:GPSVelocityEast>
 <Track3:GPSVelocityNorth>-10.5452861785889</Track3:GPSVelocityNorth>
 <Track3:GPSVelocityUp>0</Track3:GPSVelocityUp>
 <Track3:GPSSpeedAccuracy>0</Track3:GPSSpeedAccuracy>
Then tried
exiftool -tagsfromfile tags.txt out.mp4
but I can't seem to be able to write continuous GPS data into the other mp4... (also tried adding -all:all, -gps:all and other variations, but I might be doing something wrong)

All in all my goal would be to be able to write arbitrary GPS track such as
<Track3:SampleTime>0.20 s</Track3:SampleTime>
 <Track3:SampleDuration>0.20 s</Track3:SampleDuration>
 <Track3:GPSLatitude>X1 deg YY&#39; 20.10&quot; N</Track3:GPSLatitude>
 <Track3:GPSLongitude>X1 deg YY&#39; 6.69&quot; E</Track3:GPSLongitude>
 <Track3:SampleTime>0.40 s</Track3:SampleTime>
 <Track3:SampleDuration>0.20 s</Track3:SampleDuration>
 <Track3:GPSLatitude>X2 deg YY&#39; 20.10&quot; N</Track3:GPSLatitude>
 <Track3:GPSLongitude>X2 deg YY&#39; 6.69&quot; E</Track3:GPSLongitude>
 ...
or to append these continuous GPS packets into an mp4 so I can build the track one by one.

I also tried importing from .gpx which looks like
<trk>
<name>reel_0005_20210906-125956</name>
<trkseg
<trkpt lat="XX.0763717375" lon="YY.0485558810"><time>2020-05-04T15:03:11.6</time><ele>50.28</ele></trkpt>
<trkpt lat="XX.0763716195" lon="YY.0485558810"><time>2020-05-04T15:03:11.8</time><ele>50.30</ele></trkpt>
<trkpt lat="XX.0763715009" lon="YY.0485558810"><time>2020-05-04T15:03:12</time><ele>50.30</ele></trkpt>
<trkpt lat="XX.0763713806" lon="YY.0485559251"><time>2020-05-04T15:03:12.2</time><ele>50.30</ele></trkpt>
...
</trkseg>
</trk>
with no luck.

NOTE: I don't want to copy GPS data from one mp4 to another nor do I want to just geotag the file with singular latlon. I want to be able to modify/create the "duplicate tags" that software can use to display a video + it's path on a map (without separate gps files, just from the video alone).
Title: Re: Replacing/appending gps track of a mp4
Post by: Phil Harvey on January 18, 2023, 06:44:27 AM
ExifTool doesn't yet have the ability to write timed GPS.

- Phil
Title: Re: Replacing/appending gps track of a mp4
Post by: MikeM on January 18, 2023, 06:53:19 AM
Okay good to know, thanks! Any plans of adding this in the (near) future? I'm honestly shocked at the lack of tools to do this (I found one and it is broken, writes invalid data) considering how common use-case this is and the formats are known too... (at least camm is well documented)
Title: Re: Replacing/appending gps track of a mp4
Post by: Phil Harvey on January 18, 2023, 07:34:17 AM
Well, ExifTool currently supports reading 66 different formats of timed GPS (https://exiftool.org/TagNames/QuickTime.html#Stream).  There is no chance that ExifTool will ever support writing all of these.

The good news is that the CAMM format is probably one I would consider supporting first because it is the only one with a published specification.

The bad news is that the CAMM format is the most complex, and would be the most difficult to implement. :(  (Which is probably one reason why everybody seems to be inventing their own format.)

- Phil
Title: Re: Replacing/appending gps track of a mp4
Post by: motodaxa on December 18, 2023, 12:34:28 PM
Joined this forum just to say that if you do manage to write timed GPS to mp4 files, especially in the GPMF format, I would give you my firstborn child.

It's true that everyone is creating their own format, and yet the ONLY one used by every motorsport lap timer and data logger to this day is GPMF mp4. I can extract a .gpx and a perfectly synced .mp4 from almost any other action camera, but if only there was some way to put them back together again in a way that RaceChrono, serious-racing.com, or TrackdayGenius could read... a true humpty dumpty problem.
Title: Re: Replacing/appending gps track of a mp4
Post by: Phil Harvey on December 18, 2023, 08:52:43 PM
GPMF is the GoPro-specific format.  Adding support for this would only make sense if this format gains widespread support in non-GoPro applications.

But thanks for your suggestion.  GPMF seems to be more widely supported than I thought.  The bad news is that this is one of the more complicated formats (similar to the Google specification, with the timed metadata stored in a separate track).

- Phil