2015-02-21

Video transcoding on BananaPi


For a while I've been playing with BananaPi running LAMP server and other stuff. Then I decided to test how well it can transcode video since it has a dual core processor and NEON SIMD instruction set. I've used HandBrake as it's open source and can compile on BananaPi. I came to a suprising conclusion. But first - what I did.

Setting up the machine

I've set up a Lubuntu 14.04, but since I don't use X-Windows I've tried to clean the system as much as possible. I've used this page as guidance, but added a few things on my own. Basically I wanted a server machine using only command line. Since I'm going to use it without a monitor.

 sudo apt-get remove abiword abiword-common abiword-plugin-grammar abiword-plugin-mathview ace-of-penguins audacious audacious-plugins audacious-plugins-data blueman catfish chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg elementary-icon-theme fonts-lyx galculator gdebi gdebi-core gecko-mediaplayer giblib1 gnome-desktop-data gnome-icon-theme-full gnome-mplayer gnome-system-tools gnome-time-admin gnumeric gnumeric-common gnumeric-doc gpicview gtk2-engines-pixbuf guvcview hardinfo indicator-application-gtk2 leafpad libaacs0 libabiword* libass4 libaudclient2 libaudcore1 libbinio1ldbl libbluray1 libbs2b0 libcddb2 libcompfaceg1 libcue1 libdca0 libdirectfb-1.2-9 libenca0 libept1.4.12 libexo-1-0 libexo-common libexo-helpers libfaad2 libfluidsynth1 libfm-data libfm-gtk-bin libfm-gtk-data libfm-gtk3 libfm3 libgdome2-0 libgdome2-cpp-smart0c2a libglade2-0 libgoffice-0.8-8 libgoffice-0.8-8-common libgsf-1-114 libgsf-1-common libgsm1 libgtkmathview0c2a libgtkspell0 libguess1 libid3tag0 libimlib2 libindicate-gtk3 libjpeg-progs libjpeg-turbo-progs liblink-grammar4 libloudmouth1-0 libmenu-cache1 libmms0 libmodplug1 libmowgli2 libmp3lame0 libmpg123-0 libmusicbrainz3-6 libnet-dbus-perl libonig2 liboobs-1-5 libopts25 libots0 libpisock9 libpostproc52 librarian0 libresid-builder0c2a libschroedinger-1.0-0 libsdl1.2debian libsidplay2 libswscale2 libtidy-0.99-0 libtie-ixhash-perl libts-0.0-0 libuniconf4.6 libva1 libvdpau1 libvpx1 libvte-common libvte9 libwebcam0 libwv-1.2-4 libwvstreams4.6-base libwvstreams4.6-extras libxfce4ui-1-0 libxfce4util-bin libxfce4util-common libxfce4util6 libxfconf-0-2 libxml-parser-perl libxml-twig-perl libxml-xpath-perl libxvidcore4 lightdm-gtk-greeter link-grammar-dictionaries-en lm-sensors lp-solve lubuntu-artwork lubuntu-artwork-12-10 lubuntu-core lubuntu-default-settings lubuntu-desktop lubuntu-icon-theme lubuntu-lxpanel-icons lubuntu-software-center lxappearance lxappearance-obconf lxinput lxkeymap lxlauncher lxmenu-data lxpanel lxpanel-indicator-applet-plugin lxrandr lxsession lxsession-data lxsession-edit lxshortcut lxtask lxterminal mplayer2 mtpaint ntp obconf openbox pcmanfm pidgin pidgin-data pidgin-libnotify pidgin-microblog plymouth-theme-lubuntu-logo plymouth-theme-lubuntu-text python-pysqlite2 python-support python-xklavier rarian-compat scrot sylpheed sylpheed-doc sylpheed-i18n sylpheed-plugins synaptic system-tools-backends transmission tsconf uvcdynctrl uvcdynctrl-data wvdial xfburn xfce-keyboard-shortcuts xfce4-notifyd xfce4-power-manager xfce4-power-manager-data xfconf xfonts-100dpi xpad xscreensaver xscreensaver-data cups* gnome* xserver* modemmanager network-manager whoopsie avahi*  

Setting up video transcoder

After setting up Linux I've tried compiling HandBrake from source. Again I used this page as reference. It's an old guid for Handbrake 0.9.8 but the essence is still OK. Also note that it's made for RaspberryPi which is missing NEON instruction set so you have to disable some options. But with BananaPi you don't need to do anything.

I've used old version of Handbrake 0.9.9 because I've been testing it this whole time. But it should work on newer version. Anyway here are the steps.

Get Handbrake:

 wget http://download.handbrake.fr/releases/0.9.9/HandBrake-0.9.9.tar.bz2  

Extract source:

 tar -xjf HandBrake-0.9.9.tar.bz2  

Download and install dependencies:

 apt-get install yasm build-essential autoconf libtool zlib1g-dev libbz2-dev libfribidi-dev intltool libglib2.0-dev libdbus-glib-1-dev libgtk2.0-dev libgudev-1.0-dev libwebkit-dev libnotify-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libvorbis-dev libass-dev libsamplerate-dev libogg-dev libtheora-dev  

Configure and Compile:

 sudo ./configure  
 cd ./build  
 sudo make  
 sudo make install  

After this you should be able to run HandBrake in command line issuing the command:

 /usr/local/bin/HandBrakeCLI   

Benchmark

After setting up HandBrake I've tried to run video transcode on the same file on three different processors. I've used these three systems:

CPU OS CPU TDP Watts used (system)
i7 3537U Windows 8.1 64bit 17W 35W
Core2Duo T9300 Windows 7 64bit 35W 45W
Allwinner A20 (ARM Cortex-A7) Lubuntu 14.04 32bit ??? 3W

Note that I'm using mobile versions of CPUs as all the computers that I own are laptops.

Testing file is a 30 seconds MP4 video file (H264, 1920x1080@23.833FPS, 16950kbps / AAC audio 96kbps, 48kHz). For all the three systems I've used the same preset which is Regular(Normal). Or in the case of command line HandBrake:

 ./HandBrakeCLI -i movie.mp4 -o movie_converted.mp4 -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 --audio-copy-mask aac,ac3,dtshd,dts,mp3 --audio-fallback ffac3 -f mp4 --loose-anamorphic --modulus 2 -m --x264-preset veryfast --h264-profile main --h264-level 4.0  

Results

Below are the results which I got running transcode on video file on all three systems. Please note that I didn't use kilowatt hour notation as the usage is pretty small. So I used watts per hour.

CPU Time used (seconds) Energy used (Watt/hour)
i7 3537U 35s 0.34Wh
Core2Duo T9300 67s 0.84Wh
Allwinner A20 (ARM Cortex-A7) 346s 0.29Wh

Conclusion

Considering the power usage of BananaPi this is a very capable machine, you get more out of it that what you get from a i7 laptop. The downside is that it takes considerable amount of time to do the same work. But if you're not in a hurry and you do your video transcoding at night then BananaPi is for you (and again it uses only 3W of energy!).