Script to extract GPS Data from Novatek MP4

Maybe the most easy way is that somebody to hack the RV, I donyt know if this is possible but there is some version which have a lot of MB compared to final release.
I think RV was sponsored by a dashcam manufacturer, Datakam, so for SergeiF was more easy to do. I translated the romanian language of RV and I remember was a smart guy, easy understanding the things. Maybe somebody which was already working for software players can do the job.

Regarding dashcams and VLC, for example will be needed more and more a player for dual dashcams to look at video as PIP, a software which can easy create a video as PIP from both videos of a dashcam.

enjoy,
Mtz
 
Last edited:
the script provided by Serguei has a bug if we use python3,

Traceback (most recent call last):
File "nvtk_mp42gpx.py", line 174, in <module>
f.write(gpx)
TypeError: a bytes-like object is required, not 'str'

to solve the error we need to change line 172 to :

with open (out_file, "w") as f:

instead of :
with open (out_file, "wb") as f:

just delete the "b" letter, no need to open a file in binary mode if it's just to put strings in this file

but the script will produce no gpx data if we use python3, with python2 no problems
 
Last edited:
the script provided by Serguei has a bug if we use python3,

Traceback (most recent call last):
File "nvtk_mp42gpx.py", line 174, in <module>
f.write(gpx)
TypeError: a bytes-like object is required, not 'str'

to solve the error we need to change line 172 to :

with open (out_file, "w") as f:

instead of :
with open (out_file, "wb") as f:

just delete the "b" letter, no need to open a file in binary mode if it's just to put strings in this file

but the script will produce no gpx data if we use python3, with python2 no problems


Awesome! someone actually uses it!.
Thank you, I fixed the file in the original link.
 
  • Like
Reactions: Mtz
Many people could use it if not so many requirements were needed.
Also I tried to use it but working with CMD and scripts is difficult for a lot of people. Maybe was not working for me because of that bug, I don't know. I already uninstalled Python because was installed just for this script.

Of course the ideal usage of a program which can read GPS data could be if it can provide the needed file on-the-fly to Registrator Viewer, but I expect this to be impossible.

enjoy,
Mtz
 
I can create a GUI version of this python script,

all I need is time and also understand how to extract binary datas from the mp4 container
 
Of course the ideal usage of a program which can read GPS data could be if it can provide the needed file on-the-fly to Registrator Viewer, but I expect this to be impossible.

enjoy,
Mtz

even if not on the fly if the card could be read and a process run to output the files needed before using RV would be useful, sort of copy the files to a folder, run the process and have it dump the GPS data as needed in the correct folder and then use RV would do the job
 
  • Like
Reactions: Mtz
Yes, maybe something like:
- transfer desired dashcam file from card over some file inside a HDD folder where is also RV
- when transferring that file to HDD the GPX file is extracted

I donyt know which chipset is using the Garmin Dashcams but I expect their player to play videos and display tracks on the map.

enjoy,
Mtz
 
I fixed the script so it works in python2 and python3 (added bunch of decodes in there as struct.unpack_from returns type string for 's' format in python2 and type byte string in python3. Decoding string to string is harmless in python2 thus I could make it python2 and python3 compatible.
 
Yes, maybe something like:
- transfer desired dashcam file from card over some file inside a HDD folder where is also RV
- when transferring that file to HDD the GPX file is extracted

I donyt know which chipset is using the Garmin Dashcams but I expect their player to play videos and display tracks on the map.

enjoy,
Mtz
I see u mentioned Garmin Would u rate Garmin 35 as an ok DVR other than the fact is has no audio recording in North America and it comes with a 6 ft power cord instead of 12 ft. And I finally found out the viewing angle 180 But cannot find out any thing about whats inside. Staples has a big sale in Canada $229. less 10% coupon
 
  • Like
Reactions: Mtz
I fixed the script so it works in python2 and python3 (added bunch of decodes in there as struct.unpack_from returns type string for 's' format in python2 and type byte string in python3. Decoding string to string is harmless in python2 thus I could make it python2 and python3 compatible.

thank you SergeiF, it's a very good job
 
I can create a GUI version of this python script,

all I need is time and also understand how to extract binary datas from the mp4 container

It is fairly straight forward: the gist of it that each atom contains size (4byte long int) and type (4byte long string) at the beginning of atom. The file starts with an atom. I iterate through atoms intil I hit 'moov' type of atom.
The 'moov' contains a special non standard 'gps ' sub-atom. To get to sub-atom 'gps ' I simply iterate through sub-atoms inside of 'moov' (with offset of 8bytes for header).
The 'gps ' contains simple look up table made up of 8byte rows, that point to the 'free' atoms that contains the actual GPS data.
The first row is version/metadata/notsure, I skip that.
The following rows consist of 4byte address (absolute) and 4byte size (0x1000), these point to the GPS data in the file.

The structure of the GPS data atom (the 'free' atoms mentioned above) is following:
hour,minute,second,year,month,day,active,latitude_b,longitude_b,unknown2,latitude,longitude,speed = struct.unpack_from('<IIIIIIssssfff',data, 48)
For those unfamiliar with python struct:
I = int
s = is string (size 1, in this case)
f = float

I hope that helps ;).

Sergei.
 
Last edited:
Will be interesting to understand why Novatek modified the GPS code by comparing an A118 GPS recording with A119 recording.

enjoy,
Mtz
 
I see u mentioned Garmin Would u rate Garmin 35 as an ok
No.
I am interested only by their Windows PC player if it can be used for other dashcams.

enjoy,
Mtz
 
I like it, works great. How about adding a wildcard support so we could do something like this:
Code:
./nvtk_mp42gpx.py -i 2016_1026* -o out.gpx
 
  • Like
Reactions: Mtz
I like it, works great. How about adding a wildcard support so we could do something like this:
Code:
./nvtk_mp42gpx.py -i 2016_1026* -o out.gpx

It should not be too difficult. Just need to add an iterator and re-factor the code a bit...
I am looking into it now...
 
Using this script I was able to compare GPS accuracy of SGGC and A119. On the highway, both are very accurate, in a dense urban area, SGGC was about 15ft off while A119 remained very accurate.
 
  • Like
Reactions: Mtz
Will be interesting to understand why Novatek modified the GPS code by comparing an A118 GPS recording with A119 recording.

enjoy,
Mtz
For before GPS code, it is not good for some slow speed cards.
 
My preference is the way Mini series does it. A separate file for GPS and sensor data. This way, I can chose whether to include the data or not...
 
My preference is the way Mini series does it. A separate file for GPS and sensor data. This way, I can chose whether to include the data or not...

I think you'll find on some of those models they are also embedded in the file as well as the standalone file
 
  • Like
Reactions: Mtz
Thread starter Similar threads Forum Replies Date
RobTrehy A119 138
Back
Top