This post is a write up of a recent project I completed that automates editing interesting moments from lengthy video footage. The scripts utilize meta data to programmatically trim the footage into a short “best of” highlight reel.
Competitive Amateur Volleyball
I play competitive volleyball with my coworkers. Competitive not in the sense that we are great players (we are pretty bad), but in that winning means we get to carry the title of champion for the rest of the day.
The problem with being competitive amateurs is that every play, every self-made call on whether someone touched the net or if the ball landed out of bounds is scrutinized; after all, it only takes one mistaken call to cause the other team to come out victorious.
I started filming our volleyball games in an effort to reduce some of the disputed calls – after all, video footage will show the truth of whether your hand scraped the net or not. As a bonus, having video footage of all of your mistakes and terrible plays makes for great fun.
While filming volleyball games is easy – set up the camera, press record, go and play – editing that hour worth of footage is painful. If you have filmed your child’s piano recital or baseball game only to have to fast-forward to the interesting parts when re-watching later on, you know what I mean.
Filming games for dispute arbitration, self-improvement, and comedy is only good if people actually want to watch the footage. And the only way ANYONE is going to want to watch the footage is if it’s edited down to a “best of” highlight reel.
Identifying Interesting Footage
I was determined to find a way to edit our volleyball game footage without having to actually edit our volleyball game footage.
These HiLight tags are meant to make it easy to find interesting parts of your video later on. HiLight tags can either be added via remote control or the voice activated phrases “Add HiLight” or “That was sick” (yes really). The voice activation didn’t work well for our camera setup inside of a giant gym, so I opted for aknock-off GoPro remote.
The way it works is that after every contentious, comedic, or (completely lucky) amazing play, I press the HiLight button on the remote to save this interesting spot in the footage for later.
Automatic Programmatic Editing
Now comes time to edit the hour of game footage. GoPro has some of their own desktop and mobile software for editing the tagged footage, but those options did not produce the results I was looking for (those tools are definitely catered towards putting together compilations of your footage from a weekend ski trip).
Unsatisfied with existing solutions, I ended up writing my own python script for extracting the HiLight tags from the video footage.
First, the script parses the video files, identifying the locations of all of the HiLight tags.
Next it calculates the time locations for a given amount of seconds before and after each HiLight tag (this is variable – I’ve found 7 seconds before and 1 second after the remote button press works well for our volleyball games).
Once all of the trim start and end points are calculated, the script then cuts out clips from the footage and compiles them into a single video file.
Finally, after the finished “HiLight” reel renders, the video uploads to our private YouTube channel.
Conclusion and the Future
After I get back to my computer from our volleyball games, it takes my under powered laptop about 40 minutes to edit an hour of footage down to around 5 minutes and upload the resulting compilation to YouTube.
Honestly, I’d be happy even if this took 3 hours because the best part is that after I put the SD card into the computer and double click the shortcut to run the script, the process is completely automatic.
In all honesty, having the game footage hasn’t stopped many of our game disputes: arguments about physics, geometry, and indoor weather patterns still come up regularly.
However, having a tightly edited video of you and your friends’ “best of” and “worst of” moments is really fun to watch.
While I’ll keep editing our volleyball game footage (because it’s so easy), I’m more excited about ideas this project has given me for editing other, non-GoPro footage I generate weekly. I plan on repurposing quite a bit of this code for more advanced version to help me do the rough edits of my SQL with Bert DSLR footage.