ExifTool Forum

ExifTool => Newbies => Topic started by: Genesis on June 13, 2013, 03:10:39 AM

Title: Extracting GPS Information from .MP4?
Post by: Genesis on June 13, 2013, 03:10:39 AM
Gday,

I am new to the forum and am trying to extract the GPS track information from a captured .MP4 file.
Has anyone done this before? if so how?

Thank you in advance (Even if there is no solution  :P)

Murray
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 13, 2013, 07:17:45 AM
Hi Murray,

ExifTool will extract this information if it is stored as metadata in the MP4 container:

exiftool -location:all some_file.mp4

However, ExifTool will not yet extract this information if it is embedded in the video stream.  I have this on my list of things to do.  If you would like to have this ability, it would help if you could send me a sample (philharvey66 at gmail.com).

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Genesis on June 13, 2013, 07:16:21 PM
Phil,

Firstly thank you, I tried the command line it seemed to process the file fine but I cannot seem to get this to pipe into a file for viewing?.

I tried -w filenamt.txt also the > filename.txt etc with no luck, any ideas ?

Murray
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 13, 2013, 07:46:12 PM
Hi Murray,

If you use this command:

exiftool -w txt -g2 some_file.mp4

A ".txt" file will be created in the same directory and with the same name as your .mp4 file.

Here I changed "-location:all" to "-g2" so you will get all of the information, grouped by type.  You are looking for the "Location" group.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Genesis on June 13, 2013, 08:54:33 PM
Phil,

That worked, I managed to generate an output with that string but alas no "--- Location ---" group in sight, the Geocoding must be embedded in the video stream.
I have attached the file for you. I will keep a keen eye on your new versions for this functionality.

Thanks again

Murray
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 14, 2013, 07:31:07 AM
Hi Murray,

Sorry, I meant that it would be useful if you could email me an MP4.  The output .txt doesn't help me in decoding the GPS from the video stream.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Genesis on June 15, 2013, 07:38:11 AM
Phil,

Yeah... Sorry about that. I will send you one first thing Monday. I might have to drop box it to you as the file size might make an email impossible.
I will see how I go.

Murray
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 17, 2013, 08:04:03 AM
Hi Murray,

I got the file, thanks, and I've taken a quick look to see what is involved.  This will be a bit of work since it requires that I write my own codec to parse the video stream, but I'll see what I can do.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Genesis on June 18, 2013, 04:19:31 AM
Phil,

Thank you for even taking a look, if do end up building a parser then hats off to you my friend. I would be grateful!

Murray
Title: Re: Extracting GPS Information from .MP4?
Post by: sergey_ardrone on July 17, 2013, 09:29:39 AM
Hi everybody

I'm having the same issue as Genesis. I would like to extract the position metadata (GPS and Inertial Measurement Unit data) from a mp4 video. However, it does not seem to be stored in the header file.

The attached video was recorded with an AR. Drone together with a GPS receiver. My goal is it to get the position metadata for every frame of the video.

Can anybody point me out how to do that? I know that this metadata must be stored in the video file.

The video can be found here:

https://www.dropbox.com/s/tx39axrjgxvs9ml/video_20130717_145730.mp4 (https://www.dropbox.com/s/tx39axrjgxvs9ml/video_20130717_145730.mp4)

and here the header info:

exiftool video_drone.mp4
ExifTool Version Number         : 9.33
File Name                       : video_drone.mp4
Directory                       : .
File Size                       : 6.7 MB
File Modification Date/Time     : 2013:07:17 14:57:48+02:00
File Access Date/Time           : 2013:07:17 15:21:19+02:00
File Inode Change Date/Time     : 2013:07:17 15:21:08+02:00
File Permissions                : rwxrwxrwx
File Type                       : MP4
MIME Type                       : video/mp4
Major Brand                     : MP4  Base Media v1 [IS0 14496-12:2003]
Minor Version                   : 0.2.0
Compatible Brands               : isom, iso2, avc1, mp41
Movie Data Size                 : 6978856
Movie Header Version            : 0
Modify Date                     : 2013:07:17 14:57:31
Time Scale                      : 1000
Duration                        : 17.00 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 2
Track Header Version            : 0
Track Create Date               : 2013:07:17 14:57:31
Track Modify Date               : 2013:07:17 14:57:31
Track ID                        : 1
Track Duration                  : 17.00 s
Track Layer                     : 0
Track Volume                    : 0.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Image Width                     : 1280
Image Height                    : 720
Media Header Version            : 0
Media Create Date               : 2013:07:17 14:57:31
Media Modify Date               : 2013:07:17 14:57:31
Media Time Scale                : 30
Media Duration                  : 17.00 s
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Handler Class                   : Data Handler
Handler Type                    : URL
Handler Description             : DataHandler
Other Format                    : avc1
Software Version                : AR.Drone 2.0
Create Date                     : 2013:07:17 14:57:31+00:00
Avg Bitrate                     : 3.28 Mbps
Image Size                      : 1280x720
Rotation                        : 0

Cheers

Sergey
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on July 17, 2013, 09:48:22 AM
Hi Sergey,

I agree.  The GPS is stored in the video stream.  I haven't found enough time yet to extract this with ExifTool, but it is on my list of things to do.  ExifTool currently extracts GPS from M2TS videos, which use the H.264 codec, same as your MP4, so I'm thinking that I've probably already done most of the hard work.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: sergey_ardrone on July 17, 2013, 10:33:26 AM
Hi Phil

Thanks for the fast reply. Would be great to have this feature in ExifTool! 

Can you in the meanwhile give me some hint if there is an other way to get the stored metadata? I'm totally new to codecs/video parsing and I need the data for a research project. I have some programming experience so if you can point out some APIs I can try to get it running by myself.

Cheers

Sergey   
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on July 17, 2013, 10:49:53 AM
Hi Sergey,

Sorry, I don't know of any other utilities or API's that have this functionality.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: sergey_ardrone on July 18, 2013, 03:50:29 AM
Hi Phil

Ok thanks for your interest. I'll keep an eye on updates for ExifTool.

Cheers

Sergey
Title: Re: Extracting GPS Information from .MP4?
Post by: amal on November 21, 2013, 05:48:38 AM
Hi everybody,

I'm new in media, and exiftool, and i need the same things 'extract GPS data from video (.MP4, .TS)'.
i wonder if the new version is not ready yet  :).

Amal.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on November 21, 2013, 07:53:07 AM
I did spend some time working on this, but it was more work than I had hoped.  Maybe this would be a good project for me over the Christmas holiday.  I'll move it back up to the top of my to-do list.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: amal on December 05, 2013, 06:49:12 AM
Thanks Sir.
Title: Re: Extracting GPS Information from .MP4?
Post by: dvazquez on December 07, 2013, 08:40:17 AM
Hi guys,

I'm trying to extract the GPS information from a .mov file but I'm not able. Maybe it is something similar to your problem with .mp4? I could send you some videos if needed.

There are some applications that can read the GPS information from my videos but I would have to extrac the info video by video and I would like to use exiftool api to extract the info by myself ino my application.

