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!).

2014-09-16

Banana Pi trial

Intro


I've been considering ordering Raspberry Pi B+ when it came out. But I found out that more ARM computers exist. I was considering between Beaglebone Black, Cubieboard and Raspberry Pi B+ (a nice comparison here). But all of them had one or more shortcomings. I wanted a machine which has fast processor with maybe more than one core. More RAM (most had 512MB) and also fast Ethernet (most have 100MBit/s max).

This is the ARM that I always wanted

Contents


I ordered my Banana Pi together with SATA cable and case which came relatively fast – 3 weeks from China (Aliexpress). The case is very nice looking and luckily I ordered whole package. If I hadn't Banana Pi would lite my room up. It has 3 or 4 LED lights so it can be really annyoing especially if you use it in a dark room.

This case looks even cooler in real life
I wanted Banana Pi also because it is has connector for external disk which can be quite useful if you have old disk laying around. And it also has infrared sensor directly on the board (hopefully for future XBMC support).

First thing I did when I got it was to try to install Raspian on SD card. It worked without problem booting fast into the operation system. The only let down came later when I ran browser. While the experience is faster than Raspberry Pi, YouTube videos didn't play and with Midori as the default browser I couldn't do much.

Because I'm more inclined to Ubuntu universe I tried Lubuntu image. This one worked OK, and it even played YouTube videos. But the problem was the videos were laggy and skipping picture. So basically I couldn't watch or use it in real life.

I was also considering putting on Android since I heard it can do also video acceleration. But I got stuck with Lubuntu because I wanted to try more things with it. And also on Android I can't do much because I have no touch screen and there are no application which I want to try on (I have Nexus 5 for that).

As for the hardware part I really like, that you can physically turn off the machine. And as far as I found out it doesn't use any electricity when it's powered off. I tried running it of a battery which I bought cheap and found out it can run stable at 5V/1A. So I now have a nice little home made UPS.
This is the battery I'm using

Conclusion


It's a really nice box and I have a few ideas of how to use it. I would recommend it to anyone who's deciding between single-board computers. The community for Banana Pi is growing really fast and I expect it to be better than Raspberry Pi considering the capabilities of Banana Pi.

Now for a few pro/cons.

Pro

  • very low power usage
  • it can run off a battery at 5V/1A without problems
  • IR receiver
  • on/off switch
  • it's small and nice looking

