Raspberry Pi can do fast video encoding
Yes, the Raspberry Pi can do fast video encoding. Of course you normally wouldn’t want to re-encode any video with an ARM processor, but that’s not what we’re going to do here. We’re going to leverage the GPU. I should point out before proceeding that the input formats for re-encoding are limited in this method, more about that below.
In order to do this, I’m using a proof-of-concept tool called omxtx, which I think is supposed to be a shortened form of “OpenMAX Transcoding”. Off the top of my head, here are the prerequisites for building the binary from source:
- Raspbian. It will probably work on other RPi distros, but I haven’t tried them.
- The
build-essential
package installed, which you normally need to build anything. - Memory split of 64MB for video. I previously had this all the way down to 16 since I don’t use a display on my Pi, but bumping it to only 32MB caused runtime errors from the omxtx binary. You need to give the GPU some breathing room to encode video.
- There’s probably some libraries you may or may not have installed that the build wants to link in. When I run
ldd
on my finished binary, it loads all kinds of media libs like libav, libvorbis, libvpx, etc. YMMV.
Once you’ve run git clone URL
or just grabbed & unzipped the master.zip from the Github page, go the the directory and just try running make
to see if it works. With luck, in about 30 seconds you should have a working omxtx
binary that you can drop into one of your PATH
s like /usr/local/bin or ~/bin.
Running it without any arguments shows the command usage, available options, and the input formats. As I mentioned at the top of this post, the input formats are limited, but I tried running it on a video encoded with XVID, and it seems to work mostly fine. I think the output mp4 file may just have been missing the final one or two frames from the original.