Automatically Editing Lengthy Video Footage

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.

Video Arbitration

Not every hit is as obvious to officiate as this.

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

You would think pressing the Star button would add a HiLight tag. Nope – it’s the wrench.

I was determined to find a way to edit our volleyball game footage without having to actually edit our volleyball game footage.

I film our games with a GoPro, and the more recent GoPro models have a “HiLight” tagging feature that adds chapter marker meta data to the video 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

This is the full length ~30 second long recording. It is boring to watch (with the exception of King Charles wanting to get in on the action). Imagine this is a 1-hour long volleyball game. Notice when I press the button on the remote to add “HiLight” tags to the video.
This is the automatically edited version. You’ll notice each clip starts 3 seconds before and 1 second after each time the button is pressed – that is configured in the program.

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.

6 Replies to “Automatically Editing Lengthy Video Footage

  1. Hey Bert

    I’ve been searching for a solution for the hilights ever since gopro removed them a while ago (they dont work with premiere anymore, but used to at launch).

    After trying a lot of methods I found yours but Im not a programmer and getting some errors I dont know how to fix.

    “gopro-hilight-reel\HiLightExtractor.py”, line 3, in
    from moviepy.editor import *”

    Searched for moviepy, found it on github but release only has source code which Im not sure what I should do with.

    Any guidance on this? What Im missing or what am I supposed to install for it to work?

    Thank you

      1. Got git, installed moviepy, not getting the error anymore.

        But running HiLightExtractor.py doesnt do anything (doesnt even throw an error or anything). The only thing doing something is the app.py which throws some errors (looks like it uses extra / in the file location).

        Is there soemthing else Im missing?

        1. App.py is the code that runs everything else. HiLightExtractor.py is not meant to run on its own, but can be repurposed for whatever you need.

          1. I understand now, managed to run it without problems. Thanks for the answers, learned a bit today.

            It runs nice and it does what its supposed to, thanks for writing it. Im actually looking for something to grab the hilights from the files and make it usable in Premiere. Im fiddling with the code while trying to learn it.

            Do you by chance have knowledge of something that can import the hilights into Adobe Premiere? It used to work when 5 launched but it stopped a few months later.

            Some software (like MP-HC) read the hilights, Adobe doesnt. I was thinking of extracting the hilight timing and just writing a normal XML that adobe uses, to import. Its annoying to have months of material with a few markers in each and having to go manually one by one and mark them for cutting later. It actually makes not want to edit video and it sucks, hence looking for a solution.

            Thank you again

          2. Glad you got it working!

            I think premiere used to import them as chapter markers right? You might be able to figure out what premiere reads them in as, extract the hilights using the python code, and then add chapter markers (or whatever premiere uses) to the video meta data and hopefully it will work again.

            Haven’t tried this though, but I’m guessing that’s how it works.

Leave a Reply

Your email address will not be published. Required fields are marked *