time4tea / gopro-dashboard-overlay

Programs to process GoPro MP4 & Generic GPX/FIT files and create video dashboards & maps
GNU General Public License v3.0
383 stars 52 forks source link

Change in 0.114.0 breaks speed metric component #161

Closed neri14 closed 11 months ago

neri14 commented 12 months ago

with layout xml:

<layout>
    <component type="metric" metric="speed" size="64" />
</layout>

speed metric doesn't render in 0.114.0 (works in 0.113.0):

(venv) [neri@hades overlay]$ gopro-dashboard.py --layout xml --layout-xml ./layouts/test.xml   --video-time-start file-modified --use-gpx-only --gpx /home/neri/downloads/gpx/20231126_zwift.gpx   /home/neri/videos/gopro/edits/20231126.trim.mp4   /home/neri/videos/gopro/edits/20231126.trim.dash.mp4
Starting gopro-dashboard version 0.114.0
ffmpeg version is n6.1
Using Python version 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
GPX/FIT file:     2023-11-26T09:32:40+00:00 -> 2023-11-26T10:18:49+00:00
Video File Dates: 2023-11-26T10:03:25+00:00 -> 2023-11-26T10:06:25+00:00
Generating overlay at Dimension(x=3840, y=2160)
Timeseries has 1801 data points
Processing....
FFMPEG Output is in /tmp/tmpp2xwkpuk.txt
Timelapse Factor = 1.000
Executing ['ffmpeg', '-y', '-hide_banner', '-loglevel', 'info', '-i', '/home/neri/videos/gopro/edits/20231126.trim.mp4', '-f', 'rawvideo', '-framerate', '10.0', '-s', '3840x2160', '-pix_fmt', 'rgba', '-i', '-', '-filter_complex', '[0:v][1:v]overlay', '-vcodec', 'libx264', '-preset', 'veryfast', '/home/neri/videos/gopro/edits/20231126.trim.dash.mp4']
Render: 0 [  0%]  [  0.0/s] |                                                                                               | ETA:  --:--:--Timer(drawing frames - Called: 0, Total: 0.00000, Avg: 0.00000, Rate: 0.00)
Traceback (most recent call last):
  File "/data/user/neri/projects/nerimtb/overlay/venv/bin/gopro-dashboard.py", line 378, in <module>
    draw_timer.time(lambda: buffer.draw(lambda frame: overlay.draw(dt, frame)))
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/timing.py", line 30, in time
    r = f()
        ^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/bin/gopro-dashboard.py", line 378, in <lambda>
    draw_timer.time(lambda: buffer.draw(lambda frame: overlay.draw(dt, frame)))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/buffering.py", line 27, in draw
    f(image)
  File "/data/user/neri/projects/nerimtb/overlay/venv/bin/gopro-dashboard.py", line 378, in <lambda>
    draw_timer.time(lambda: buffer.draw(lambda frame: overlay.draw(dt, frame)))
                                                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/layout.py", line 105, in draw
    return self.scene.draw(image)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/widgets/widgets.py", line 251, in draw
    w.draw(image, draw)
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/widgets/widgets.py", line 32, in draw
    w.draw(image, draw)
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/widgets/text.py", line 28, in draw
    text = self.value()
           ^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/layout_components.py", line 43, in value
    return formatter(v)
           ^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/layout_xml.py", line 324, in <lambda>
    return lambda q: format(q.m, f".{dp}f")
                            ^^^
AttributeError: 'float' object has no attribute 'm'

with kph units:

<layout>
    <component type="metric" metric="speed" size="64" units="kph" />
</layout>

traceback is:

Traceback (most recent call last):
  File "/data/user/neri/projects/nerimtb/overlay/venv/bin/gopro-dashboard.py", line 378, in <module>
    draw_timer.time(lambda: buffer.draw(lambda frame: overlay.draw(dt, frame)))
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/timing.py", line 30, in time
    r = f()
        ^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/bin/gopro-dashboard.py", line 378, in <lambda>
    draw_timer.time(lambda: buffer.draw(lambda frame: overlay.draw(dt, frame)))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/buffering.py", line 27, in draw
    f(image)
  File "/data/user/neri/projects/nerimtb/overlay/venv/bin/gopro-dashboard.py", line 378, in <lambda>
    draw_timer.time(lambda: buffer.draw(lambda frame: overlay.draw(dt, frame)))
                                                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/layout.py", line 105, in draw
    return self.scene.draw(image)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/widgets/widgets.py", line 251, in draw
    w.draw(image, draw)
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/widgets/widgets.py", line 32, in draw
    w.draw(image, draw)
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/widgets/text.py", line 28, in draw
    text = self.value()
           ^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/layout_components.py", line 41, in value
    v = converter(e)
        ^^^^^^^^^^^^
  File "/data/user/neri/projects/nerimtb/overlay/venv/lib/python3.11/site-packages/gopro_overlay/layout_xml.py", line 61, in <lambda>
    "kph": lambda u: u.to("KPH"),
                     ^^^^
AttributeError: 'float' object has no attribute 'to'
time4tea commented 12 months ago

Thank you for reporting this. It won't happen for all videos.. although for an affected video it will happen repeatable.

think it will happen when gps is not locked at the start of a ride.

I'll fix ASAP.

time4tea commented 11 months ago

Hi @neri14 - are you able to share your gpx and mp4 files with me? I believe I know what the issue is, but I've not been able to reproduce it with an actual file. If not, of course this is absolutely fine. If you can, please email a link to gopro-overlay@time4tea.net -> i usually suggest using WeTransfer. Thank you!

neri14 commented 11 months ago

Shared over mail, I've attached through wetransfer: gpx, video, overlay xml and requirements.txt with pip freeze output.

Video is trimmed with ffmpeg - I was using that one for testing and that fits within wetransfer limit - although I've checked now - same errors show up when using raw file from gopro that wasn't joined or cut.

Video is from gopro 12 (so no gps onboard). Gpx was from zwift downloaded from strava - I was doing a test recording.

I've tried it just now with normal outdoor gpx downloaded from garmin connect and its same behavior - crash on 0.114.0, reinstalling 0.113.0 renders (attached that gpx directly to mail).

time4tea commented 11 months ago

Hi @neri14 - thanks for the files. Maybe this is now fixed. Your files now work for me. They were very useful to pinpoint the issue. I have published 0.115.0 to PyPI - should be available very shortly.

neri14 commented 11 months ago

All works now, Thanks!