Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Novatek MP4 detection not working out-of-the-box; New FPS logic is buggy #6

Open
GPSMapper opened this issue May 7, 2021 · 0 comments

Comments

@GPSMapper
Copy link
Contributor

GPSMapper commented May 7, 2021

  1. Novatek MP4 detection not working

    if box.type.decode("utf-8") == "gps": #has Novatek-specific stuff

    this will not work with MP4 novatek (gps box is not detected, as it is a subatom under moov)
    Quick workaround: change "gps" to "moov"
    if box.type.decode("utf-8") == "moov": #has Novatek-specific stuff

  2. new FPS calculation approach is buggy.

    fps = length/packetno

    In MP4 Novatek files you could expect 1-2 additional GPS location packets which are carried over between the files.
    So it's typical to have 61 or 181 gps packets ('freeGPS') for 60 or 180 sec video
    As a result, fps is calculated incorrectly and image sampling gets broken.
    For 180 sec video with 1 sec sampling interval you will get 187 frames

How to reproduce:
Sample video: https://drive.google.com/file/d/14AXSVYlToIxUmoGPPmq-lGHsb2S8PWTH/view?usp=sharing
Script parameters: ts_processor.py --input 20210426103432_001156.MP4 --sampling_interval 1

Output:

20210426103432_001156.MP4
Novatek MP4 T
FPS : 30.0; LEN: 5400
GPS data analysis ended, no of points  181
Frames per point:  29.834254143646408
Video extraction started
20210426103432_001156.MP4  processed,  187  images extracted

So, at first FPS is detected properly by cv2

fps = video.get(cv2.CAP_PROP_FPS)

but later it get's overwritten by
fps = length/packetno

and while packetno=181 (contains one extra gps packet), resulting FPS is not correct and this breaks the sampling
Frames per point: 29.834254143646408
Extra images are produced (not @ 1fps interval defined) and coordinates are assigned incorrectly.
Similar issue will occur if some of there will be a temp gpsfix loss. (i.e. in the tunnel) Packet will not be captured and counted and fps calculation will be completely erroneous

IMO, original approach works excellent (fps extracted by cv2) and there is no need to redefine it.
Quick workaround: delete or comment lines 559-561

    #if packetno > 0:
        #print ("Frames per point: ", length/packetno)
        #fps = length/packetno
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant