Script to extract GPS Data from Novatek MP4

I just checked with yesterday footage and I get correct GPS data.
I spend 2 hours to understand your script but in fact it was a 2seconds fix.:confused: The header to ignore is not 48 anymore but 16.
struct.unpack_from('<IIIIIIssssfff',data, 16)

Awesome! Thank you very much!

Updated main file.

It looks like the features I need to add is a flag for pre v2.0 firmware (perhaps auto detect somehow?) and multiple files thing.
 
Wow, with your script and the for loop (without MP4 in gps filename) , i can use registrator viewer. It detects gpx files:)
 
I wander why they changed the binary structure in first place?
They need to open up the spec, there is no harm, only benefit (allows people developing supporting software).
 
I wander why they changed the binary structure in first place?
They need to open up the spec, there is no harm, only benefit (allows people developing supporting software).
Novatek updated the SDK and that changed the way it handles GPS data. It's not under the control of viofo.
 
@Curtis54, SergeiF updated the script. Any news?

enjoy,
Mtz

Just a bit of insight why there are delays (at least from my side).
When I do a lot of coding at work, I simply lose all interest and motivation in coding side-projects.
So if I write a lot of python scripts at work, then it is highly unlikely I will be doing it after work. It happens that my job involves a lot of coding, thus I could only code when I am involved in other aspects (eg.: hardware, databases, security etc.).

It took me many hours to come up with that script, and that is a relatively simple thing. If you are talking about a GUI viewer, then it makes it more complicated (by an order, or two of magnitude).
You could pour hundreds of hours into a registrator viewer type of thing.
 
I am having trouble running the python script. I have Windows 7 and installed Python 3.5.2 from https://www.python.org/downloads/release/python-352/. When I try to run the script from the Python command window, I just keep getting syntax errors.

>>> "C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py" -i 2016_1206_191052_032.mp4 -o 2016_1206_191052_032.gpx
File "<stdin>", line 1
"C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py" -i 2016_1206_191052_032.mp4 -o 2016_1206_191052_032.gpx
^
SyntaxError: invalid syntax

It seems the full path of the python script needs to be in double quotes for sure. The mp4 file is in the same directory as the .py script. I also tried specifying full paths for the mp4 and gpx files, but this did not help whether I enclosed the full path or just the filenames in double quotes.

Does anyone have an example of the command line to run this in Windows?
 
I am having trouble running the python script. I have Windows 7 and installed Python 3.5.2 from https://www.python.org/downloads/release/python-352/. When I try to run the script from the Python command window, I just keep getting syntax errors.

>>> "C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py" -i 2016_1206_191052_032.mp4 -o 2016_1206_191052_032.gpx
File "<stdin>", line 1
"C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py" -i 2016_1206_191052_032.mp4 -o 2016_1206_191052_032.gpx
^
SyntaxError: invalid syntax

It seems the full path of the python script needs to be in double quotes for sure. The mp4 file is in the same directory as the .py script. I also tried specifying full paths for the mp4 and gpx files, but this did not help whether I enclosed the full path or just the filenames in double quotes.

Does anyone have an example of the command line to run this in Windows?
Try this:
Code:
C:\Python35\python.exe C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py -i 2016_1206_191052_032.mp4 -o 2016_1206_191052_032.gpx

Replace C:\Python35\python.exe with your python path (where you installed python into).
I don't have windows to test with, but I see no reason why the above should not work.
 
I just realised that you can wrap my script with a batch script so it will be more windows friendly.

Code:
C:\Python35\python.exe C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py %*
pause
replace the paths to reflect your system.
call it something like nvtk_mp42gpx.bat or whatever you like and run it from CMD or Win+R with same arguments you would run the py file.
 
Apparently for windows users there is a thing called py2exe (http://www.py2exe.org/) but you need windows installation to make an exe out of python script. That could be an alternative...

Windows is horrible ;).
 
  • Like
Reactions: Mtz
Try this:
Code:
C:\Python35\python.exe C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py -i 2016_1206_191052_032.mp4 -o 2016_1206_191052_032.gpx

Replace C:\Python35\python.exe with your python path (where you installed python into).
I don't have windows to test with, but I see no reason why the above should not work.

