AdrianEddy / telemetry-parser

A tool to parse real-time metadata embedded in video files or telemetry from other sources like Betaflight blackbox. Supported formats: Sony, GoPro GPMF, Insta360, Betaflight blackbox (csv and binary)
Apache License 2.0
145 stars 15 forks source link

Crash on opening semi-corrupt GoPro file #21

Closed JRispens closed 1 year ago

JRispens commented 1 year ago

I recorded some video's with a GoPro Session5 which were stopped mid-flight. Also my latest video, which I stopped manually, gave the same problem. The GoPro could repair the latest video, all the files were still on the SD card and a new copy simply worked. I don't have the original files of the old ones anymore and I can't get the GoPro to automagically repair them :(

07:49:39 [WARN] Garbage found at the end of the file, removing 31067 bytes from the end. 07:49:39 [DEBUG] (1) default: QT_QUICK_CONTROLS_TEXT_SELECTION_BEHAVIOR "" 07:49:39 [ERROR] thread '' panicked at 'called Result::unwrap() on an Err value: InvalidData("zero timescale in mdhd")': C:\Users\runneradmin.cargo\git\checkouts\telemetry-parser-19821e7ac6d09f51\06e6f80\src\util.rs:102

Video causing the crash: https://drive.google.com/file/d/1Gh-DMn6P78dij9ER9IfQrBYWBJBIxuw9/view?usp=share_link

AdrianEddy commented 1 year ago

mp4 structure is corrupt in this file and it's not valid so the parser returns an error. With some trickery I managed to implement a workaround by patching the incorrect data to a known value for GoPro metadata, and it appears to be working.

Workaround is here: https://github.com/AdrianEddy/telemetry-parser/blob/1602bf7a54af542dbc096ad1d1d9bf18017ff210/src/util.rs#L71-L98

Gyroflow with this fix is currently building here https://github.com/gyroflow/gyroflow/actions/runs/3481824562

Thanks for the sample file