Handbrake Automation

My wife and I have been fortunate this year to have taken multiple vacations.  Something that rarely happens even during my younger days.  One of those vacations happened to be our honeymoon to the one and only Hawaii!  We rented a house and tried our best to act like locals, up until we bought a GoPro.  The single best purchase we’ve made in a long time, unfortunately we made the decision a couple days into our honeymoon so we didn’t capture as much as we wanted.  Now, I’m thinking about doing a review about the GoPro 4 Hero, but that’ll be at a latter date.

Today, I want to talk about the ability to compress videos automatically.  As you can imagine, with a GoPro we were recording everything that we could; after all that’s why we bought it!  And we did this for each vacation we went on.  Now that I finally have been able to migrate the data to my main machine, I thought of a way to compress the videos.  On the GoPro 4 Hero a 3-4 minute video is about 1.5GB or larger in size.   Yes that’s 4K resolution, but geez that is a lot!  So I pulled out HandbrakeCLI from the dusty parts of my drive, fired up Visual Studio and got to work (Handbrake is a video compression application).  My only complaint with Handbrake, is it’s lack of looking at sub folders, which lead me here.

I started by building an Windows Service that would listen to a folder for changes, but then scrapped that idea for a simple console app for the time being.  Therefore, I made a console app that simply looks at a folder recursively to find any video files and convert them using Handbrake.  Now, the folder that the application looks for is set via the App.config and same goes for the extensions it will look at.

After successfully running the application I was able to see a ~90% compression on all the videos with no loss in quality.  I call that a win!  Check out the code over at my GitHub and feel free to branch it and/or leave a comment below!

Leave a Reply

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