So I got distracted by video encoding…

Yeah, was meant to be getting my head around Docker, but got side tracked by H.265 and H.264, and CUDA…

Turns out that a lot of the media files I’ve got are from the DivX era of encoding and re-encoding using something a little more modern would keep the quality the same, but reduce the file size significantly (probably around half the current size, if not less!).

So I started to play around the with the various encoding presets, and found that the outputs looked worse than the originals unless I increased the quality to the extent that things were transcoding in real time (not that surprising, as H.265 is still relatively new and less optimised than H.264)!. Real time converting is less than ideal, given the number of media files I’ve got. After a bit of poking about the net to find out whether there were some options I wasn’t aware of, I discovered that Nvidia cards have {en/de}coding hardware on them, so it should be possible to use the GPU to do the heavy lifting.

Turns out that I need to compile FFmpeg from source to get that functionality. It was pleasantly simple to do and everything Just Worked(tm). Now armed with h264_nvenc (my GTX 680 doesn’t have the H.265 hardware), I ran it using the same options on a sample file.

On my Intel i7-3770 (3.4GHz turbo to 3.9GHz), I was averaging around 2x-4x speed (i.e. 1 second to encode between 2 and 4 seconds of video). Using the GPU, it was 20x to 35x real time(!!). The machine was also a hell of a lot quieter, as the GPU with the video engine running at 100% was 45C and barely perceptible fan noise, the CPU running at 100% was around 60C with the fan running at full speed and making a noticeable amount of noise (I’m a big fan of silent machines, so if I can hear the fans, there’s a lot of heat being dissipated!). File size went from 4.2GB to 2.1GB, so a nice 50% saving, time to encode was a little under 5 minutes. So 5 minutes of GPU time to save a couple of GB of storage space and a very slight reduction in quality – that sounds like a Cunning Plan if I ever heard one!

Now that I’ve found out that transcoding things can be done in a reasonable amount of time, I’ll put together a script to work through the various old media files and bring them a little more up to date 🙂

Tagged with: , , ,
One comment on “So I got distracted by video encoding…
  1. Specter says:

    I have no idea what any of this means at all. I currently feel like an impotent Luddite. My terror and fear of “the demon electricity” is made flesh in these words you’ve posted. Nevertheless… thinking of you speaking them was both entertaining, and insightful. Turah. #teamghostbacon

Leave a Reply

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

*