Extracting GPS Information from .MP4?

Started by Genesis, June 13, 2013, 03:10:39 AM

Previous topic - Next topic

krandino

I appreciate the response. I will try looking at the source. I programmed for 45 years, assembler, Basic, Fortran, and then C and C++ for the last 40 years. Never looked at Perl. I will take a look. Thanks again.


boweiche

Hi everybody

I'm having the same issue as Rove R2-4K Dash Cam. I would like to extract the GPS of every frame from a mp4 video. However, it does not seem to be stored in the header file. Here is the command I used on Ubuntu 18.04:

exiftool -filename -gpslatitude -gpslongitude -gpstimestamp -gpsdatestamp -n -api LargeFileSupport=1 2022_0426_115626_003.MP4 > gps.txt

The video can be found here:

https://www.dropbox.com/s/xh2b9odsch8nj7w/2022_0426_115626_003.MP4?dl=0

My output header file is:
File Name                       : 2022_0426_115626_003.MP4

Can anybody point me out how to do that? Thank you so much!

StarGeek

You have to add the -ee (-extractEmbedded) option.

If you want to create a GPX or KML geotrak, see Inverse Geotagging.

First you have to create the gpx.fmt or kml.fmt format files.  You can copy/paste the gpx.fmt from the above link or download either from GitHub.  Then run the example command in the file.

Using your example file.  The warnings can be ignored as there isn't any altitude data in your file.
C:\>exiftool -p C:\Programs\UnixUtils\ExifTool\gpx.fmt -ee3 Y:\!temp\ccc\2022_0426_115626_003.MP4 >Y:\!temp\ccc\2022_0426_115626_003.gpx
Warning: [Minor] Tag 'Doc1:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc2:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc3:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc4:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc5:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc6:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc7:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc8:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4
Warning: [Minor] Tag 'Doc9:gpsaltitude' not defined - Y:/!temp/ccc/2022_0426_115626_003.MP4

C:\>Type Y:\!temp\ccc\2022_0426_115626_003.gpx
<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.0"
creator="ExifTool 12.41"
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.437185" lon="-79.9630366666667">
  <time>2022-04-26T11:56:26Z</time>
</trkpt>
<trkpt lat="40.43725" lon="-79.962955">
  <time>2022-04-26T11:56:27Z</time>
</trkpt>
<trkpt lat="40.4373716666667" lon="-79.9627833333333">
  <time>2022-04-26T11:56:28Z</time>
</trkpt>
<trkpt lat="40.4374333333333" lon="-79.962695">
  <time>2022-04-26T11:56:29Z</time>
</trkpt>
<trkpt lat="40.4375" lon="-79.9626116666667">
  <time>2022-04-26T11:56:30Z</time>
</trkpt>
<trkpt lat="40.437565" lon="-79.9625233333333">
  <time>2022-04-26T11:56:31Z</time>
</trkpt>
<trkpt lat="40.43763" lon="-79.9624333333333">
  <time>2022-04-26T11:56:32Z</time>
</trkpt>
<trkpt lat="40.43763" lon="-79.9624333333333">
  <time>2022-04-26T11:56:32Z</time>
</trkpt>
<trkpt lat="40.4376866666667" lon="-79.962345">
  <time>2022-04-26T11:56:33Z</time>
</trkpt>
</trkseg>
</trk>
</gpx>
* 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).

boweiche

Hi,

Thanks for the reply. I tried your command on Windows and Ubuntu. Both of them did not give me the desired outputs. Any thoughts please? Attached are the outputs of windows and ubuntu.

StarGeek

Run this command on the file.  It should display all the embedded GPS data in the file that exiftool knows about.
exiftool -G1 -a -s -ee3 "-gps*" file.mp4

If no GPS Coordinates are displayed, either the file doesn't have GPS coordinates or the coordinates are embedded in a (yet another) way that exiftool doesn't know about.  Exiftool can decode 59 different ways a GPS track can be embedded in a video file, but there are always other unknown ways.

If it is the latter case, then a short sample would be helpful and Phil might try to add support if he has time.
* 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).

boweiche

Hi,

That seems to have extracted the gps info. It's not in a standard format so not easy to verify on a map... but the time stamps and speed seem reasonable. Thanks!


StarGeek

The command I gave wasn't to create a GPS track but to verify that there were GPS coordinates in the file that exiftool could extract.  The file appears to have the coordinates.

I suggest reading over the links I gave and make sure that your FMT file is correct and you are giving the full paths to the files.
* 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).