Extracting GPS Information from .MP4?

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

Previous topic - Next topic

Phil Harvey

@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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

@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.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jonnyhonda

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/


Phil Harvey

I got your sample AVI video.  I'll see what I can decode from this and post back later.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

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. :)
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jonnyhonda

Wow, that's amazing, yes it was shot yesterday about 4pm uk time

Phil Harvey

#37
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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

jonnyhonda

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

Phil Harvey

Thanks!  That'll buy me a couple of Guinness from the supermarket. :)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

rickvdk

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sylloge

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



Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

sylloge

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