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

#121
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>
"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

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.
"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

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.
"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

vab3

Hello Phil!
You have created a wonderful program. But it does not extract coordinates from the video from my DVR. Exiftool even reports that coordinates were not found in the file. But they are there. The manufacturer's program shows coordinates when playing. And in the file itself there are inserts very similar to them. Also, the altitude, speed, compass readings and maybe something else are recorded in the file.
I kindly ask you to help extract coordinates and other data from the video.
Link to the video file.
https://cloud.mail.ru/public/J7UD/yaa6M6qAg

With great respect, Vladimir

Phil Harvey

Hi Vladimir,

I tried your link but I get this:

QuoteСервис недоступен
Попробуйте обновить страницу через несколько минут или вернитесь на главную.

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

vab3

Hello Phil.
Sorry for the lack of access.
I am giving a new link.
https://drive.google.com/file/d/1q_uNGoN9wXCh-OQscc1t5ACKVJxHe9I9/view?usp=sharing

Thanks in advance.
Respectfully, Vladimir.



Phil Harvey

Hi Vladimir,

I got the file and have taken a look at it.  I can see the GPS and should be able to extract it.  Can you tell me the make/model of this device?

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

vab3

Hello Phil!
This is a motorcycle dash cam from a Chinese manufacturer XBHT. Model XB702.
Link to documentation.
https://manualspro.net/581256-xbht-motorcycle-motor-vehicle-dedicated-driving-recorder-xb702-user-manual

Respectfully, Vladimir.

Phil Harvey

Got it, thanks.  I am successfully decoding GPS and speed in 0.1 second intervals.  Expect to see this new ability in ExifTool 13.06.  I could upload a pre-release for you if you want it sooner than a couple of weeks -- are you running ExifTool on Windows?

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

vab3

Yes Phil. I use exiftool for windows. Would really appreciate it if I could get it sooner.
Thanks a lot!

Phil Harvey

Hi Vladimir,

Here is a 13.06 pre-release version for you.

You need to use the -ee option to extract the timed metadata.

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