icegoogles / GoPro-Highlight-Parser

This project is to extract the highlights of GoPro-videos.
MIT License
17 stars 5 forks source link

Long videos #3

Open jayargo opened 9 months ago

jayargo commented 9 months ago

I went to test a 4GB file and found that the sequential read was taking forever. Looking around for solutions, I discovered that newer GoPro cameras store the highlights as chapters! I couldn't find a way to directly view those chapters in Adobe Premiere without a script to import them, but you can extract them quickly using ffprobe:

ffprobe -v error -show_chapters -of default=noprint_wrappers=1:nokey=1 -sexagesimal .\GX010015.MP4 -select_streams v:0 -show_entries chapter=start_time -of csv=p=0

0:22:52.988000
1:17:50.399000
1:20:05.567000
1:20:11.323000
1:20:33.211000
1:20:36.064000

Might be worth enhancing this repo to provide a solution that first checks if the GoPro video has chapters, and if it does, directly extracting them via ffprobe (there's a python wrapper for ffprobe), and otherwise fall back to sequential read approach.

icegoogles commented 9 months ago

What do you mean with "newer GoPro cameras"? Which model do you have? My newest is a Hero9 where the reading seems to work perfectly. I converted 49 Videos (ca. 26 GB) in about 5 seconds or so. Which I think is okay. Maybe they changed something afterwards. It then really surprises me that my script still works 😄 Maybe it is also Video-Length. My videos where a maximum of 11 minutes but most where shorter

Probing the chapters beforehand sounds like a good idea. But I think I would need some footage to test with. Also I can't yet say when I will be able to implementing this. But this does not sound that tricky

Maybe related: In this Issue we found that the Hero5 (and maybe older ones) store highlights in a different way. I added an implementation to get this to work with the Hero5.

jayargo commented 9 months ago

The test I ran where it was taking forever was a single file with over an hour and 20mins of footage at 60fps (volleyball games can be long!). I didn't time the script but I let it sit for at least 5 minutes before killing it. The ffprobe was close to instant. I think you are right, it's the video length, not the file size. I've updated the issue title accordingly.

Regarding newer cameras, I saw it reported elsewhere that since at least gopro hero 7, the highlights are (also?) stored as chapters. If you have a hero8, if you open your footage in VLC you should supposedly also see the highlights as chapters (or install ffprobe and run the ffprobe example to extract the timecodes). I only have a GoPro 12 (I'm new to all this!) so that's the only one I could test and i can confirm both VLC and ffprobe show chapters for the highlights. If the reports are wrong and your hero8 doesn't have chapters, I'd be happy to upload some hero12 footage.

You make a good point about backwards compatibility being surprising here. I think they must also store the chapters the way you are currently checking because that does still work with my gopro 12 footage (at last for the shorter video that I could test).

icegoogles commented 9 months ago

I fiddled around a bit and found that my GoPro9 footage does not contain video chapters even though it has highlights. I tested with your command and with VLC-Player as was suggested here.

But I have a new lead! My Videos are a maximum of 11 minutes and 47 seconds (11:47) long. Longer Videos get split so they do not get over this time limit. I thought it might have something to to with some integer-value being/getting to large. That's what I remember from my research a few years ago. But I did not verify this value and also it does not align with any integer limit (mainly milliseconds of videotime).

But I think when you import the Gopro-files via "Quik Desktop" ("GoPro Desktop" / "GoPro Studio") the files get stitched together (did not verify again, but I have a memory of noticing that once). Maybe the desktop app also converts the highlights into video chapters. I personally just put the SD-Card to my PC and copy the "raw" footage, since I did not like the desktop app at the time.

I will try out the pipline with the desktop app, but in the meantime maybe you could tell me: How do you export your videos from your GoPro?

Also a small note: From my research using ffmpeg/ffprobe requires an installation of the program, using a docker container or something similar. That makes me hesitant to implement it in the main script. But I still am all for it, but maybe an an extra script for more advanced users

UPDATE: I tried importing with the Quick Desktop App. For me the Videos where still split in multiple videos and did not contain highlights as chapters. I used MTP connection not GoPro Connect. Maybe I should try that option, but I'll try that another day