Extracting GPS data from MP4 video file

Started by fakej, December 31, 2017, 11:58:10 AM

Previous topic - Next topic

off

How about Ambarella Chinese cams that out MP4 with embedded data? ExifTool produce empty .gpx file

can share or send sample file (what e-mail should I enter if send via WeTransfer?)

StarGeek

The author is currently away until sometime next week.  If you hit the "Notify" button in the upper right corner of this thread you can get an email when he would be able to look at the file for you.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Send me a sample file and I'll take a look (my email is philharvey66 at gmail.com)

- 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 got the samples, thanks.

I can decode the GPS from the Ambarella A12 MP4 video.  ExifTool 11.77 will support this format.

I can't see any GPS in the A7 MOV video.

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

off

Quote from: Phil Harvey on November 25, 2019, 01:31:59 PM
I can't see any GPS in the A7 MOV video.

Thank you. I'll try to find power cable :)

off

Uploaded another pair of MOV-files from Ambarella A5 & A7, not sure about A5-file (without speed), pretty sure about A7-file (with GPS-coordinates and speed)

GPSmapper

Hi Phil,

Hi Phil,
Hope this message finds you well!

I have came across this topic and wondering if you could add support for one more format from dashcam (Blueskysea B4K, Novatek NT96670 )
https://dashcamtalk.com/blueskysea-b4k/

It uses H.265 HEV codec  and TS container.
Latest Exiftool does not seem to be able to recognize the gps exif data.

Sample file was sent by e-mail.

Thank you very much in advance!

Phil Harvey

I've looked at the .ts file you sent.  Unfortunately there is no trailer with GPS like some other .ts files I have.  This file contains only 3 programs: 1. clock reference, 2. HEVC video, and 3. AAC audio.  If timed GPS exists in this file, then it is in the HEVC video stream.  ExifTool doesn't yet have the ability to decode H.265, and it would be a LOT of work to do this (if I could find the specification at all).

I'll add this to my to-do list, but it won't be a feature that will be added in the near future.

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

GPSmapper

Thanks Phil, I will try to get more details from the manufacturer, will let you know once I'll get something.

GPSmapper

Quote from: Phil Harvey on March 08, 2021, 03:40:32 PM
ExifTool doesn't yet have the ability to decode H.265, and it would be a LOT of work to do this (if I could find the specification at all).

Hi Phil,
hopefully this will not be required (decode), I have sent you the specs I've got from manufacturer by e-mail.
Storage logic for MP4 and TS is different and explained in specs.
MP4 - you already support this since 11.68 (Viofo A119 V3) - using same chipset

Thanks

Phil Harvey

I got the documentation, thanks.  This was very useful.

The documentation says the GPS is in program ID 0x300, but there is no such program in the program map table of the file.

However, this program does exist in the file you sent.  I think this is an oversight on the part of the device manufacturer, and it will unfortunately mean that ExifTool would need to scan the entire video to see if this information exists.  This would mean a huge performance penalty for all TS videos.  I'm not sure how to deal with this.  Maybe you could suggest that they add this program to the TS Program Map Table.

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

GPSmapper

Quote from: Phil Harvey on March 10, 2021, 06:56:53 AM
Maybe you could suggest that they add this program to the TS Program Map Table.

I could give it a try, but considering the GPS data extraction possibility is not in their focus, I doubt they will be motivated to implement any changes in that regards.

Maybe you could try the other sample? Is it the same (missing program map)?

Both sample recordings  are coming from B4K dashcam, I do not have any Viofo A119 V3 TS samples to share, I will have this cam probably next week so we could check if it is he same issue.

GPSmapper

Also looking at p.4:
QuoteIf the GPS recording function is enabled, the generated TS file will use a specific pid to insert GPS data every second. Unlike the MP4 format, which has an index table, the TS format must search each TS packet from the beginning to filter out the GPS data.
I read this as 'there's NO index available in TS'

This 'specific' pid is 0x47 0x43 0x00

anyway, will try to clarify what was meant in 4.1.2

GPSmapper

#58
Hi Phil, while waiting for feedback from the B4K vendor, I have managed to 'decode' the gps blocks pattern, gps data is split between 2 packets.
It is not the same as described in the datasheet

it seems that this is quite common among Chinese manufacturers to 'alter' the default specs making resulting formats incompatible with competitor products (dashcam viewers).
B4K seems to be no exception.

Coordinates : packet 0x47 0x03 0x00: bytes 157 - 176: (green block)
active: string (1 byte) # satelite lock "A"=active, everything else (eg " ") lost reception
latitude hemisphere: string (1 byte) # "N"=North or "S"=South
longitude hemisphere: string (1 byte) # "E"=East or "W"=West
unknown: string (1 byte) always "0"
latitude: little-endian float (4 bytes) # unusual format of DDDmm.mmmm D=degrees m=minutes
longitude: little-endian float (4 bytes) # unusual format of DDDmm.mmmm D=degrees m=minutes

Datetime data: packet 0x47 0x43 0x00, bytes 175-188 + packet 0x47 0x03 0x00 bytes 147-156 (orange block)
hour: unsigned little-endian int (4 bytes)
minute: unsigned little-endian int (4 bytes)
second: unsigned little-endian int (4 bytes)
year: unsigned little-endian int (4 bytes) - bytes 187,188 AND 147,148 of the next packet
month: unsigned little-endian int (4 bytes)
day: unsigned little-endian int (4 bytes)



Phil Harvey

Quote from: GPSmapper on March 10, 2021, 12:33:26 PM
I read this as 'there's NO index available in TS'

There is a Program Map Table as I mentioned (run exiftool -v3 on the file).

Thanks for the information about the decoding, but this isn't the problem (at least not now -- I haven't tried to decode this yet).  Without an indication that the private program exists, ExifTool can not know how much of the file it needs to parse.  I have to think about 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 ($).