doing something wrong, extracting GPS/GPX info from GoPro Hero 11 video files

Started by PatFarrell, October 13, 2024, 07:18:31 PM

Previous topic - Next topic

PatFarrell

I must be doing something wrong. I have a few hours worth of video files created by my GoPro Hero 11
that I know have GPS data (because Telemetry Overlay works to create gauges and track layout).
I'm trying to use exiftools 12.98 to create a GPX file.

I'm running using WSL on Windows 11 (x64) using the linux distribution.
(I'm not sure that all the exiftool_files are being used).
I've made a gpx.fmt file from the https://exiftool.org/geotag.html#GPX
(all the lines in it appear commented out, hope that is OK).

The command that I'm using is
exiftool -ee -p /usr/bin/exiftool_files/gpx.fmt GX060056.MP4

The output is just repeated lines (1526 repeats of
/usr/bin/exiftool_files/gpx.fmt
/usr/bin/exiftool_files/gpx.fmt
/usr/bin/exiftool_files/gpx.fmt
/usr/bin/exiftool_files/gpx.fmt
/usr/bin/exiftool_files/gpx.fmt
/usr/bin/exiftool_files/gpx.fmt

I've tried running 'strings' on the MP4 file, and grep'ing the strings output.
I don't see any of the usual NEMA sentence keywords.


Phil Harvey

Hi Pat,

This will happen if the input gpx file doesn't exist or can't be opened.  Try dragging and dropping the .gpx file onto the terminal window instead of typing the path.  If this doesn't work, double check the permissions.  Make sure you can list the file contents with this command first:

cat /usr/bin/exiftool_files/gpx.fmt

Yes, all of the lines in the file you mention should begin with "#".  See the -p option in the exiftool application documentation for a description of how these format files work.

- 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

When you see gpx.fmt (or /usr/bin/exiftool_files/gpx.fmt in this case) repeated over and over like this, that means that exiftool can't find the gpx.fmt file. Double check the path to the FMT file.

The # at the beginning of the lines isn't a comment, it's the format for the -p (-printFormat) option.

I usually find it best to grab the FMT file directly from GitHub.
"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

PatFarrell

Quote from: Phil Harvey on October 13, 2024, 08:54:56 PMcat /usr/bin/exiftool_files/gpx.fmt

cat works, no protection issues
cat /usr/bin/exiftool_files/gpx.fmt
yields
$ cat /usr/bin/exiftool_files/gpx.fmt
#------------------------------------------------------------------------------
# File:         gpx.fmt
#
# Description:  Example ExifTool print format file to generate a GPX track log
#
# Usage:        exiftool -p gpx.fmt -ee3 FILE [...] > out.gpx
#
# Requires:     ExifTool version 10.49 or later
#
# Revisions:    2010/02/05 - P. Harvey created
#               2018/01/04 - PH Added IF to be sure position exists
#               2018/01/06 - PH Use DateFmt function instead of -d option
#               2019/10/24 - PH Preserve sub-seconds in GPSDateTime value
#               2024/04/11 - PH Use %f feature in GPSDateTime formatting
#
# Notes:     1) Input file(s) must contain GPSLatitude and GPSLongitude.
#            2) The -ee3 option is to extract the full track from video files.
#            3) The -fileOrder option may be used to control the order of the
#               generated track points when processing multiple files.
#            4) Coordinates are written at full resolution.  To change this,
#               remove the "#" from the GPSLatitude/Longitude tag names below
#               and use the -c option to set the desired precision.
#------------------------------------------------------------------------------
#[HEAD]<?xml version="1.0" encoding="utf-8"?>
#[HEAD]<gpx version="1.0"
#[HEAD] creator="ExifTool $ExifToolVersion"
#[HEAD] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
#[HEAD] xmlns="http://www.topografix.com/GPX/1/0"
#[HEAD] xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
#[HEAD]<trk>
#[HEAD]<number>1</number>
#[HEAD]<trkseg>
#[IF]  $gpslatitude $gpslongitude
#[BODY]<trkpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <ele>$gpsaltitude#</ele>
#[BODY]  <time>${gpsdatetime#;DateFmt("%Y-%m-%dT%H:%M:%S%fZ")}</time>
#[BODY]</trkpt>
#[TAIL]</trkseg>
#[TAIL]</trk>
#[TAIL]</gpx>

its straight out of github.


PatFarrell

Quote from: StarGeek on October 13, 2024, 09:00:04 PMWhen you see gpx.fmt (or /usr/bin/exiftool_files/gpx.fmt in this case) repeated over and over like this, that means that exiftool can't find the gpx.fmt file. Double check the path to the FMT file.

looks like the path is not being properly handled. While Phil's cat test passes,

exiftool -ee -p /usr/bin/exiftool_files/gpx.fmt GX060056.MP4   
just returns (lots of copies of) the
/usr/bin/exiftool_files/gpx.fmt

while copying the format file locally and using
exiftool -ee -p gpx.fmt GX060056.MP4 

works as expected and documented, producing XML code like this:
<trkpt lat="40.7219422" lon="-76.1394457">
  <ele>244.253</ele>
  <time>2024-10-11T16:28:42.700Z</time>
</trkpt>

Phil Harvey

Hmmm.  OK.  We've seen similar weirdness recently.  Maybe try adding these options to the command:

  -charset filename=utf8 -api windowswidefile=1

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

PatFarrell

Quote from: Phil Harvey on October 14, 2024, 09:25:37 AMTry
  -charset filename=utf8 -api windowswidefile=1

That works
exiftool -ee  -charset filename=utf8 -api windowswidefile=1  -p gpx.fm
t GX060056.MP4

yields the expected

<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.0"
 creator="ExifTool 12.98"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
<number>1</number>
<trkseg>
<trkpt lat="40.7219343" lon="-76.1394851">
  <ele>244.374</ele>
  <time>2024-10-11T16:28:41.700Z</time>
</trkpt>
<trkpt lat="40.7219422" lon="-76.1394457">
  <ele>244.253</ele>
  <time>2024-10-11T16:28:42.700Z</time>
</trkpt>


Remember this install may be a bit weird, its WSL on Windows 11 with
the windows exiftool(-k).exe placed in /usr/bin as just exiftool
and the exiftool_files" folder is also in /usr/bin or more specifically /usr/bin/exiftool_files
But the exiftool_files" folder is not in the path.

Phil Harvey

OK.  Apparently ExifTool can't read files from some drives (like network shares) that don't support short file names, and this must be one of those drives.

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

PatFarrell

I added /usr/bin/exiftool_files to the path
and restarted. Checked that it was in the path.
But no joy.

looks like
-charset filename=utf8 -api windowswidefile=1 
is needed, just to read the GoPro hero 11 format. This is consistant, since both "strings" and "grep" could not find the usual NEMA tags in the file.

PatFarrell

More testing. I don't think its just some wierd Windows long file name thing.
I made a softlink in /usr/bin named exft so that /usr/bin/exft points to the real
/usr/bin/exiftool_files/ and then did

exiftool -ee  -charset filename=utf8  -api windowswidefile=1 -p /usr/bin/exft/gpx.fmt GX060056.MP4

and exiftool failed to read the file.
but the usual "cat" test works.


Phil Harvey

Interesting.

BTW, you can add these options to your config file so you don't have to type them each time:

%Image::ExifTool::UserDefined::Options = (
    CharsetFileName => 'UTF8',
    WindowsWideFile => 1,
);

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