Raspberry PI 3 – Howto compile VLC with hardware acceleration

VLC is one of the best multimedia player in the market, a must have app. Available in almost all devices: windows, mac, android, iphone… even on raspberry! Yes, VLC is available for Raspberry PI (good news)! but between us, the version distributed on the official raspbian’s repositories is almost unusable (bad news).

You recently installed your Raspberry PI and you rush to install all the essential software including VLC of course.

You probably started with this command in Terminal:

sudo apt-get install vlc

 
Confident, you make a little test and try to play a video to check that everything is ok and… it is an absolute disaster. Even 480P videos are jerky so do not even talk about a Full HD video… almost impossible to get an image, the CPU is running at 130% until the raspberry starting to freeze – and you’re done, you have to reboot. Why so much Hate? just because VLC distributed on the raspbian’s repositories don’t include OpenMax in charge of the Hardware acceleration. That’s why he is unable to play any HD video.

Okay, sad observation, no hardware acceleration with VLC on the Raspberry PI! The CPU is used and clearly he is not enough powerful for that.

vlcraspberry
vlcraspberry_no hardware acceleration

We could stop there and say: too bad! no video with VLC on the Raspberry. But no! no fear, we are engineers! So we will compile VLC for the raspberry PI3 with hardware acceleration in order to get the GPU working for us. We want to watch our holiday movies on the Raspberry PI!

 


1- Prerequisites

First of all you need the distribution Raspbian Stretch (desktop version of course) and a Raspberry PI 3. Although it is possible to compile on another version of Raspberry, this tutorial only presents the compilation on RPI 3 running Raspbian Stretch.

If you already have installed VLC from the raspbian’s repositories (by miserably noticing the playing failure – the reason you are here), uninstall it:

sudo apt-get purge vlc

Download VLC sources (currently version 2.2.6). in Terminal enter:

cd Downloads
wget http://download.videolan.org/vlc/2.2.6/vlc-2.2.6.tar.xz
tar -xJf vlc-2.2.6.tar.xz

 

2- Dependencies installation

A large list of dependencies must be installed. Hey! We are trying to compile VLC media player on the Raspberry PI 3! not an ‘Hello World’… Given the consequent list, the list is separated, but you can try to regroup commands…

sudo apt-get update

sudo apt-get install autopoint gettext liba52-0.7.4-dev libaa1-dev libasound2-dev libass-dev libavahi-client-dev libavc1394-dev libavcodec-dev libavformat-dev libbluray-dev libcaca-dev libcddb2-dev libcdio-dev libchromaprint-dev libdbus-1-dev libdc1394-22-dev libdca-dev libdirectfb-dev libdvbpsi-dev libdvdnav-dev libdvdread-dev libegl1-mesa-dev libfaad-dev libflac-dev libfluidsynth-dev libfreerdp-dev libfreetype6-dev libfribidi-dev

sudo apt-get install libgl1-mesa-dev libgles1-mesa-dev libgles2-mesa-dev libgnutls28-dev libgtk2.0-dev libidn11-dev libiso9660-dev libjack-jackd2-dev libkate-dev liblircclient-dev liblivemedia-dev liblua5.2-dev libmad0-dev libmatroska-dev libmodplug-dev libmpcdec-dev libmpeg2-4-dev libmtp-dev libncursesw5-dev libnotify-dev libogg-dev libomxil-bellagio-dev libopus-dev

sudo apt-get install libpulse-dev libqt4-dev libraw1394-dev libresid-builder-dev librsvg2-dev libsamplerate0-dev libschroedinger-dev libsdl-image1.2-dev libsdl1.2-dev libshine-dev libshout3-dev libsidplay2-dev libsmbclient-dev libspeex-dev libspeexdsp-dev libssh2-1-dev libswscale-dev libtag1-dev libtheora-dev libtwolame-dev libudev-dev libupnp-dev

sudo apt-get install libv4l-dev libva-dev libvcdinfo-dev libvdpau-dev libvncserver-dev libvorbis-dev libx11-dev libx264-dev libxcb-composite0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xv0-dev libxcb1-dev libxext-dev libxinerama-dev libxml2-dev libxpm-dev libzvbi-dev lua5.2 oss4-dev pkg-config zlib1g-dev libpng12-dev libtool build-essential autoconf

 

If you try to configure and compile VLC now, you may get an error regarding Libavutils because VLC 2.2.6 do not support libavutils prior to version 55. Congrats, if you get this message, you will have to compile FFMPEG first 🙂

 

3- FFMPEG compilation

We will download ffmpeg version 2.7.7 (Nash) and compile it. You can add more codecs if you want (libmp3lame, x264…).

cd Downloads
wget https://www.ffmpeg.org/releases/ffmpeg-2.7.7.tar.xz
tar -xJf ffmpeg-2.7.7.tar.xz
cd ffmpeg-2.7.7
sudo ./configure –enable-gpl –enable-nonfree –bindir=/usr/local/bin
make
sudo make install

you have time to tidy up the garage and even the time to tidy up the garage of your neighbors… it will take a little while. Once compiled, launch FFmpeg to see libraries version installed:

 

4- VLC media player compilation

ok… we’re finally here:

cd vlc-2.2.6
./bootstrap CFLAGS="-I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/mmal -I/opt/vc/include/interface/vchiq_arm -I/opt/vc/include/IL -I/opt/vc/include/GLES2 -mfloat-abi=hard -mcpu=cortex-a7 -mfpu=neon-vfpv4" CXXFLAGS="-I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/mmal -I/opt/vc/include/interface/vchiq_arm -I/opt/vc/include/IL -mfloat-abi=hard -I/opt/vc/include/GLES2 -mcpu=cortex-a7 -mfpu=neon-vfpv4" LDFLAGS="-L/opt/vc/lib" ./configure –prefix=/usr –enable-omxil –enable-omxil-vout –enable-rpi-omxil –disable-mmal-codec –disable-mmal-vout –enable-gles2


You must not have any error. If vlc configuration is saying that a library is missing, install it. Sometimes I’ve had to install gles2 at this stage.

make -j3

Compilation takes about twenty minutes, so you can now mow the lawn…

sudo make install

Ok, so now, VLC with OpenMax support for hardware acceleration is installed on your Raspberry PI 3 running Raspbian Stretch. Congratulations!
I think a reboot is necessary at this stage to start to play with VLC.
 

5- VLC Configuration

Now open VLC (the one we just compiled! huh!) You can start the program via the menu bar (Sound & Video > VLC media player) or Terminal (with the command vlc). After starting the program, open the settings dialog and change your settings (Tools > Preferences > Video)

Select OpenMAX IL as video output.

 

Now HD video playback is no problem and the CPU is no longer 100%. The only limit is the overlay video. Movies are not played in the VLC’s main window. Only keyboard controls are available (Ctrl+Q to quit).
Don’t forget to configure your raspberry to choose HDMI as audio output if it’s necessary. Open Terminal and run the command sudo raspi-config. go to Advanced Options > A4 Audio > Choose the audio output: 2 Force HDMI.

Ok, we’re done. Hope you will enjoy your videos on Raspberry PI 😉

4 thoughts on “Raspberry PI 3 – Howto compile VLC with hardware acceleration

Leave a Reply

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