Thanks, I got it to work like you suggest using the Windows command prompt. Somehow I could not get it to work in the Python command window, but since I don't have any Python experience, I must not understand how to run python scripts from there.

A couple things to note that may help others. First, when I installed Python in Windows, during the installation, I elected to add Python to the Windows path (or I could have done it manually later). So I don't need to enter the full path of python.exe when running it in the Window command prompt. Second, for the -i and -o values, if you don't specify full path for these, it will default to looking for the input file in the current directory of the Windows command prompt or default to outputting the gpx file in the current directory.


I just realised that you can wrap my script with a batch script so it will be more windows friendly.

Code:
C:\Python35\python.exe C:\Users\dan\Documents\dashcam\A119\nvtk_mp42gpx.py %*
pause
replace the paths to reflect your system.
call it something like nvtk_mp42gpx.bat or whatever you like and run it from CMD or Win+R with same arguments you would run the py file.

I was not clear about this batch script suggestion. What does the %* mean in it? Are the -i and -o arguments supposed to be in the batch script or are they supposed to be supplied by the user running the batch script?


For now since outputting to different gpx files is not supported, I would need to run the python command multiple times with different -i and -o file arguments. I saw the suggestion how to do this in Linux, but does anyone know if there's also a simple way to do this in Windows?
 
I'm on windows as well, but i've choosed to intall cygwin with python so i could use bash scripts.
 
Speaking of bash, i made a little script to generate gpx files of new mp4 adn cleaning orphan gpx :
Code:
#/bin/bash
echo "Generating missing gpx files"
for file in *.MP4
do
    if [ ! -f ${file%.MP4}.gpx ]
    then
        ./gps.py -i $file -o ${file%.MP4}.gpx
    fi
done
echo "Cleaning orphan gpx files"
for file in *.gpx
do
    if [ ! -f ${file%.gpx}.MP4 ]
    then
        rm -f $file
    fi
done
 
Hi,

I have a working Windows GUI version of this script.
I need to complete final testing, and make a couple of improvements.

It's based upon the original script by SergeiF, but has been completely re-written.

This initial version will support one MP4 input file output one GPX file.

I hope to make it available tomorrow, but will depend on outcome of bug testing.

Dev-Screenshot.jpg
 
I'd say his issues are just with the player, no support in Registrator Viewer and Dashcam Viewer seems to be a problem with this model for some users, not really any other option out there

@jokiin, as far as I'm aware all incompatibilities between Dashcam Viewer and the A119 GPS data formats have been resolved. Please let me know of any GPS data incompatibilities I'm not aware of and I will update DV. Thanks!
 
@jokiin, as far as I'm aware all incompatibilities between Dashcam Viewer and the A119 GPS data formats have been resolved. Please let me know of any GPS data incompatibilities I'm not aware of and I will update DV. Thanks!
I suspect that people that were having issues were on a different firmware version at the time, there were some changes in the SDK which broke things for a bit
 
Hey guys, I've just got a GS63H dash-cam which is using the same Novatek96660 chipset and tried to extract the gps data out of some .mp4 files that I captured yesterday ,unfortunately I have one out of 2 things happening while I run the script:
- a .gpx file is generated , but it's empty(it only contains the header)
- I get a parsing error(see above trace for details):

Code:
/usr/bin/python3 nvtk_mp42gpx.py -i sample_1.MP4 -o $GPS_TRACK.GPX
Queueing file 'sample_1.MP4' for processing...                                                    
Processing file 'sample_1.MP4'...                                                                
Found moov atom...
Found gps chunk descriptor atom...
Traceback (most recent call last):
File "nvtk_mp42gpx.py", line 184, in <module>main()
File "nvtk_mp42gpx.py", line 169, in main process_file(f)
File "nvtk_mp42gpx.py", line 157, in process_file                                                                        
gps_data.append(get_gps_atom(get_gps_atom_info(f.read(8)),f))                                                        
File "nvtk_mp42gpx.py", line 99, in get_gps_atom
active=active.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9b in position 0: invalid start byte

I have to mention I ran the script in Linux subsystem for windows after installing pyhon3 on it and that I am no programmer so I want to know if any of you experienced a similar thing and if you know how can I fix it ?

With regards,
k-tod.
 
Last edited:
Thread starter Similar threads Forum Replies Date
RobTrehy A119 138
Back
Top