Extracting GPS Information from .MP4?

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

Previous topic - Next topic

sylloge

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

Phil Harvey

Did you see the dji.config file 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
...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 ($).

Krampapas

#47
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

Phil Harvey

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

#49
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.
...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

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

Krampapas

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!

Phil Harvey

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

tomcheney

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

Phil Harvey

Hi Tom,

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

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

tomcheney

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

Phil Harvey

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

ptpmashish

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.

Phil Harvey

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

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

leonard_zh

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