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 (phil at owl.phy.queensu.ca).

- 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 (http://u88.n24.queensu.ca/exiftool/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
Is 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 (phil at owl.phy.queensu.ca).

- Phil
Title: Re: Extracting GPS Information from .MP4?
Post by: Insta on February 28, 2018, 09:00:40 AM
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 (phil at owl.phy.queensu.ca).

- 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 phil at owl.phy.queensu.ca)

- 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:

Code: [Select]
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 
Code: [Select]
exiftool -n -p photo.fmt clubhouse\*.jpg > clubhouse.geojson
but for videos I want to create a linestring using the information from the line
Code: [Select]
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
Code: [Select]
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:

Code: [Select]
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

Code: [Select]
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!

Code: [Select]
---- 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://sno.phy.queensu.ca/~phil/exiftool/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://sno.phy.queensu.ca/~phil/exiftool/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!