time4tea / gopro-dashboard-overlay

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

Is there any way to time align the fit file with the gpx file in the gopro file? #143

Closed xiaoxin01 closed 11 months ago

xiaoxin01 commented 11 months ago

When a video of a ride is recorded with a gopro, and then a fit file with data like heart rate and power is recorded with a Gamin device, they usually don't start at the same time.

Is there any way to make the start and end times of the fit file match the start and end times of the gopro's gpx file? So the data from the fit file such as heart rate can be displayed in the video!

Thanks

time4tea commented 11 months ago

Hi, Thanks for your interest.

This is a common use case. When using a gopro video, and a gpx or fit file, you should be able to do this quite simply.

The example given at https://github.com/time4tea/gopro-dashboard-overlay#example is basically this use case.

Does this work for you? The alignment cannot be completely exact but it should be accurate to 1 second.

Please let me know if you have any problems with this

James

xiaoxin01 commented 11 months ago

Hi @time4tea,

I tried rendering a gopro video with a fit file, but ran into an error: list index out of range

Here is the detailed output:

bin/gopro-dashboard.py --font "Andale Mono" --fit ~/Downloads/11348674853_ACTIVITY.fit --privacy 52.000,-0.40000,0.50 /Volumes/Untitled/DCIM/100GOPRO/GX020123.MP4 GX020123-dashboard.MP4

Starting gopro-dashboard version 0.101.0
ffmpeg version is 6.0
Using Python version 3.10.8 (main, Nov 24 2022, 08:08:27) [Clang 14.0.6 ]
    Timer(GPMD - Called: 1, Total: 0.16385, Avg: 0.16385, Rate: 6.10)
    Timer(extract GPS - Called: 1, Total: 0.01990, Avg: 0.01990, Rate: 50.26)
Timer(parsing - Called: 1, Total: 0.18388, Avg: 0.18388, Rate: 5.44)
GPX/FIT Timeseries has 4146 data points.. merging...
Timer(loading timeseries - Called: 1, Total: 5.68536, Avg: 5.68536, Rate: 0.18)
Timer(program - Called: 1, Total: 5.68537, Avg: 5.68537, Rate: 0.18)
Traceback (most recent call last):
  File "/Users/chenjinxin/Desktop/cycling/gopro-dashboard-overlay/bin/gopro-dashboard.py", line 204, in <module>
    merge_gpx_with_gopro(gpx_timeseries, frame_meta)
  File "/Users/chenjinxin/miniconda3/lib/python3.10/site-packages/gopro_overlay/framemeta_gpx.py", line 49, in merge_gpx_with_gopro
    if gpx_timeseries.min > gopro_framemeta.get(gopro_framemeta.max).dt:
  File "/Users/chenjinxin/miniconda3/lib/python3.10/site-packages/gopro_overlay/framemeta.py", line 148, in max
    return self.framelist[-1]
IndexError: list index out of range
time4tea commented 11 months ago

Hi, Thanks for reporting this. There does appear to be an issue.

time4tea commented 11 months ago

Hi @xiaoxin01 - I have been able to reproduce this error, when GPS recording was not enabled in the GoPro. I've made the new version be more obvious when this is the case. Is it possible that this is what happened? You could use:

bin/gopro-to-csv.py --every 1 /path/to/file.MP4

to show all the GPS data.

xiaoxin01 commented 11 months ago

Hi @time4tea,

Thanks for your help. After I enable GPS recording, the script can add overlay successfully. It’s great :)