Click here to Skip to main content
15,868,016 members
Articles / Programming Languages / XML

GoPro Clip Extractor

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
28 Nov 2018CPOL4 min read 8.6K   320   4   2
A quick and easy way to extract multiple video clips from GoPro video footage

Introduction

I have a couple of kids who play minor sports and I regularly record video their team games using GoPro cameras. There is a lot of video footage created from one game. Using two cameras at a hockey game creates about two hours of video. Editing all of that video into one nice final cut can be tedious to say the least. GoPro has an application called Quik to extract clips from video, but the process is way too long and the workflow is tedious. I tried a few open source applications as well including ShotCut but nothing seemed to make life easier. I then found the FFMPEG library and the command line application ffmpeg.exe. Using the proper command line parameters, I could extract a video clip in less than a second. This article is a brief discussion of the GUI that was made to select the starting point and length of the clip to create batch files for ffmpeg.

Background

One of the problems with editing high resolution 2K/4K video is the enormous file sizes which are typically 4GB each. Most computers can play the videos but quickly jumping around in time is glitchy. The GoPro cameras also record a low resolution video with an extension LRV. This is actually an MP4 video file and can be renamed and watched using any video player. The low resolution videos are used to find the wanted clips and then ffmpeg is used to extract them from the higher resolution videos. I used the Windows Media Player control and embedded it into a Windows Forms application to allow me to control the video playback. There isn't a lot of code required to make this work since ffmpeg is doing the heavy lifting for us.

The contents of a typical GoPro folder are displayed below where the low resolution files are highlighted.

Image 1

The main window for this application is an MDI window as shown below. The intention was to be able to open the videos from two or more cameras in separate forms.

Image 2

Clicking the New Extractor button will open a new video extraction form as shown below:

Image 3

The first step of the process is to rename GoPro LRV files. This will open the file open dialog to select the files.

Image 4

We then Open Videos to add the low resolution videos.

Image 5

This will add all of the selected videos to the listbox. Selecting a video in the listbox will open it in the Media Player control as shown below:

Image 6

The default media player buttons and scroll bar can be used to pause/play and skip through the video. However, it is much more efficient to use the keyboard. The following keys can be used to control the media player. The right arrow skips the video forward by one second. The left arrow skips the video back by two seconds. The Spacebar is used to toggle the play and pause states. The Enter key is used to mark the beginning of the clip to extract.

Image 7

Each time, the Enter key is pressed, a new clip extraction macro is created and added to the clip list box. This is shown below where five clips have been added to the list box. Notice that the filename has been changed from the low-resolution video GL010232.mp4 to the high-resolution file GH010232.mp4 in the macro. The low-resolution file is used because it speeds up the processing. The high-resolution video is what is going to be extracted from the files. There is a combo box named Clip Time that can be used to select the length of the clip. The default value is ten seconds.

Image 8

The clip macros are simply instructions that get passed to the ffmepg.exe application. Before these instructions can be executed, they must be saved to batch file. This is done using the Save button. The default filename is extractClip.bat and the default folder for saving is the source of the video files. The contents of this file are shown below. Each line calls the program ffmeg.exe and passes the starting point of the clip, the filename to extract the clip from, the length of the clip, and the output filename. The output files are named clipN.mp4 where N is an integer starting from one and ending in the number of clips.

Image 9

Since this is just a text file, it can be modified in any text editor if slight changes are required to the starting or ending times of the clips. To extract all of the video clips, simply double click on the extractClips.bat file that was saved. This requires the ffmpeg.exe file to be in the same directory as the batch file.

Points of Interest

There isn't much code or interesting details behind the project. It's just the fastest way that I've found to extract clips from the GoPro video files to date. It might be a starting point for someone else to extend upon or maybe someone else has the need to extract clips from GoPro videos.

History

  • November 28th, 2018: V1.0 Initial release

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionBrilliant ... Pin
Richard MacCutchan3-Dec-18 1:21
mveRichard MacCutchan3-Dec-18 1:21 
AnswerRe: Brilliant ... Pin
Anthony Fountaine4-Dec-18 10:28
Anthony Fountaine4-Dec-18 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.