progweb / gpx2video

Creating video with telemetry overlay from GPX data
GNU General Public License v3.0
174 stars 10 forks source link

[BUG] GPX extract and retrieve fails #16

Closed benfulton closed 1 year ago

benfulton commented 1 year ago

Describe the bug I tried to create a video using a source created with a GoPro 11. First I attempted to extract the gpx file and then use that gpx in building a video with overlays. The first command I ran was:

./gpx2video -v -m /mnt/d/GoPro/7thToDowntown.mp4 -o /mnt/d/GoPro/output.gpx -f 2 extract This seemed to be successful with this output:

gpx2video v0.0.0
creation_time = 2023-02-25T16:45:10.000000Z
Failed to find decoder for stream #2
Failed to find decoder for stream #3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/d/GoPro/7thToDowntown.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2023-02-25T16:45:10.000000Z
    location        : +39.1997-086.5327/
    location-eng    : +39.1997-086.5327/
    firmware        : H22.01.02.01.00
  Duration: 00:03:03.13, start: 0.000000, bitrate: 45064 kb/s
  Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 2704x1520 [SAR 1520:1521 DAR 16:9], 44789 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro H.265
      vendor_id       : [0][0][0][0]
      encoder         : GoPro H.265 encoder
      timecode        : 11:55:08:05
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro AAC
      vendor_id       : [0][0][0][0]
      timecode        : 11:55:08:05
  Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro TCD
      timecode        : 11:55:08:05
  Stream #0:3(eng): Data: bin_data (gpmd / 0x646D7067), 63 kb/s (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro MET
Extract GPMD data...
PACKET: 0 - PTS: 0 - TIMESTAMP: 0 ms - TIME: 2023-02-25 21:45:10
PACKET: 1 - PTS: 1001 - TIMESTAMP: 1001 ms - TIME: 2023-02-25 21:45:11
PACKET: 2 - PTS: 2002 - TIMESTAMP: 2002 ms - TIME: 2023-02-25 21:45:12
PACKET: 3 - PTS: 3003 - TIMESTAMP: 3003 ms - TIME: 2023-02-25 21:45:13
...
PACKET: 182 - PTS: 182182 - TIMESTAMP: 182182 ms - TIME: 2023-02-25 21:48:12
GPMD data extracted with success

I then attempted to create a video with the command:

./gpx2video -v -m /mnt/d/GoPro/7thToDowntown.mp4 -g /mnt/d/GoPro/output.gpx -l ../samples/layout-1920x1080.xml -o /mnt/d/GoPro/output.mp4 video A video was created, but it had no overlays at all - it appeared to be identical to the source video. I received the following output:

gpx2video v0.0.0
creation_time = 2023-02-25T16:45:10.000000Z
Failed to find decoder for stream #2
Failed to find decoder for stream #3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/mnt/d/GoPro/7thToDowntown.mp4':
  Metadata:
    major_brand     : mp41
    minor_version   : 538120216
    compatible_brands: mp41
    creation_time   : 2023-02-25T16:45:10.000000Z
    location        : +39.1997-086.5327/
    location-eng    : +39.1997-086.5327/
    firmware        : H22.01.02.01.00
  Duration: 00:03:03.13, start: 0.000000, bitrate: 45064 kb/s
  Stream #0:0(eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 2704x1520 [SAR 1520:1521 DAR 16:9], 44789 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro H.265
      vendor_id       : [0][0][0][0]
      encoder         : GoPro H.265 encoder
      timecode        : 11:55:08:05
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro AAC
      vendor_id       : [0][0][0][0]
      timecode        : 11:55:08:05
  Stream #0:2(eng): Data: none (tmcd / 0x64636D74) (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro TCD
      timecode        : 11:55:08:05
  Stream #0:3(eng): Data: bin_data (gpmd / 0x646D7067), 63 kb/s (default)
    Metadata:
      creation_time   : 2023-02-25T16:45:10.000000Z
      handler_name    : GoPro MET