Thanks in advance
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on December 07, 2013, 08:59:46 AM
I have responded to your other post (https://exiftool.org/forum/index.php/topic,5466.0.html)

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: DJPhrost on August 05, 2016, 03:51:05 AM
Any progress on this yet?
I'm desperately needing GPS location pulled from an MP4 recorded on a smart phone, not sure if Android or iPhone, in the mp4 format.

Thank you,
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on August 05, 2016, 07:27:49 AM
Sorry, no progress :(
Title: Re: Extracting GPS Information from .MP4?
Post by: DJPhrost on August 05, 2016, 12:18:35 PM
Curiously then, is there a specific reason?
I see this has been requested for many years now and seems to be very difficult to do, surely MP4s have geotags as well, or am I wrong?

What makes it so difficult to extract?

Just for personal edification.

I found a video of my now ex-fiance and another gentleman and was hoping the issue had been resolved so as to figure out whom it may have been. Oh well!
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on August 05, 2016, 02:51:45 PM
Maybe ExifTool already does what you want.  ExifTool extracts all metadata from MP4 videos, included the GPS position if written to the metadata.

The initial post is requesting extraction of the full GPS track, which is embedded in the video stream.  Extracting anything from the video stream is difficult.  I have done this H264 stream in a M2TS container, and it was a real pain (lack of documentation, complex format, etc).  Naively I would have thought that this would be easy to apply to the H264 stream in MP4 videos, but sadly this was not the case.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: DJPhrost on August 07, 2016, 02:43:33 AM
Oh.. I guess I misread the initial post.. Sorry!
I've not slept one wink since the 28th of last month, when I found out about this, more or less. Heh.

Let me post my own thread as to not hijack this one, sorry!
Title: Re: Extracting GPS Information from .MP4?
Post by: jmurch on August 25, 2016, 04:05:44 PM
Hi Phil,

I've been following this thread because this is pretty much the same thing I need to do re: extract the ongoing gps info from the mp4 stream.  I did go what I think is the obvious easy route that being use ffmeg to convert the mp4 to m2ts and then try to extract the gps info from the mt2s stream. So.... how do I use xiftool to do that?

Thanks, Jeff


OK RTFM.... found it I think but I get the following message:

exiftool -ee -p '$gpslatitude, $gpslongitude, $gpstimestamp' apgar.m2ts

Warning: [Minor] Tag 'gpslatitude' not defined - apgar.m2ts


#3:   I guess the tags are contingent on what they are named in the stream?  Is there anything I can use for a wildcard?   Here is the gpx that was extracetd by virb:

<trk>
    <name>apgar area</name>
    <extensions>
      <gpxx:TrackExtension>
        <gpxx:DisplayColor>DarkGray</gpxx:DisplayColor>
      </gpxx:TrackExtension>
    </extensions>
    <trkseg>
      <trkpt lat="48.521992899477482" lon="-113.98851854726672">
        <ele>989.4000244140625</ele>
        <time>2015-09-22T22:34:34Z</time>
      </trkpt>

#4 When this does work it just appears to be that same info from the metadata not the stream.
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on August 25, 2016, 05:11:14 PM
Quote from: jmurch on August 25, 2016, 04:05:44 PMIs there anything I can use for a wildcard?

Try
exiftool -gps* File

The tags may not be named gpslatitude, gpslongitude, etc.  Some video files have a single tag with all the info. 
Title: Re: Extracting GPS Information from .MP4?
Post by: Victor on November 19, 2016, 05:58:15 AM
I faced a similar requirement and have opted for a rather brute force solution.  Instead of reverse engineering the video stream I have extracted the GPS information from the video overlay (of course this assumes that the GPS information is being shown overlayed on the video frame itself).  The extracted data is saved to a GPX file.  The advantage of this method is that it can easily be customised to any video file, the disadvantage is that it is slower to extract the data.  If you are interested, you can download the software from here http://bigbugisoftware.jigsy.com/gpx-extractor (http://bigbugisoftware.jigsy.com/gpx-extractor).
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on January 04, 2018, 04:44:02 PM
ExifTool 10.72 (just released) has the ability to extract GPS from MOV/MP4 videos using the -ee option.  Please send me a sample if it doesn't extract it for your camera (philharvey66 at gmail.com).

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Insta on February 28, 2018, 09:00:40 AM
Quote from: Phil Harvey on January 04, 2018, 04:44:02 PM
ExifTool 10.72 (just released) has the ability to extract GPS from MOV/MP4 videos using the -ee option.  Please send me a sample if it doesn't extract it for your camera (philharvey66 at gmail.com).

- Phil

Hello! Can you help me to extract GPS data drom mp4 video using -ee processing feature? what should i insert? exiftool -ee 1.mp4?
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on February 28, 2018, 11:02:45 AM
Yes.  If that doesn't work, send me a sample video and I'll see what I can do to extract the GPS.  (my email is philharvey66 at gmail.com)

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on February 28, 2018, 11:52:18 AM
@Insta:  I got your sample, thanks.  The camera is apparently an Insta360, which (yet again) seems to have its own technique for storing the GPS.  I think I can see where it is stored, so I should be able to decode it.  I'll post back here when I know more.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 01, 2018, 12:00:50 PM
@Insta:  I've just released ExifTool 10.82 with the ability to extract timed GPS information from the Insta360 sample you provided.  Here is a command you can use with this version to generate a CVS file from this information:

exiftool -ee -n -p "$sampletime,$gpslatitude,$gpslongitude,$gpsaltitude" FILE > out.cvs

- Phil

Edit:  The above command will give a minor warning "Tag 'Main:sampletime' not defined" because the SampleTime tag is not defined in the main metadata.  Ignore this warning.
Title: Re: Extracting GPS Information from .MP4?
Post by: jonnyhonda on March 15, 2018, 10:48:01 AM
Been watching this thread for a while hoping it would resolve my problem, but it looks like my camera custom encodes the GPS information too. I'm currently writing an application to report potholes on roads in the UK, if you watch the first 4 seconds of this you'll see why.

https://www.dropbox.com/s/mcjdtzt5yd1zxyo/REC_0027.AVI?dl=0

The Camera is a proprietary one called BikeBro, it's dual channel camera with GPS and 3 axis G-shock sensor, I've managed to glean from the manufacturer that the metadata is applied to the video stream by the SoC at recording time.

I would be interested in any advice as I know the camera is not that common and discontinued, there is a propitiatory viewer here http://www.nortek.co.uk/bike-bro-dual-camera-motorcycle-dvr/

Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 15, 2018, 10:59:07 AM
I got your sample AVI video.  I'll see what I can decode from this and post back later.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 15, 2018, 11:36:13 AM
I think I can see where the information is stored, and I think I can extract it.  I'll post back when I know more.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 15, 2018, 12:39:10 PM
So far I can extract the lat/lon and time, but I'm having trouble with the date.  Do you know what date this video was taken?  Should be able to extract the accelerometer data too.

- Phil

Edit: Found it.  Was shot yesterday. :)
Title: Re: Extracting GPS Information from .MP4?
Post by: jonnyhonda on March 15, 2018, 01:01:26 PM
Wow, that's amazing, yes it was shot yesterday about 4pm uk time
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 15, 2018, 01:42:16 PM
ExifTool 10.86 (just released) will decode the GPS and accelerometer information from the sample video you provided.

Use this command to see all the available information:

exiftool -ee -G3 FILE

The records are extracted as sub-documents, each with a video FrameNumber that allows you to relate the tags to the time in the original video.

- Phil

Edit:  As a usage example, the following command gives the attached output file:

exiftool -ee -p "GPS $framenumber $gpslatitude $gpslongitude" -p "ACC $framenumber $accelerometer" -n REC_0027.AVI > out.txt
Title: Re: Extracting GPS Information from .MP4?
Post by: jonnyhonda on March 15, 2018, 02:23:39 PM
That is awesome Phil, you certainly know your Exif.

I've donated a few dollars, I don't what a beer costs out there but drink it wisely my friend.

Many thanks
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 15, 2018, 02:30:44 PM
Thanks!  That'll buy me a couple of Guinness from the supermarket. :)

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: rickvdk on May 01, 2018, 11:45:50 PM
Hi Phil,

I'm trying to understand the guide in this blog but I'm having difficulties understanding what exactly I might be doing wrong.

I have an mp4 video file that I would love to know the gps location where it was shot. I downloaded your exiftool and somehow can't seem to make things happen.

I'm hoping you're reading this sometime soon and feel compelled to helping me out :)

Sincerely,
Rick
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on May 02, 2018, 06:58:24 AM
Hi Rick,

Are you running Windows?  If so, try renaming "exiftool(-k).exe" to "exiftool(-k -ee).exe", then drag and drop the MP4 on the .exe

For the file you posted, I don't see any gps:

ExifTool Version Number         : 10.94
File Name                       : VID-20180428-WA0000.mp4
Directory                       : /Users/phil/Desktop
File Size                       : 1628 kB
File Modification Date/Time     : 2018:05:02 06:58:44-04:00
File Access Date/Time           : 2018:05:02 06:58:45-04:00
File Inode Change Date/Time     : 2018:05:02 06:58:44-04:00
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.1
Compatible Brands               : mp41, mp42, isom
Movie Header Version            : 0
Create Date                     : 2018:04:28 01:02:51
Modify Date                     : 2018:04:28 01:02:52
Time Scale                      : 600
Duration                        : 10.00 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Track Header Version            : 0
Track Create Date               : 2018:04:28 01:02:51
Track Modify Date               : 2018:04:28 01:02:52
Track ID                        : 1
Track Duration                  : 10.00 s
Track Layer                     : 0
Track Volume                    : 100.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2018:04:28 01:02:51
Media Modify Date               : 2018:04:28 01:02:52
Media Time Scale                : 44100
Media Duration                  : 10.08 s
Media Language Code             : und
Handler Type                    : Audio Track
Handler Description             : Core Media Audio
Balance                         : 0
Audio Format                    : mp4a
Audio Channels                  : 1
Audio Bits Per Sample           : 16
Audio Sample Rate               : 44100
Track Header Version            : 0
Track Create Date               : 2018:04:28 01:02:51
Track Modify Date               : 2018:04:28 01:02:52
Track ID                        : 2
Track Duration                  : 10.00 s
Track Layer                     : 0
Track Volume                    : 100.00%
Matrix Structure                : 0 1 0 -1 0 0 0 0 1
Image Width                     : 960
Image Height                    : 540
Media Header Version            : 0
Media Create Date               : 2018:04:28 01:02:51
Media Modify Date               : 2018:04:28 01:02:52
Media Time Scale                : 600
Media Duration                  : 10.03 s
Media Language Code             : und
Handler Type                    : Video Track
Handler Description             : Core Media Video
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Compressor ID                   : avc1
Source Image Width              : 960
Source Image Height             : 540
X Resolution                    : 72
Y Resolution                    : 72
Bit Depth                       : 24
Color Representation            : nclx 1 1 6
Video Field Order               : Progressive; 0
Video Frame Rate                : 30
Description                     : {"WXVer":369493538}
Movie Data Size                 : 1659504
Movie Data Offset               : 7152
Avg Bitrate                     : 1.33 Mbps
Base Name                       : VID-20180428-WA0000
File Extension                  : mp4
File Type Description           : MPEG-4 video
Image Size                      : 960x540
Megapixels                      : 0.518
Rotation                        : 90


- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: sylloge on July 18, 2018, 12:37:09 AM
on windows and exiftool 11.06

A DJI drone x3 camera creates this mp4
https://drive.google.com/file/d/1zvl4Eey0ej1yDvEN_zkjN6cT0g3pWvZO/view?usp=sharing

exiftool -ee  dji.mp4 > ee.txt
ee.txt attached
this just gives a result as if it's a single frame

-ee only adds $Matrix Structure and $Handler Type compared to exiftool without -ee

if this can be sorted how do you limit the number of gps co-ords returned
eg say every 5 seconds

thanks


Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on July 18, 2018, 07:20:58 AM
Are you sure this video contains streaming GPS?  I can't see where it would be in the data.  Other DJI videos have separate tracks for this, but this video has only one track (the AVC video track).  It looks like this video was edited with some Microsoft product which I suspect removed the streaming GPS.

To answer your second question, exiftool will only output all of the GPS coords.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: sylloge on July 19, 2018, 05:00:38 AM
It wasn't edited, at least I can stop looking.

Same result with a z3 camera.

Then I started trying all the settings, captioning kind of gives me a solution.
It creates a standard .srt text file (attached) with gps co-ords each second, but only to 4 decimals / 10m

Title: Re: Extracting GPS Information from .MP4?
Post by: sylloge on July 28, 2018, 11:38:43 PM
I have a different camera, phantom 4, it embeds a subtitle track in the file

>exiftool -ee -n  moonee\dji_0016.mp4 > moonee\dji_0016.txt [ file attached ]

what i'd like to be able to do is create a .geojson file from a directory of files

I can do this for photos as they are points and just use a singe co-ord 
exiftool -n -p photo.fmt clubhouse\*.jpg > clubhouse.geojson

but for videos I want to create a linestring using the information from the line
Text                            : F/4, SS 800, ISO 100, EV +0.7, GPS (153.1539, -30.2041, 13), D 43.75m, H 0.00m, H.S 0.41m/s, V.S 0.00m/s .

using my -p video.fmt i get
Warning: [Minor] Tag 'Main:text' not defined - moonee/dji_0016.mp4

is there a switch that will
- read the text line
- extract just the cords within ()

regards
stephen
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on July 30, 2018, 07:26:37 AM
Did you see the dji.config file (https://github.com/exiftool/exiftool/blob/master/config_files/dji.config) in the full ExifTool distribution?  This configuration allows you to generate GPS tags from the DJI subtitle track.  Then you should be able to use your photo.fmt file with the videos.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Krampapas on August 10, 2018, 06:27:27 AM
Hello, I am currently working on extracting GPS data from a MP4 video that i create using  a set of 5FPS 8K 360 street-view-level videos shot from Insta360Pro. I was wondering if there is more gps information stored in the metadata of the file as yaw, pitch, and roll that is stored in Google Maps Street View.The videos fullfil the requirments for Google Street view so accorting to Google CAmera Motion Metadata (CAMM) found on https://developers.google.com/streetview/publish/camm-spec should be on the video.

https://drive.google.com/file/d/1_jQTmHLZCq-rsmT4wk3MmqgMpAFun1PM/view?usp=sharing

Thank you
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on August 10, 2018, 09:27:51 PM
There is definitely some metadata in the camm type 2 and 3 records that ExifTool isn't decoding, but it may be difficult to figure out how to decode this without more information.  You can see it in raw form with exiftool -ee -v3 FILE.  If you have any more details about what is stored in this video, let me know.   I'll look into this again when I get a chance.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on August 11, 2018, 08:43:06 AM
OK, the camm2 and camm3 metadata seems to be 3 float values each.  Camm3 looks like accelerations with the 3rd number being Z in m/s^2.  Camm2 could be angular velocity or acceleration.  Here are the first values from the file you sent:

Camm 2                          : -0.0217499062418938 -0.0105053121224046 0.0439290478825569
Camm 2                          : -0.0355848222970963 -0.0158264338970184 0.0439290478825569
Camm 2                          : -0.0440986156463623 -0.0190191064029932 0.0428648255765438
Camm 2                          : -0.0526124089956284 -0.022211778908968 0.0428648255765438
Camm 2                          : -0.0589977540075779 -0.0243402272462845 0.0418005995452404
Camm 2                          : -0.0632546544075012 -0.0254044514149427 0.0418005995452404
Camm 2                          : -0.0664473250508308 -0.026468675583601 0.0418005995452404
Camm 2                          : -0.0675115510821342 -0.0275328997522593 0.0418005995452404
Camm 2                          : -0.0675115510821342 -0.0275328997522593 0.0418005995452404
Camm 2                          : -0.0653830990195274 -0.0275328997522593 0.0418005995452404
Camm 2                          : -0.0621904283761978 -0.026468675583601 0.0418005995452404
Camm 2                          : -0.0589977540075779 -0.0254044514149427 0.0418005995452404
Camm 2                          : -0.0536766350269318 -0.0232760030776262 0.0407363772392273
Camm 2                          : -0.0472912862896919 -0.0211475547403097 0.0407363772392273
Camm 2                          : -0.0419701673090458 -0.0179548822343349 0.0407363772392273
Camm 2                          : -0.0377132706344128 -0.0158264338970184 0.0396721512079239
Camm 2                          : -0.0291994754225016 -0.0126337604597211 0.0396721512079239
Camm 2                          : -0.0164287853986025 -0.00731263961642981 0.0396721512079239
Camm 2                          : -0.00791499018669128 -0.00411996664479375 0.0396721512079239
Camm 2                          : 0.000598803511820734 -0.000927294022403657 0.0396721512079239
Camm 2                          : 0.00804837327450514 0.00120115443132818 0.0396721512079239
Camm 2                          : 0.013369495049119 0.00332960300147533 0.0396721512079239
Camm 2                          : 0.0197548400610685 0.00652227597311139 0.0386079289019108
Camm 2                          : 0.0261401850730181 0.00865072384476662 0.0386079289019108
Camm 2                          : 0.0325255319476128 0.0107791731134057 0.0386079289019108
Camm 2                          : 0.0367824286222458 0.0139718456193805 0.0375437028706074
Camm 2                          : 0.0410393252968788 0.0171645190566778 0.0375437028706074
Camm 2                          : 0.0463604480028152 0.0203571915626526 0.0375437028706074
Camm 2                          : 0.0506173446774483 0.0224856398999691 0.0375437028706074
Camm 2                          : 0.0538100153207779 0.0246140882372856 0.0364794805645943
Camm 2                          : 0.0570026896893978 0.0267425365746021 0.0364794805645943
Camm 2                          : 0.0591311380267143 0.0278067607432604 0.0354152545332909
Camm 2                          : 0.0623238086700439 0.0278067607432604 0.0354152545332909
Camm 2                          : 0.0633880347013474 0.0278067607432604 0.0343510322272778
Camm 2                          : 0.0633880347013474 0.0278067607432604 0.0343510322272778
Camm 2                          : 0.0633880347013474 0.0267425365746021 0.0343510322272778
Camm 2                          : 0.0612595863640308 0.0256783124059439 0.0343510322272778
Camm 2                          : 0.0591311380267143 0.0246140882372856 0.0343510322272778
Camm 2                          : 0.0548742413520813 0.0214214157313108 0.0343510322272778
Camm 2                          : 0.0516815669834614 0.0192929673939943 0.0343510322272778


Camm 3                          : 0.196191400289536 -0.148339837789536 10.1541013717651
Camm 3                          : 0.270361334085464 -0.31103515625 9.88134765625
Camm 3                          : 0.296679675579071 -0.480908215045929 9.79282188415527
Camm 3                          : 0.325390636920929 -0.495263665914536 9.78085899353027
Camm 3                          : 0.35888671875 -0.626855492591858 9.78803730010986
Camm 3                          : 0.349316418170929 -0.748876929283142 9.81435585021973
Camm 3                          : 0.483300775289536 -0.849365234375 9.941162109375
Camm 3                          : 0.600537121295929 -0.93310546875 9.86699199676514
Camm 3                          : 0.4306640625 -0.966601550579071 9.92919921875
Camm 3                          : 0.531152367591858 -1.12690424919128 9.85981464385986
Camm 3                          : 0.514404296875 -1.19389653205872 9.83349609375
Camm 3                          : 0.540722668170929 -1.05991208553314 9.74497032165527
Camm 3                          : 0.567041039466858 -1.112548828125 9.83828163146973
Camm 3                          : 0.533544898033142 -1.22500002384186 9.79282188415527
Camm 3                          : 0.543115258216858 -1.06948244571686 9.80478477478027
Camm 3                          : 0.57421875 -0.988134741783142 9.87417030334473
Camm 3                          : 0.488085925579071 -1.07187497615814 9.89809608459473
Camm 3                          : 0.512011706829071 -0.985742211341858 9.83110332489014
Camm 3                          : 0.579003930091858 -0.863720715045929 9.70908164978027
Camm 3                          : 0.4306640625 -0.846972644329071 9.57509803771973
Camm 3                          : 0.401953130960464 -0.882861316204071 9.666015625
Camm 3                          : 0.3349609375 -0.799121081829071 9.677978515625
Camm 3                          : 0.294287115335464 -0.605322241783142 9.81674766540527
Camm 3                          : 0.339746087789536 -0.614892601966858 9.99858379364014
Camm 3                          : 0.287109375 -0.638818383216858 10.1397457122803
Camm 3                          : 0.155517578125 -0.435449212789536 10.2187013626099
Camm 3                          : 0.141162112355232 -0.265576183795929 10.0057621002197
Camm 3                          : 0.212939456105232 -0.327783197164536 9.89570331573486
Camm 3                          : 0.186621099710464 -0.3349609375 9.81196308135986
Camm 3                          : 0.0622070319950581 -0.0622070319950581 9.70429706573486
Camm 3                          : 0.0478515625 -0.0502441413700581 9.66362285614014
Camm 3                          : 0.0622070319950581 -0.083740234375 9.62773418426514
Camm 3                          : 0.0263183601200581 0.0813476592302322 9.90288066864014
Camm 3                          : -0.0645996108651161 0.0885253921151161 9.83349609375
Camm 3                          : -0.0693847686052322 0.112451173365116 9.91962909698486
Camm 3                          : -0.00957031268626451 0.0502441413700581 9.86459922790527
Camm 3                          : -0.0143554685637355 0.141162112355232 9.93637657165527
Camm 3                          : -0.0669921860098839 0.184228509664536 9.85263633728027
Camm 3                          : -0.0765625014901161 0.141162112355232 9.773681640625
Camm 3                          : -0.028710937127471 0.110058590769768 9.78085899353027


Any ideas as to exactly what they could be?  It would be good to nail down the orientation and units for each value.

- Phil

Edit:  After plotting and looking at the data more closely, I'm leaning towards calling camm2 "AngularVelocity" with the note "angular velocity about X, Y and Z axes in rad/s", and camm3 "Acceleration" with the note "acceleration in the X, Y and Z directions in m/s^2".  Does this sound OK?

If you could shoot a short video with the camera rotated about each of the 3 axes, then I could be more confident about this.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on August 11, 2018, 10:43:21 AM
There is also some interesting undecoded information in the camm6 metadata.  See the attached plot for these values during the video you sent.  Any ideas about these?

Edit:  The green/purple look like components of velocity in two directions (north and east?), but what units?  The peak is only 6, could it be in knots (roughly 12 km/hr)?

Edit2: Still working on this... I think the units look like m/s...
Title: Re: Extracting GPS Information from .MP4?
Post by: Krampapas on August 13, 2018, 07:08:30 AM
Hi Phil, Many thanks for all your help! If by camm2 and camm3 you refer to the different types of metadata samples defined according to the google camm api, then i guess you are right. if you check here: https://developers.google.com/streetview/publish/camm-spec, there are 8 cases (0-7). type 2 is three floats and seems to be gyroscope signal (radians/seconds), and type 3 is three floats and is the accelerometer reading (meters/seconds^2). type 6 seems to have gps coordinates and altitude, among others. ideally we would be interested to decode all possible types, as we are not certain yet which are useful for our purpose - e.g. type 0 is angle-axis orientation, type 4 is position, and type 5 is gps latitude/longitute/altitude. Can you tell which of these are available in the mp4? Unfortunately we no longer have access to the camera to shoot test videos and the manufacturer has not been very helpful about this. Again, many thanks for your effort! We greatly appreciate it!
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on August 13, 2018, 08:48:20 AM
I should have looked at the link you posted sooner.  The video contains camm2, camm3 and camm6 metadata, and with this information I should be able to fully decode it.  Look for this in ExifTool 11.09 when it is released.

Thanks!

- Phil

Edit: ExifTool 11.09 is now available.
Title: Re: Extracting GPS Information from .MP4?
Post by: tomcheney on September 04, 2018, 06:44:58 AM
Hi Phil,

I am trying to get accurate time and gps position from an mp4 file from a DJI Phantom Pro drone. I am managing to do the same thing for some GoPro video using the GPMF data in the video file. I have been using ffmpeg to strip out the meta stream and then this tool https://github.com/stilldavid/gopro-utils to get a JSON dump of the gps track.

Frustratingly I can see that the dpi video has a meta channel and I can extract it but I can't find any reference for how to decode it. Fundamentally I can't find the GPS start time of the video file, which feels like it should be obvious!!

Tom
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on September 04, 2018, 04:05:50 PM
Hi Tom,

Is this an ExifTool question?  ExifTool should be able to decode this.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: tomcheney on September 06, 2018, 04:58:09 AM
Hi Phil,

Here is a video I took using a DJI phantom 4 pro drone and an iPad mini

https://drive.google.com/file/d/1qimYEUl-onEZ_njdFGLyhtArouyeim8f/view?usp=sharing

The actual start time of the recording was around 2018-09-03 1604 UTC but the exif data seems to show the incorrect time (I think due to the clock on the iPad)

Even when the iPad clock is set correctly there is significant drift across the day. Given that ExifTool can show the GPS latitude, longitude, roll, pitch and yaw of the device (I assume at the starting time of the video) is there a way to get GPS time?

Tom
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on September 06, 2018, 07:15:54 AM
Hi Tom,

Unfortunately DJI doesn't store the GPS date/time.  I think your best bet is to attempt to correct for the clock drift.

About the 3 hour time offset... try using the -api quicktimeutc option, and make sure that your iPad time zone is set correctly.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: ptpmashish on December 20, 2018, 12:41:55 PM
HI phil,

I tried many commands from this thread and some other to retrieve gps data from the video.

https://drive.google.com/drive/folders/1g-G9hyFj5tP6JSOPrSwLTaSecSWvrawX?usp=sharing

When i play the video in quicktime, it shows the GPS coordinate on the video. but not able to extract.

please see what can be done.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on December 20, 2018, 12:57:16 PM
Sorry.  As far as I can tell there is no GPS metadata in this file.  ExifTool can not extract information from text stamped into a video image.  If they had done this properly as a subtitle track then ExifTool could extract it.  But sadly, that is not the case.

- Phil

Title: Re: Extracting GPS Information from .MP4?
Post by: leonard_zh on March 24, 2019, 05:44:21 PM
Hi Phil,
thanks for all great work you've done for this software. I am going to extract GPS information from my dashcam mp4. I can see there is a GPS data list in binary format through the example output command. Could you help me to give some clue on how to extract the GPS information in a readable format like in txt?
Here attaches the mp4 file:
https://drive.google.com/file/d/1GtClFYWwzVx9hjzjddbemcE2HQxPspDQ/view?usp=sharing

Thanks!

---- ExifTool ----
ExifTool Version Number         : 11.32
Warning                         : [minor] The ExtractEmbedded option may find more tags in the movie data
---- System ----
File Name                       : 2019_0324_163821_007.MP4
Directory                       : D:/Data/DashCam
File Size                       : 253 MB
File Modification Date/Time     : 2019:03:24 16:40:04-04:00
File Access Date/Time           : 2019:03:24 17:34:42-04:00
File Creation Date/Time         : 2019:03:24 17:34:42-04:00
File Permissions                : rw-rw-rw-
---- File ----
File Type                       : MP4
File Type Extension             : mp4
MIME Type                       : video/mp4
---- QuickTime ----
Major Brand                     : MP4 v2 [ISO 14496-14]
Minor Version                   : 0.0.0
Compatible Brands               : isom, avc1, mp42
Movie Data Size                 : 265579344
Movie Data Offset               : 7616
Movie Header Version            : 0
Create Date                     : 2019:03:24 16:40:03
Modify Date                     : 2019:03:24 16:40:03
Time Scale                      : 60000
Duration                        : 0:01:44
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 3
Format                          : NOVATEK
Information                     : DEMO1
GPS Data List                   : (Binary data 832 bytes, use -b option to extract)
---- Kodak ----
Duration                        : 0:01:43
Kodak Version                   : 3.01.051
Thumbnail Image                 : (Binary data 7528 bytes, use -b option to extract)
---- Track1 ----
Track Header Version            : 0
Track Create Date               : 2019:03:24 16:40:03
Track Modify Date               : 2019:03:24 16:40:03
Track ID                        : 1
Track Duration                  : 0:01:44
Track Layer                     : 0
Track Volume                    : 0.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Image Width                     : 2560
Image Height                    : 1440
Media Header Version            : 0
Media Create Date               : 2019:03:24 16:40:03
Media Modify Date               : 2019:03:24 16:40:03
Media Time Scale                : 60000
Media Duration                  : 0:01:44
Handler Class                   : Media Handler
Handler Type                    : Video Track
Handler Description             : VideoHandler
Graphics Mode                   : srcCopy
Op Color                        : 0 0 0
Handler Class                   : Data Handler
Handler Type                    : URL
Handler Description             : DataHandler
Compressor ID                   : avc1
Source Image Width              : 2560
Source Image Height             : 1440
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : h264
Bit Depth                       : 24
AVC Configuration               : (Binary data 36 bytes, use -b option to extract)
Video Frame Rate                : 30
Sync Sample Table               : (Binary data 840 bytes, use -b option to extract)
Sample To Chunk                 : (Binary data 20 bytes, use -b option to extract)
Sample Sizes                    : (Binary data 12436 bytes, use -b option to extract)
Chunk Offset                    : (Binary data 12432 bytes, use -b option to extract)
---- Track2 ----
Track Header Version            : 0
Track Create Date               : 2019:03:24 16:40:03
Track Modify Date               : 2019:03:24 16:40:03
Track ID                        : 2
Track Duration                  : 0:01:44
Track Layer                     : 0
Track Volume                    : 100.00%
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Media Header Version            : 0
Media Create Date               : 2019:03:24 16:40:03
Media Modify Date               : 2019:03:24 16:40:03
Media Time Scale                : 32000
Media Duration                  : 0:01:44
Handler Class                   : Media Handler
Handler Type                    : Audio Track
Handler Description             : SoundHandler
Balance                         : 0
Handler Class                   : Data Handler
Handler Type                    : URL
Handler Description             : DataHandler
Audio Format                    : mp4a
Audio Channels                  : 1
Audio Bits Per Sample           : 16
Audio Sample Rate               : 32000
Unknown esds                    : (Binary data 31 bytes, use -b option to extract)
Time To Sample Table            : (Binary data 16 bytes, use -b option to extract)
Sample To Chunk                 : (Binary data 20 bytes, use -b option to extract)
Sample Sizes                    : (Binary data 12952 bytes, use -b option to extract)
Chunk Offset                    : (Binary data 12948 bytes, use -b option to extract)
---- Composite ----
Avg Bitrate                     : 20.5 Mbps
Image Size                      : 2560x1440
Megapixels                      : 3.7
Rotation                        : 0

Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on March 24, 2019, 07:57:19 PM
Just add the -ee (extractEmbedded) option (https://exiftool.org/exiftool_pod.html#ee--extractEmbedded) to get all the data in readable format.  If you want to limit the output to just the GPS data, add -GPS*.

To get it in a useful geo track file, such as gpx or kml, download the appropriate format file from github (https://github.com/exiftool/exiftool/tree/master/fmt_files) and drop it in the same directory as exiftool.  You can then run
exiftool -p gpx.fmt FILE.mp4 > out.gpx
and exiftool with create a geotrack.  Replace gpx.fmt with kml.fmt if you want a kml type geotrack.

See Inverse Geotagging (https://exiftool.org/geotag.html#Inverse) for more details.
Title: Re: Extracting GPS Information from .MP4?
Post by: leonard_zh on March 24, 2019, 09:48:05 PM
That's awesome! Thank you a lot!
Title: Re: Extracting GPS Information from .MP4?
Post by: sjytribe on March 03, 2020, 11:17:41 AM
Trying to use the exiftool to extract the GPS from a GoPro MP4 file and using various options but appear to be struggling with "large file support not enabled"

Currently using the following options

exiftool.exe -p gpx.fmt GH015087.mp4 > out.gpx


Am I missing something ?
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on March 03, 2020, 11:23:47 AM
Try this:

exiftool.exe -api largefilesupport -ee -p gpx.fmt GH015087.mp4 > out.gpx

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 23, 2020, 12:53:45 PM
Any body tried decoding lukas ace 7900 videos gps location? The default extractor gives only locations 1 minute away while I need 1 second location to upload to Mapillary. The default viewer shows the lcoations and accelerometer during playback but no option to export.  I contributed about 800km videos to mapillary from another 70mai dash camera, but this proprietery standard is not allowing

Any who wanted to have a look at the viewer and sample files at https://drive.google.com/open?id=0B-_IfqQwPO0AbWFfaUx4aGxYQms
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 23, 2020, 02:51:30 PM
I think I can see the GPS in this video, but it will take some work to be able to decode it.

The precision of the coordinates seems to be 0.006 seconds, which is pretty good.

Give me some time to work on this.

- Phil

Edit:  Ah.  Looking at your CSV file I see you mean 1 minute in time, not 1 minute coordinate precision.  Yes.  The positions are recorded every second in the AVI file.
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 23, 2020, 04:16:29 PM
Phil, Thanks in Advance..  Be safe.. I have 1.6TB video waiting to uploaded to Mapillary after converting.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 24, 2020, 12:09:43 PM
ExifTool 11.96 is now available, and should extract the GPS from these AVI files with the -ee option.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 24, 2020, 01:28:56 PM
need details like which mp4 file and how you know gps data is inside. Searching in the file without any clue whether data is inside is difficult.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 24, 2020, 02:27:06 PM
I don't understand.

Quote from: johnichan on April 24, 2020, 01:28:56 PM
need details like which mp4 file

Both AVI files that you posted.  If you send an MP4 then I didn't see it.

Quotehow you know gps data is inside.

You can see it by running exiftool -ee on these files.

QuoteSearching in the file without any clue whether data is inside is difficult.

How are you searching in the file?  I don't understand what you want to do.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 24, 2020, 02:47:30 PM
Hi Phil,

Sorry for the confusion. I am a fool to reply to a very old message to amal on 2013 listed below,seeing a 'newbie' tag. Ignore it...

"Re: Extracting GPS Information from .MP4?
« Reply #14 on: November 21, 2013, 05:48:38 AM »"
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 25, 2020, 12:21:09 PM
Hi Phil,
I got another clue that the gps data is present in junk section when opened in the riffpad. Now we need a way to batch extract junk section & process the gps co ordinates. Can you please help to do riff extract? I have given the riff extracted format in the same google drive link  https://drive.google.com/open?id=0B-_IfqQwPO0AbWFfaUx4aGxYQms
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 25, 2020, 09:06:11 PM
Again, I don't understand.

Are you looking for a utility other than ExifTool to extract this information?  Or is ExifTool not extracting it in the format that you want?  If the latter, then I can show you how to extract it in any format you want if you are more specific about what you require.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 25, 2020, 11:44:13 PM
Hi Phil,

I am a Hardware engineer and I am not actually trained to write softwares, but doing it as a hobby. Now I found the required information is available in "Junk" tag of the file using riffpad tool,which is graphical. I need exiftool to extract 'Junk' tag as a batch process in command line to get text file output and I will add a perl script to extract to CSV from text output file. The following section from the Junk section which can be used for geo tagging(This is raw gps strings output from gps receiver). The information of every second is available in the string below. .....:...0GDA..e.H...&...........:...0GDA..e.H...-...........9...0GDA4.e.H...%...........:...0GDAk.e.H...K...........9...0GDA..e.H...............9...0GPSt.e.H...............F..@....o..@......H@9$GA,052$GA,052349,A,0949.6572,07635.4297,046,N,E,*4A...$GC,052349,180914,0000955,1,08,1.1,0016,,A*4C...$GA,052350,A,0949.6595,07635.4369,048,N,E,*45...0GPS..e.H.............:.M..@..n.q..@......H@9$GC,052$GC,052350,180914,0000955,1,08,1.1,0017,,A*45...$GA,052351,A,0949.6626,07635.4439,049,N,E,*4C...$GC,052351,180914,0000955,1,08,1.1,0017,,A*44...0GPS..e.H...........f.c]\..@.~j.t..@......F@9$GA,052$GA,052352,A,0949.6660,07635.4504,047,N,E,*4C...$GC,052352,180914,0000955,1,08,1.1,0018,,A*48...$GA,052353,A,0949.6701,07635.4560,045,N,E,*4B...0GPS..e.H............C.lg..@Y.8.u..@......F@9$GC,052$GC,052353,180914,0000955,1,08,1.1,0019,,A*48...$GA,052354,A,0949.6755,07635.4603,045,N,E,*4B...$GC,052354,180914,0000956,1,08,1.1,0020,,A*46...0GPS..e.H.............n....@J..+w..@......H@9$GA,052$GA,052355,A,0949.6818,07635.4634,046,N,E,*4B...$GC,052355,180914,0000956,1,08,1.1,0021,,A*46...$GA,052356,A,0949.6890,07635.4655,049,N,E,*40...0GPS,.e.H.............s....@P..sw..@......I@9$GC,052$GC,052356,180914,0000956,1,08,1.1,0022,,A*46...$GA,052357,A,0949.6967,07635.4666,051,N,E,*41...$GC,052357,180914,0000956,1,07,1.3,0023,,A*4B...0GPSx.e.H...`........w.....@....w..@......K@9$GA,052$GA,052358,A,0949.7049,07635.4671,054,N,E,*49...$GC,052358,180914,0000956,1,07,1.3,0024,,A*43...0GPS..e.H............c]....@.Mb.x..@......M@9$GA,052$GA,052359,A,0949.7134,07635.4678,057,N,E,*49...$GC,052359,180914,0000957,1,07,1.3,0024,,A*43...$GA,052400,A,0949.7221,07635.4690,058,N,E,*4C...0GPS/.e.H..............D...@.-..x..@......M@9$GC,052$GC,052400,180914,0000957,1,07,1.3,0025,,A*49...$GA,052401,A,0949.7306,07635.4712,058,N,E,*42...$GC,052401,180914,0000957,1,07,1.3,0025,,A*48...0GPS..e.H.............._...@..0.z..@......J@9$GA,052$GA,052402,A,0949.7383,07635.4746,055,N,E,*40...$GC,052402,180914,0000957,1,07,1.3,0025,,A*4B...$GA,052403,A,0949.7453,07635.4789,053,N,E,*4E...0GPS..e.H..................@.&1.|..@......L@9$GC,052$GC,052403,180914,0000958,1,07,1.3,0025,,A*45...$GA,052404,A,0949.7518,07635.4845,056,N,E,*4D...$GC,052404,180914,0000958,1,07,1.3,0025,,A*42...0GPS..e.H..................@.-.....@......M@9$GA,052$GA,052405,A,0949.7575,07635.4911,057,N,E,*46...$GC,052405,180914,0000958,1,08,1.1,0025,,A*4E...$GA,052406,A,0949.7625,07635.4985,058,N,E,*41...0GPS..e.H...............(..@.......@......M@9$GC,052$GC,052406,180914,0000958,1,08,1.1,0025,,A*4D...$GA,052407,A,0949.7666,07635.5069,061,N,E,*47...$GC,052407,180914,0000959,1,08,1.1,0025,,A*4D...$GA,052408,A,0949.7698,07635.5155,059,N,E,*4C...0GPSl.e.H.............1w-..@`vO....@......L@9$GC,052$GC,052408,180914,0000959,1,08,1.1,0025,,A*42...$GA,052409,A,0949.7722,07635.5239,057,N,E,*4A...$GC,052409,180914,0000959,1,08,1.1,0025,,A*43...0GPSu.e.H.............W.2..@...Q...@......J@9$GA,052$GA,052410,A,0949.7739,07635.5322,054,N,E,*40...$GC,052410,180914,0000960,1,08,1.1,0026,,A*42...$GA,052411,A,0949.7748,07635.5403,052,N,E,*45...0GPS[.e.H..............g3..@..HP...@......I@9$GC,052$GC,052411,180914,0000960,1,08,1.1,0026,,A*43...$GA,052412,A,0949.7751,07635.5481,050,N,E,*46...$GC,052412,180914,0000960,1,08,1.1,0026,,A*40...0GPSP.e.H..............g3..@EGr....@......F@9$GA,052$GA,052413,A,0949.7750,07635.5555,047,N,E,*48...$GC,052413,180914,0000960,1,08,1.1,0026,,A*41...$GA,052414,A,0949.7751,07635.5624,044,N,E,*48...0GPS=.e.H............'..5..@<.R....@......D@9$GC,052$GC,052414,180914,0000960,1,08,1.1,0026,,A*46...$GA,052415,A,0949.7759,07635.5687,041,N,E,*4D...$GC,052415,180914,0000961,1,08,1.1,0027,,A*47...0GPS..e.H...`.........Y.9..@.&S....@......C@9$GA,052$GA,052416,A,0949.7783,07635.5743,039,N,E,*4F...$GC,052416,180914,0000961,1,08,1.1,0027,,A*44...0GPS..e.H.............^)K..@}..Y...@......D@9$GA,052$GA,052417,A,0949.7820,07635.5792,039,N,E,*44...$GC,052417,180914,0000961,1,08,1.1,0027,,A*45...$GA,052418,A,0949.7867,07635.5834,041,N,E,*44..
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 26, 2020, 06:46:56 AM
To extract the raw data of the junk tag you would need to create a user-defined tag in ExifTool.

However, ExifTool 11.96 has the ability to produce a CSV file directly from this information.  For example:

exiftool -p "$gpsdatetime,$gpslatitude,$gpslongitude,$gpsaltitude,$gpsspeed" -n -ee FILE > out.csv

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 26, 2020, 07:15:52 AM
HI Phil,

Can you guide to make the user defined tag to get the 'JUNK' inside the RIFF?  I have no idea on how to extract a tag from a video file.  Google guides to RIFF.pm written by you at git hub https://github.com/alchemy-fr/exiftool/blob/master/lib/Image/ExifTool/RIFF.pm. I hope there will be some guides on how to use it.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 26, 2020, 08:25:44 AM
Here is the config file:

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::RIFF::Main' => {
    JUNK => { Binary => 1 },
  },
);


and here is the command:

exiftool -junk -b FILE > junk.dat

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: johnichan on April 27, 2020, 01:39:51 PM
Hi Phil,

Here goes my solution. I am not a professional in perl coding. So making things some how working is my only aim.

https://drive.google.com/open?id=192NaREqmfK6smein9tqjH2Qlx2NUogkO

Thanks again for helping out without which I would have dropped this part.
Title: Re: Extracting GPS Information from .MP4?
Post by: diplonics on June 05, 2020, 10:46:21 AM
Hi Phil,
     I've just lately started using a new dashcam, Roadhawk, and want to get the GPS data from it.
I've used Exiftool many times before on other cameras like a GoPro to get the GPS data but since changing to the Roadhawk the GPS data, I'm pretty sure, exports but is garbled in a text field.
I know the GPS is in the standard NMEA format so wondering if there is an option I missing to properly decode these strings?

Using the basic method: exiftool -g -ee Roadhawk_Sample.mp4 > out.csv
I get output like this:
*************************************************************************
Sample Time                     : 0 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D=-;;6+;;;D;NL;4;;;=D;P?;O;;;=D=PJ?HO71G>F;-?==BF:FNJJ;DPBN?F3F;;PL?D;-B;F0F;=-DPF=;BDRLF;N;?=JF;;?D=F:*5D~
Sample Time                     : 0.20 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D=-;;6;;;;D;R?;4;;;;DBNL;O;;;;DBLRRHO71G>F;-?==BF:FNJJ;DPBL-F3F;;PL?D;-RLF0F;=-DNF=;BDRJF;N;?=JF;;?D=F:*58~
Sample Time                     : 0.40 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D?=P;6;;;;D=?P;4;;;=D;;-;O;;;=D;R-PHO71G>F;-?==BF:FNJJ;DPBLNF3F;;PL?D;-N-F0F;=-DLF=;BD-NF;N;?=JF;;?D=F:*53~
Sample Time                     : 0.60 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D=;-;6;;;;D;B;;4;;;;DBJP;O;;;;D-BNBHO71G>F;-?=?;F:FNJJ;DPBL=F3F;;PL?D;-L=F0F;=-DLF==;D;PF;N;?=JF;;?D=F:*56~
Sample Time                     : 0.80 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D=LL;6;;;;D;NL;4;;;;DBR?;O;;;;DBP-LHO71G>F;-?=?;F:FNJJ;DPBJRF3F;;PL?D;-?PF0F;=-DJF==;D??F;N;?=JF;;?D=F:*57~
Sample Time                     : 1.00 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D=LL;6;;;;D;NL;4;;;;DBR?;O;;;;DBP-LHO71G>F;-?=?;F:FNJJ;DPBJLF3F;;PL?D;-=;F0F;=-D?F==;DR=F;N;?=JF;;?D=F:*56~
Sample Time                     : 1.20 s
Sample Duration                 : 0.20 s
Text                            : .;;;;D=B-;6+;;;D;JP;4;;;=D;;-;O;;;=D;NPPHO71G>F;-?=?;F:FNJJ;DPBJ;F3F;;PL?D;RBLF0F;=-D=F==;D-RF;N;?=JF;;?D=F:*5B~
Sample Time                     : 1.40 s

............
*************************************************************************

Is there a format mask I can provide to decode the Text field, which I'm pretty sure holds an NMEA message with the GPS.
Or is the decode more fundamental and needs deeper decoding within ExifTool?

Thanks
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on June 05, 2020, 11:13:58 AM
I edited you post to add the Code formatting to make it easier to read.

Can you make a small sample file available with movement, like going to the end of the block?  Phil might need to actually look at the file to see if he can support it.
Title: Re: Extracting GPS Information from .MP4?
Post by: diplonics on June 05, 2020, 01:52:59 PM
Thanks StarGeek for the format fix.
This sample file link should work:

https://ufile.io/24orw4k2
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 05, 2020, 04:54:13 PM
I've had a quick look at this.  I haven't seen anything like this before, and can't find any NMEA in this text.  The checksum at the end is the only thing that looks vaguely like NMEA.  I've tried the standard decryption technique, using various keys, but no luck.

Do you know the coordinates at the start of the video?  I'll analyze this when I get a chance, and knowing this may help.

- Phil

Edit: Ah, I found the answer for how to decrypt this on stackexchange (https://reverseengineering.stackexchange.com/questions/11582/how-to-reverse-engineer-dash-cam-metadata):

#include <stdio.h>

const char *decode_table = "#I8XQWRVNZOYPUTA0B1C2SJ9K.L,M$D3E4F5G6H7";

void decode_in_place(char *s) {
    while (*s) {
        *s = decode_table[*s-43];
        s++;
    }
}

int main(void) {
    char data[] = ".+;;;D=;-;6;;;;D;JP;4;;;=D;P?;O;;;=D=L;-HO71G>F=;;;JJF:FNJNBDL=R?F3F;;=;PDLR;;F0F;;=DRFJJ?DRJF??;J=LF;;;D;F:*59~";
    decode_in_place(data);
    printf("%s", data);
    return 0;
}
// Output: X#000.1080Y0000.0360Z0001.0620G0001.1408$GPRMC,100033,A,5359.4172,N,00106.4700,W,001.7,332.73,220314,000.0,A
//X0000.0000Y0000.0000Z0000.0000G0000.0000$GPRMC,UTS_Position,Status,Latitude,N/S,Longitude,E/W,Speed,Course_Over,Ground,Date,Magnetic_variation,Checksum~


I should be able to add support for this in the next release.
Title: Re: Extracting GPS Information from .MP4?
Post by: diplonics on June 08, 2020, 05:00:40 AM
Hi Phil,
       Brilliant in loads of ways, spent ages on google looking for Roadhawk specs etc... to solve this, finding nothing.
Think I need a lesson of effective searching!!! either way thanks a mill with this and even better, till next release, I can use this mask to decode as is currently output by ExifTool.

Also looks like the end of the string doesn't need decoding, the *59~ has no substitution for * or ~ and GPRMC strings end with this *59 type checksum anyway..
As all the 'text' field strings seem the same length I'm assuming then I can just end the substitution at the *..
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 09, 2020, 08:27:33 AM
I'm pretty sure the first character in the decode_table should be "-" instead of "#".  This makes sense for the signs in the accelerometer data.  I'll decode it this way.

Also, I am not going to decode the magnetic variation.  This should be two fields in NMEA RMC, but the second field ("E" or "W", indicating the direction of the variation) is missing.

- Phil

(That will make 42 different types of streaming GPS that ExifTool extracts from video files.)
Title: Re: Extracting GPS Information from .MP4?
Post by: diplonics on June 10, 2020, 05:58:24 AM
Yea that seems sensible changing # for a -.
The magnetic variation field is probably a bug on their side as its always a : (decodes to A) in all the examples that I have that I've run through ExifTool.

Also, re your 42 different types, if there a definitive list?
Through my University work I've access to a number of different cameras, old and new, with loads of data to test, some legacy.
Testing ExifTool on some of it reveals the following:

Roadhawk (File Type .mp4) - ExifTool works great, just need to handle the mask operation separate until next ExifTool release

Parrott Anafi (File Type .mp4) - ExifTool works fine, seems to dump all GPS Date/Time data to the end of the output in 1 block, rest seems sequential

GoPro Hero 8 (File Type .mp4) - ExifTool works fine, very high GPS hrz in these files but seems reasonable to parse

Nextbase 312GW, 412GW and 512G (File Type .mov) - ExifTool works perfect..
   
360Fly (File Type .mp4) - Exiftool doesn't find GPS but I have PHP code to rip it.   

Have an old .ts MPEG-2 format - ExifTool doesn't find GPS it but I have c code to rip it.
Have an old .mts AVCHD format - ExifTool seems to find lots of detailed frame level data but no GPS, maybe no GPS in it..

Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 10, 2020, 09:10:25 AM
Quote from: diplonics on June 10, 2020, 05:58:24 AM
Also, re your 42 different types, if there a definitive list?

No.  I don't even know the make/model of some of my samples.

Quote360Fly (File Type .mp4) - Exiftool doesn't find GPS but I have PHP code to rip it.

Have an old .ts MPEG-2 format - ExifTool doesn't find GPS it but I have c code to rip it.

Could you send me samples of these?  (philharvey66 at gmail.com)

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 10, 2020, 09:31:06 PM
I got the samples, thanks!

I should be able to add the ability to extract GPS from the 360fly video, hopefully for the next release.  Your code is very helpful.  Just a few questions: 1. Do you know what the mode values for each structure type signify?  2. Why 3 sets of yaw/pitch/roll (ie. what is "Fusion"?  I guess the other 2 are derived separately from the accelerometers and gyros).

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: diplonics on June 11, 2020, 12:46:25 PM
Seen as the 360fly can be uploaded to Google Streetview I reckon their specs relate to these:
https://developers.google.com/streetview/publish/camm-spec#data-format

This seems to give a reasonably detailed explanation of all the sensor fields, some real some derived it seems.
The relationship between the ID3 outputs and Google specs is probably:
fusion_data => position
accel_data => acceleration
gyro_data => gyro
magno_data => magnetic-field
gps_data => gps long form
rotation => angle-axis
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on June 11, 2020, 03:32:07 PM
Great, thanks.  I'll look into this.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: osakahk2009 on June 30, 2020, 11:35:50 PM
Hi Phil,
I have a mp4 with GPS info. shot by Sony A7R IV and I use your exiftoolwrapper to extract them but it doesn't show up.
Please help to check it out.
I can send you a small sample and please let me know how.

Thanks.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on July 01, 2020, 07:46:18 PM
Sure.  Send me a sample.  If it is a download link, make sure it is active for at least a week because I'm on vacation until next week.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: osakahk2009 on July 06, 2020, 09:41:57 AM
Hi Phil,
I have a sample in the following link.

https://drive.google.com/drive/folders/1nXkcDg3TdlDycmjo-X4J20xbx0UCR7EZ?usp=sharing

The coordinator of the mp4 read from Sony PlayMemories is 22 deg 17' 30" N, 114 deg 12' 42.8" E.

Thanks


Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on July 16, 2020, 10:38:42 AM
Quote from: osakahk2009 on June 30, 2020, 11:35:50 PM
Hi Phil,
I have a mp4 with GPS info. shot by Sony A7R IV and I use your exiftoolwrapper to extract them but it doesn't show up.
Please help to check it out.
I can send you a small sample and please let me know how.

Thanks.

ExifTool 12.02 (when released) will decode the GPS from Sony A7R IV videos.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: osakahk2009 on July 16, 2020, 10:49:02 AM
Hi Phil,
Good news.

Thanks a lot.
Title: Re: Extracting GPS Information from .MP4?
Post by: osakahk2009 on August 01, 2020, 06:13:07 AM
Hi Phil,
I have downloaded and tried out the latest version.
It works very well and it also works with the MP4 4K video that is shot with the Canon EOS R5.

Title: Re: Extracting GPS Information from .MP4?
Post by: airdrummer on January 05, 2021, 09:53:50 PM
hi, phil, thanx again for a fantastic tool! it works great extracting gps from viofo a119 mp4s...the only problem is GPS Date/Times are not collated with the gps lat/lon/speed/bearing(which is called track?) does the -p gpx.fmt do the right thing?
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on January 05, 2021, 10:01:57 PM
Currently, no.  I suppose I could support one method for writing, but since ExifTool already supports reading 48 different formats of timed GPS the chances would be small that I would choose the one that you want.  And there is no way I would add the ability to write all of these formats.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: airdrummer on January 05, 2021, 10:13:04 PM
ok, thanx, i'll look into what ffmpeg can do with gpx.
Title: Re: Extracting GPS Information from .MP4?
Post by: airdrummer on January 06, 2021, 12:50:31 PM
turns out https://dashcamviewer.com can apply ./trackname.gpx to ./trackname.mp4, but only if using
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Dashcam Viewer">
  <metadata>
    <name>Produced by Dashcam Viewer version 3.6.3</name>
  </metadata>
  <trk>
    <name>Track Start Time: 2021-01-05T15:29:30Z</name>
    <trkseg>
...

whereas ur gpx.fmt specifies version 1.0:
#[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>
...

i've replaced the header with the dashcamviewer version, & it seems to work...is there any reason for v1.0?
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on January 06, 2021, 02:57:56 PM
Quote from: airdrummer on January 06, 2021, 12:50:31 PM
is there any reason for v1.0?

That is the specification I was going by when I wrote the fmt file.  But the fmt files are just examples -- feel free to modify them for your particular needs.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: diplonics on February 04, 2021, 08:12:51 AM
Just a quick query re how some of the GPS related Tags data is defined by ExifTool across the GPS file formats that are supported.
In the .Exiftool_config file, which I'm using to support large file formats, I see the following:

2.  GPS:GPSPitch
3.  GPS:GPSRoll
6.  XMP-exif:GPSPitch
7.  XMP-exif:GPSRoll

Basically, is there a standard approach you've taken to define what is the Roll and/or Pitch data?
For example, in this thread post (https://exiftool.org/forum/index.php?topic=5095.msg60561#msg60561) relating to the 360 file format you had a look at, are these Tags available when I process this file type and if so what parameters did you determine them from as the file contains quite a few types of orientation data it seems..
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on February 04, 2021, 05:23:06 PM
These GPSPitch and GPSRoll tags are not standard.  I basically pulled them out of thin air for people to use if they find the need.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: aluengo on April 16, 2021, 08:23:48 AM
Greetings and congratz for this amazing tool.
In the following file: https://drive.google.com/file/d/1V_y5NS-xrXpt2lNsmWcLeoJMpmRrFHJK/view?usp=sharing with latest exifTool version nowadays (12.2.4) I´m unable to extract any location info from it.
The video was recorded with the camera APP of an iPhone and shared via Telegram (does it matter?)

Any hints?

Thanks in advance.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 16, 2021, 08:59:35 AM
What makes you think there is GPS in this video?

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: aluengo on April 16, 2021, 09:05:25 AM
Because it was recorded with GPS enabled...but Telegram reencoded it automatically when sharing...so I suppose some attributes were missing in the process.
Thanks for the quick answer, anyway!
Title: Re: Extracting GPS Information from .MP4?
Post by: aluengo on April 16, 2021, 09:24:19 AM
Another question, I have two ".mov" extracted directly from an iPhone6 backup. Customer says that in recording moment the GPS was activated..but I´m unable to recover location data from them (neither it is in Photos.sqlite). Besides maybe it is not truth, is there any special consideration for this ".mov" files?. I attach, as example for one of these files, output for command "exiftool.exe -ee IMG_7924.MOV"

Thanks in advance,
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 16, 2021, 10:15:19 AM
You could try -ee3, but it is unlikely to help if the video is indeed directly from an iPhone.  Most often in cases like this the video doesn't contain gps, but I can't say for sure without seeing the video.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on April 16, 2021, 10:24:30 AM
Quote from: aluengo on April 16, 2021, 09:05:25 AM
but Telegram reencoded it automatically when sharing

Re-encoding will remove all metadata and this is common with social media apps.  But a quick google search seemed to indicate that it would be possible to send it as a file instead of as image/video and that would preserve any metadata.
Title: Re: Extracting GPS Information from .MP4?
Post by: aluengo on April 16, 2021, 04:40:22 PM
Quote from: Phil Harvey on April 16, 2021, 10:15:19 AM
You could try -ee3, but it is unlikely to help if the video is indeed directly from an iPhone.  Most often in cases like this the video doesn't contain gps, but I can't say for sure without seeing the video.

- Phil

Greetings Phil, this is the original video recorded from iPhone 12 with GPS enabled: https://cloud.oscarmlage.com/index.php/s/3A8Tje3FoQF8rMD

Thanks for the help.
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on April 16, 2021, 06:39:02 PM
This video is very different from all the iPhone videos I have from other models (which do have GPS, btw).  I can't explain the difference, but I don't see any GPS in the video you posted.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: DavidK86 on June 10, 2021, 08:09:18 PM
Hi Phil

Thanks for the great forum full of information. Has helped a great deal.

I have hit an issue though I hope you may be able to help with?
I have some dashcam footage which I need to extract gps information from csv/txt file ideally, however when I have run it several different ways through exiftool I just get either saying there is no gps data, or just come back with some lat/longs which are obviously incorrect.

The video definitely has gps data as you can follow on a map when viewed with GPSPlayer. Unfortunately I do not know the make/model of camera used, nor do i have access to it to make and send a smaller file. I have emailed a link to philharvey66@gmail.com

Thanks so much for any advice you may be able to offer.

David
Title: Re: Extracting GPS Information from .MP4?
Post by: ldb707 on November 26, 2021, 06:51:11 PM
Hello Phil,

I am trying to extract GPS data from my Vantrue S1 dashcam which records mp4 files. Using the Vantrue Player software, it displays all GPS data: Coordinates, Speed, Accelerometer, and even plots the trace onto a map.

I have read through the forums, and tried using the -ee command and other suggestions, but it doesn't display any of the GPS information (tried both the Windows and Linux versions).
Looking at the raw form with -ee -V3 , I can see some kind of GPS data:

+ [GPS directory, 32768 bytes]
  | 2768a9e0: 00 00 80 00 66 72 65 65 47 50 53 20 78 00 00 00 [....freeGPS x...]
  | 2768a9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................]
  | 2768aa00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [................]
  | 2768aa10: 68 6f 72 73 6f 6e 74 65 63 68 00 00 00 00 00 00 [horsontech......]
  | 2768aa20: 41 4e 45 00 15 00 00 00 07 00 00 00 02 00 00 00 [ANE.............]
  |     [snip 32688 bytes]


Can I send you the video file to take a look at it when you have time?

Thanks a lot.

- Leonard
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on December 04, 2021, 10:44:49 AM
Hi Leonard,

Sorry for the delay in responding.  I was away for the last week, and unfortunately the site was disabled by dreamhost shortly after I left. :(

Sure.  Send me the file and I'll take a look (philharvey66 at gmail.com)

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Phil Harvey on December 06, 2021, 10:04:32 AM
Hi Leonard,

I got the file you sent.  ExifTool 12.37 (to be released this week) will have the ability to decode timed GPS from this file.

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: ldb707 on December 07, 2021, 04:47:40 AM
Thanks a lot for your work and dedication, Phil!

Keep it up!

Leonard
Title: Re: Extracting GPS Information from .MP4?
Post by: dh on March 10, 2022, 01:05:57 AM
Hi

I have subtitles (srt) with GPS + proprietary information embedded in Mp4 files. I can extract this with the -text tag, but some files contain other subtitle streams. They all fall into the Quicktime group. Is there a way to specify which stream to extract, using TrackID or HandlerDescription for example, to reduce the workload?

C:\exiftool -G -ee3 -text file.mp4"

Also, is it possible to add/replace this stream with a subrip format text file?

Thanks
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on March 10, 2022, 01:11:49 AM
Quote from: dh on March 10, 2022, 01:05:57 AM
Also, is it possible to add/replace this stream with a subrip format text file?

Not with exiftool.  You'll have to use ffmpeg for that.
Title: Re: Extracting GPS Information from .MP4?
Post by: dh on March 10, 2022, 02:25:41 AM
Thanks. I thought that would be the case, and that's how I got them in there. I'm just trying to reduce the number of tools I need for my workflow, and ExifTool seems to be full of surprises if you can find the right options.
Title: Re: Extracting GPS Information from .MP4?
Post by: krandino on April 22, 2022, 09:55:15 PM
Let me say that tool is very well made and works great. If I was smart, I wouldn't look a gift horse in a mouth and just use your program. I have been searching for data on the MP4 file format and metadata where the GPS coordinates for the GoPro format on a Hero 9 is stored. It was my intention to decode that information which from the specs that I saw looked fairly benign. I am looking at the metadata and not the image compression that I remember from work research years ago included the DCT transform if I remember correctly. The docs I saw looked as though there was an ASCII codeword "GPS5" and what followed contained the Lat, Long, speed, etc. stored in IEEE 754 format supposedly. I have examined the files and I have used your and other programs that are able to find, and convert the data correctly. Clearly I am doing something wrong with my assumptions/understandings. I understand you are not doing a tutorial service for retired software engineers but if you could point me to a document(s) or source (in C or C+) that would help me do this, I would be very appreciative. Just for the record, my attempt at this is NOT a commercial thing. It is strictly for use on a trip I plan on making and using the GoPro to document the trip and want to create a .gpx file for record of every mp4.

Thanks
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on April 22, 2022, 11:56:47 PM
Quote from: krandino on April 22, 2022, 09:55:15 PMif you could point me to a document(s) or source (in C or C+) that would help me do this,

From what I understand, the various camera companies don't make such specs publicly available.  Exiftool currently knows 59 different ways that GPS tracks can be embedded and it's thanks to Phil's hard work.

Your best source would be to look over the exiftool source code (https://github.com/exiftool/exiftool), though it's in Perl and not C.
Title: Re: Extracting GPS Information from .MP4?
Post by: krandino on April 23, 2022, 12:59:23 PM
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.

Title: Re: Extracting GPS Information from .MP4?
Post by: boweiche on April 27, 2022, 01:30:31 PM
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!
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on April 27, 2022, 01:45:58 PM
You have to add the -ee (-extractEmbedded) option (https://exiftool.org/exiftool_pod.html#ee--extractEmbedded).

If you want to create a GPX or KML geotrak, see Inverse Geotagging (https://exiftool.org/geotag.html#Inverse).

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 (https://github.com/exiftool/exiftool/tree/master/fmt_files).  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>
Title: Re: Extracting GPS Information from .MP4?
Post by: boweiche on April 29, 2022, 09:27:47 PM
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.
Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on April 29, 2022, 11:25:36 PM
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.
Title: Re: Extracting GPS Information from .MP4?
Post by: boweiche on April 30, 2022, 01:20:01 PM
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!

Title: Re: Extracting GPS Information from .MP4?
Post by: StarGeek on April 30, 2022, 02:47:17 PM
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.