Con

  • it doesn't reach full 1Gbit speed (around 260Mbit/s)
  • can't play YouTube videos out of the box 
  • no support for XBMC/hardware video acceleration yet
  • very bright led lights (if you're not using a case)

Use cases/TODOs/ideas


A few ideas I have of how to use Banana Pi. Some of them were ripped from other people but I can't remember where it all came from. 
  • 3G internet tethering (use it as a modem)
  • BitTorrent server (using Transmission)
  • Cloud solution (using something like ownCloud)
  • Cortana/Siri voice recognition
  • Digital TV streaming
  • Educational PC (LibreOffice/Gimb/Scratch/etc.)
  • FM pirate radio station
  • Git server
  • HTPC (XBMC when available)
  • Kiosk mode PC
  • Mail server
  • Music server for MP3 with web interface (Pi Musicbox, Rampr, RaspyFi)
  • Nagios server
  • NAS (even with 260Mbit it's better than the rest)
  • Penetration testing (something along the line of Kali, Raspberry-Pwn, Pwn-Pi, etc.)
  • Print server
  • Proxy server (squid)
  • SQL server (MySQL)
  • SSH server
  • Syslog server
  • Video encoding (handbrake)
  • Video streaming server
  • VOIP server (Asterisk)
  • VPN server
  • Web cam server
  • Web server (Apache/lighttpd + php5)
  • WiFi/Bluetooth connectivity point
These are just a few I could think of. Hopefully some of the things I'll do and write about them in this blog.

2013-03-02

Mac OS X 10.7.2 on VirtualBox 4.1.14 [with XCode 4.21]

Intro

Since I really like having multiple operating systems on my computer I decided to try out Apple's OS on a virtual computer. Not really an Apple fan, though I wanted to see what all the hype is about. After searching the web I found a few install instructions but none of them were simple or worked straight away. So I decided to write my own tutorial about my trip to Apple land.

Start

Since I will be using this machine for development purposes I will also install XCode on OSX. So let's see what I used to install Mac OS X:
  • VirtualBox 4.1.14
  • iATKOS L2 Mac OS X 10.7.2 for X86
  • 20 GBytes of space
  • 64bit processor
  • (optional) dmg2img
  • (optional) XCode 4.21
My primary machine has i7 2600 with 16GB RAM.

Making VirtualBox machine

Make a new Virtual machine and select Mac OS X as operating system and for version select Mac OS X Server (64bit). Give it at lest 1024MB of Base Memory. But the more the better. I found mine stopped lagging considerably after I jumped from 2048MB to 4096MB.

Startup disk should be at least 20GBytes. First I tried with 10GBytes but when I wanted to install anything OS said there is not enough space. So leave it at default. I recommend you set dynamically allocated size, since the size will grow when the system needs it. And it won't take your disk space (in case you're using small SSD disk).

I selected VDI as file type since I will use it only for VirtualBox. If you have other needs then select the appropriate file type.

Setting VirtualBox machine

I'm posting images because they are easier to understand.

But first you need to make ISO image out of downloaded Mac OS X image file (found at the link below).

This you do with the dmg2iso tool:


dmg2img your_downloaded_file.dmg mac_osx_lion.iso


You can mount DMG image same as ISO but since I didn't do it I can't comment on it.
After you've made the ISO image you can mount it in the Storage section in Virtualbox (as seen below).


  • Basic tab in General



  • Motherboardboard tab in System (don't check the Enable EFI)


  •  Processor tab in System (I recommend you don't use too many processors, your whole computer will get stuck if Mac OS X stops responding)


  •  Acceleration tab in System


  •  Video tab in Display (here you can also turn on Remote Display for your Mac OS X)


  •  Storage (mount CD/DVD drive with Mac OS X ISO/DMG image)


  •  Audio (select Intel HD Audio)


  •  Network (usually I select bridged because I need separate IP address)


  •  Enable USB controller


Mac installation

After setting up everything you can start the machine. It will automatically start from the mounted ISO file. Again I'm posting pictures because it's easier to see the procedure.


  • After running you're going to get this screen. Let it boot and wait for the unitl the welcome screen appears


  •  You're going to notice you can't install, because there is no disk drive available. So with mouse go to the Utilities menu and click Disk utility


  •  Select the disk and go to the Erase tab. Type in the name for your disk and press Erase. Again confirm you want to erase disk (this disk is virtual by the way)


  •  After finishing close the Disk utility and you will be transported back to the install screen. Don't click install just yet. Click the Customize button.


  •  In the customize section select the following choices that are listed below. Some instructions say you can select graphic card. But unfortunately Virtualbox emulates Intel. So it's kind of useless to install Nvidia or ATI drivers. And anyway Mac OSX will complain that no Nvidia/ATI hardware found. So resist the choice to select.

  •  After selecting all the necessary options go back to the install screen and click Install. Finally. After the install finished (depending on your configuration 12-30 min) you will see the screen showed below. You have to manually reset computer by selecting Machine->Reset. Be careful to unload the ISO image before that (otherwise we go to fresh install again). After first restart machine will probably ask again to restart. So do that.

  •  After the second restart we come to the welcome screen. Setup your keyboard, location and optional information (Apple ID, registration). And setup user account.


  •  After setting up everything your Mac OS X system will start. You have made it!


Setting the installed OSX

First thing to do after installing is to disable updates. This you do by clicking the Apple icon in the top left corner and select Software updates and untick the Check for updates option. That's it. Of course you can also update, but be careful not to upgrade to a newer version (in the time of writing 10.7.4) because your system will not boot then (figured it out the hard way). Everything else (iTunes, Java updates,...) is OK to update.

Install XCode (optional) 

Since I'm going to use Mac OS X for development I decided to install XCode. You can download XCode from Apple's development site. You have to register to download but otherwise it's free.

I tried many versions of XCode and the only one that worked was 4.21 version. The rest need a newer system (10.7.4). This became a problem when I tried to use friends iPhone for development. Since he was using 5.1.1 operating system it was too new for the installed XCode so I couldn't do anything. But you can still use this XCode to get to know how to develop in it.

Tips

I found out that Mac OS X shares a little bit different keys than Windows. So in Mac copy/paste work by pressing the Windows key (if you have a Windows keyboard) instead of Ctrl.

Tweaks

  • Disable window animations 

Open up Terminal and type in the following command:

defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool NO


  • Disable mail reply animations

Open up Terminal and type in the following command:

defaults write com.apple.Mail DisableReplyAnimations -bool YES

  • Disable the switching Spaces animation 

Open up Terminal and type in the following command:

defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock

  • Showing / hiding sheets

Open up Terminal and type in the following command:

defaults write -g NSWindowResizeTime -float 0.01


  • Window zoom

Open up Terminal and type in the following command:

defaults write com.apple.finder AnimateWindowZoom -bool false


Better performance

    As I said before if you want a better performance try to apply as much memory to the virtual machine as possible. In the end I disabled audio because I didn't need it. And I think it helped with the overall machine stability (it didn't get stuck so much).

    Troubleshooting

    • Guru Meditation -2301 (VERR_REM_VIRTUAL_CPU_ERROR)

    Found out I didn't set Mac OS X (64bit) system in VirtualBox, so always set it to 64bit.
    • F8 doesn't work / No startup screen

    Didn't follow some tutorials advice and forgot to uncheck Enable EFI (Special OSes only)

    • Mac OS X doesn't boot (stuck at Apple screen)
    One of the hiccups of having Mac OS X on virtual machine. Just try to restart/reset the machine until it comes into the OS X (usually not more than 3 times).


    Useful links