ERROR: Parsing of '/mnt/d/GoPro/output.gpx' failed due to not well-formed (invalid token) on line 1 and column 4
[swscaler @ 0x560020b36240] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x560020a9da00] using SAR=1520/1521
[libx264 @ 0x560020a9da00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x560020a9da00] profile High, level 5.1, 4:2:0, 8-bit
[libx264 @ 0x560020a9da00] 264 - core 163 r3060 5db6aa6 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=cbr mbtree=1 bitrate=32000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=32000 vbv_bufsize=2000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
[swscaler @ 0x5600210d0800] deprecated pixel format used, make sure you did set range correctly
Output #0, mp4, to '/mnt/d/GoPro/output.mp4':
  Stream #0:0: Video: h264, yuvj420p(pc), 2704x1520 [SAR 1520:1521 DAR 16:9], q=2-31, 32000 kb/s, 59.94 tbn
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
Parsing '../samples/layout-1920x1080.xml' layout file
Load widget 'position'
Initialize position widget
Load widget 'grade'
Initialize grade widget
Load widget 'speed'
Initialize speed widget
Load widget 'elevation'
Initialize elevation widget
Load widget 'time'
Initialize time widget
Load widget 'date'
Initialize date widget
Load widget 'duration'
Initialize duration widget
Load widget 'cadence'
Initialize cadence widget
Load widget 'heartrate'
Initialize heartrate widget
Load widget 'distance'
Initialize distance widget
Load widget 'avgspeed'
Initialize avgspeed widget
Load widget 'maxspeed'
Initialize maxspeed widget
Load widget 'temperature'
Initialize temperature widget
Skip widget 'gpx'
ERROR: Parsing of '/mnt/d/GoPro/output.gpx' failed due to not well-formed (invalid token) on line 1 and column 4
WARNING: Can't read GPS data, skip map widget
ERROR: Parsing of '/mnt/d/GoPro/output.gpx' failed due to not well-formed (invalid token) on line 1 and column 4
WARNING: Can't read GPS data, skip map widget
Skip map widget
Cache initialization...
Time synchronization...
PACKET: 0 - PTS: 0 - TIMESTAMP: 0 ms - TIME: 2023-02-25 21:45:10 - GPS FIX: 3 - GPS TIME: 2023-02-25 16:45:34.100 - OFFSET: -17976
Video stream synchronized with success (offset: -17976 ms)
Rendering...
FRAME: 0 - PTS: 0 - TIMESTAMP: 0 ms - TIME: 2023-02-25 11:45:34
...
FRAME: 10974 - PTS: 10984974 - TIMESTAMP: 183082 ms - TIME: 2023-02-25 11:48:37
FRAME: 10975 - PTS: 10985975 - TIMESTAMP: 183099 ms - TIME: 2023-02-25 11:48:37
FRAME: 10976 - PTS: 10986976 - TIMESTAMP: 183116 ms - TIME: 2023-02-25 11:48:37
10977 frames 2704x1520 to 2704x1520 proceed in 00:15:38
progweb commented 1 year ago

Hi,

First, thank's to use gpx2video.

The command line ./gpx2video -v -m /mnt/d/GoPro/7thToDowntown.mp4 -o /mnt/d/GoPro/output.gpx -f 2 extract extracts GPMD data in raw format (so binary)

To get a GPX formatted file: ./gpx2video -v -m /mnt/d/GoPro/7thToDowntown.mp4 -o /mnt/d/GoPro/output.gpx -f 3 extract

The next command should work as expected.

For your information:

*) Your video resolution is 2704x1520. You may to adapt the layout file.

*)

Time synchronization...
PACKET: 0 - PTS: 0 - TIMESTAMP: 0 ms - TIME: 2023-02-25 21:45:10 - GPS FIX: 3 - GPS TIME: 2023-02-25 16:45:34.100 - OFFSET: -17976
Video stream synchronized with success (offset: -17976 ms)

gpx2video detects a time offset. Indeed, your video has been created at : creation_time : 2023-02-25T16:45:10.000000Z But from GPS embedded in the camera, the "real" start time is 2023-02-25 16:45:34.100