gkreidl
Posts: 5249
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Thu Oct 12, 2017 10:40 am

VLC is a great media player but the version from the Raspbian repository does not support the GPU of the RPi and is not able to run high resolution videos. We have to compile our own version to add hardware accelerated video.

Note: This version will display video in an overlay, similar to omxplayer, and not within a window. If you need this you might prefer my omxplayerGUI.

We will have to add quite a number of libraries and tools. Before doing this, you should update your system:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
If you have already installed the VLC version from the repository before you must remove it now and that means every package belonging to it. A default VLC installation will install the following packages:

Code: Select all

vlc libvlc-bin libvlc5 libvlccore8 vlc-bin vlc-data vlc-l10n vlc-plugin-base vlc-plugin-notify vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2 vlc-plugin-video-output vlc-plugin-video-splitter vlc-plugin-visualization
All of them have to be removed before you can go on!

The whole work will be done in a terminal. Open one and run each of the commands shown below.

The first step is to make sure, that we have a number of essential building tools installed:

Code: Select all

sudo apt-get install autopoint pkg-config libtool build-essential autoconf
VLC requires quite a lot of shared libraries. Some may be already installed on your system, but we cannot be sure. To get all of them run:

Code: Select all

sudo apt-get install liba52-0.7.4 libasound2 libass5 libavahi-client3 libavahi-common3 libavc1394-0 libbasicusageenvironment1 libbluray1 libbz2-1.0 libc6 libcairo2 libcddb2 libcdio13 libchromaprint1 libdbus-1-3 libdc1394-22 libdca0 libdirectfb-1.2-9 libdvbpsi10 libdvdnav4 libdvdread4 libebml4v5 libfaad2 libflac8 libfontconfig1 libfreetype6 libfribidi0 libgcc1 libgcrypt20 libglib2.0-0 libgme0 libgnutls30 libgpg-error0 libgroupsock8 libgsm1 libjpeg62-turbo libkate1 liblirc-client0 liblivemedia57 liblua5.2-0 liblzma5 libmad0 libmatroska6v5 libmodplug1 libmp3lame0 libmpcdec6 libmpeg2-4 libmtp9 libncursesw5 libogg0 libopus0 libpng16-16 libpulse0 libraw1394-11 libresid-builder0c2a librsvg2-2 librtmp1 libsamplerate0 libsdl-image1.2 libsdl1.2debian libshine3 libshout3 libsidplay2 libsnappy1v5 libsndio6.1 libspeex1 libspeexdsp1 libssh-gcrypt-4 libssh2-1 libstdc++6 libtag1v5 libtheora0 libtinfo5 libtwolame0 libudev1 libupnp6 libusageenvironment3 libva-drm1 libva-x11-1 libva1 libvcdinfo0 libvorbis0a libvorbisenc2 libvpx4 libwavpack1 libwebp6 libwebpmux2 libx11-6 libx264-148 libx265-95 libxcb-keysyms1 libxcb1 libxml2 libxvidcore4 libzvbi0 zlib1g libgdk-pixbuf2.0-0 libgtk2.0-0 libnotify4 libqt5core5a libqt5gui5 libqt5widgets5 libqt5x11extras5 libxi6 libsmbclient libxext6 libxinerama1 libxpm4 fonts-freefont-ttf libaa1 libcaca0 libegl1-mesa libgl1-mesa-glx libgles1-mesa libgles2-mesa libxcb-shm0 libxcb-xv0 libxcb-randr0 libxcb-composite0
These libraries will enable us to run VLC, but to compile a new version we also have to add the matching development (-dev) packages:

Code: Select all

sudo apt-get install liba52-0.7.4-dev libasound2-dev libass-dev libavahi-client-dev libavc1394-dev libbluray-dev libbz2-dev libc6-dev libcairo2-dev libcddb2-dev libcdio-dev libchromaprint-dev libdbus-1-dev libdc1394-22-dev libdca-dev libdirectfb-dev libdvbpsi-dev libdvdnav-dev libdvdread-dev libebml-dev libfaad-dev libflac-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libgcc-6-dev libgcrypt20-dev libglib2.0-dev libgme-dev libgnutls28-dev libgpg-error-dev libgsm1-dev libjpeg62-turbo-dev libkate-dev liblircclient-dev liblivemedia-dev liblua5.2-dev liblzma-dev libmad0-dev libmatroska-dev libmodplug-dev libmp3lame-dev libmpcdec-dev libmpeg2-4-dev libmtp-dev libncursesw5-dev libogg-dev libopus-dev libpng-dev libpulse-dev libraw1394-dev libresid-builder-dev librsvg2-dev librtmp-dev libsamplerate0-dev libsdl-image1.2-dev libsdl1.2-dev libshine-dev libshout3-dev libsidplay2-dev libsnappy-dev libsndio-dev libspeex-dev libspeexdsp-dev libssh-gcrypt-dev libssh2-1-dev libstdc++-6-dev libtag1-dev libtheora-dev libtinfo-dev libtwolame-dev libudev-dev libupnp6-dev libva-dev libvcdinfo-dev libvorbis-dev libvpx-dev libwavpack-dev libwebp-dev libx11-dev libx264-dev libx265-dev libxcb-keysyms1-dev libxcb1-dev libxml2-dev libxvidcore-dev libzvbi-dev zlib1g-dev libgdk-pixbuf2.0-dev libgtk2.0-dev libnotify-dev libqt5x11extras5-dev libxi-dev libsmbclient-dev libxext-dev libxinerama-dev libxpm-dev libaa1-dev libcaca-dev libegl1-mesa-dev libgles1-mesa-dev libgles2-mesa-dev libxcb-shm0-dev libxcb-xv0-dev libxcb-randr0-dev libxcb-composite0-dev
Now we can start the real work. We download the current stable VLC sources:

Code: Select all

wget http://download.videolan.org/vlc/2.2.6/vlc-2.2.6.tar.xz
This version won't compile on Stretch without a patch which we will download now and apply later:

Code: Select all

wget http://www.linuxfromscratch.org/patches/blfs/svn/vlc-2.2.6-ffmpeg3-1.patch
Now it's time to extract the VLC source package

Code: Select all

tar -xJf vlc-2.2.6.tar.xz
and to enter the source folder

Code: Select all

cd vlc-2.2.6
The first command will adapt the sources to the Raspbian Stretch system:

Code: Select all

./bootstrap
Now it's time to add the patch we have downloaded earlier, which requires two commands:

Code: Select all

patch -Np1 -i ../vlc-2.2.6-ffmpeg3-1.patch

Code: Select all

sed -i 's/error-implicit-function-declaration//' configure
We will now set and export some enviroment variables for configuration and compilation:

Code: Select all

export 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 -I/opt/vc/include/EGL -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 -I/opt/vc/include/EGL -mcpu=cortex-a7 -mfpu=neon-vfpv4" LDFLAGS="-L/opt/vc/lib"
We will now run the configuration script with some RPi specific options:

Code: Select all

./configure --prefix=/usr --enable-omxil --enable-omxil-vout --enable-rpi-omxil --disable-mmal-codec --disable-mmal-vout --enable-gles2
This will take a few minutes and if it doesn't break with some error message, we are ready for compilation. But before you can go on, you should close as many applications as possible, which includes the web browser showing this tutorial ((especially if it is chromium). We will run the compilation on 3 cores and it will need a lot of free memory.

Code: Select all

make -j3
How much time the compilation process needs, depends on your mass storage system. Running from HDD it will take less than 30 minutes, but it may take much longer on slower SD cards.

If the compilation ends without an error (ignore all the warnings), we can install the new VLC version:

Code: Select all

sudo make install
This will also take a few minutes.

Note: Due to the way the "Raspberry Pi Desktop" (modifications) handle default desktop files, VLC will not appear immediately within the start menu (it usually needs a reboot). For a first test you can start it from the terminal by just typing "vlc".

After starting VLC for the first time, change the following options:
Settings, simple, Audio: make sure, ALSA and bcm2835 are selected
Settings, simple, Video, output: select "OpenMAX IL video output"
VLC will remember these settings.

Video is displayed in an overlay, similar to omxplayer, not inside a window. While playing, you can only control it from the keyboard.

On both RPi2 and 3 VLC will play up to 1080p30 video. It did not play some 1080p60 videos which are playing well with omxplayer.

If audio is jerky and out of sync check, if pulseaudio is installed on your system and remove or disable it.

SD video and some 720p video (RPi3) can also be played using software codecs, if you select SDL video output.

To remove VLC again, run

Code: Select all

sudo make uninstall
from within the vlc-2.2.6 directory.

Do not try to install the repository version without uninstalling the compiled version first!

Important note: I do not consider this version (and older ones) completely stable. It definitely crashes when I stop playing recorded TS streams typing "s". Live TV stream are playing well (same format).

Thanks to cjan who discovered the patch and showed how to apply it.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

cjan
Posts: 460
Joined: Sun May 06, 2012 12:00 am

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Fri Oct 13, 2017 9:38 am

a bit off topic?

want edit a Makefile to compile vlc-git (today had some mmal patchs), what is right sequence?
1. ./bootstrap
2. edit Makefile
3. patch some file
4. ./configure.....

or any other sequence, thanks.

gkreidl
Posts: 5249
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Fri Oct 13, 2017 10:31 am

cjan wrote:
Fri Oct 13, 2017 9:38 am
a bit off topic?

want edit a Makefile to compile vlc-git (today had some mmal patchs), what is right sequence?
1. ./bootstrap
2. edit Makefile
3. patch some file
4. ./configure.....

or any other sequence, thanks.
I never had much luck with any github version, but two things come to my mind:
1) I'm not sure if the patch can be applied to this release.
2) AFAIK, the Makefiles are created by the configure script.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

cjan
Posts: 460
Joined: Sun May 06, 2012 12:00 am

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Fri Oct 13, 2017 10:50 am

gkreidl wrote:
Fri Oct 13, 2017 10:31 am
cjan wrote:
Fri Oct 13, 2017 9:38 am
a bit off topic?

want edit a Makefile to compile vlc-git (today had some mmal patchs), what is right sequence?
1. ./bootstrap
2. edit Makefile
3. patch some file
4. ./configure.....

or any other sequence, thanks.
I never had much luck with any github version, but two things come to my mind:
1) I'm not sure if the patch can be applied to this release.
2) AFAIK, the Makefiles are created by the configure script.
sorry, my poor english.

try to compile vlc-3.git, no need to ffmpeg-patch.
had some error -> recipe for target 'libmmal_vout_plugin_la-vout.lo' failed
solution is here, down below the page.
https://forum.videolan.org/viewtopic.php?t=135341

only ask what sequence to edit Makefile? and this Makefile not created by the configure script.

anotherknight
Posts: 1
Joined: Wed Jan 04, 2017 7:40 pm

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Fri Oct 20, 2017 1:58 am

"We will now set and export some environment variables for configuration and compilation"

If I remove "-mcpu=cortex-a7 -mfpu=neon-vfpv4" from the environment variables, will the ./configure still pull the correct information from my system? I was trying to shortcut the process because I was compiling VLC for my RPi Zero W and removed those two. It compiled and installed successfully, but when I play a DVD it stutters slightly and I was curious if it was because I didn't indicate the mcpu and mfpu which made it un-optimized. The only reason I'm suspicious is because it will play 1080p files off of a USB but can't play a DVD. Anyone out there with success stories for RPi Zero W?

gkreidl
Posts: 5249
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Fri Oct 20, 2017 7:49 am

anotherknight wrote:
Fri Oct 20, 2017 1:58 am
"We will now set and export some environment variables for configuration and compilation"

If I remove "-mcpu=cortex-a7 -mfpu=neon-vfpv4" from the environment variables, will the ./configure still pull the correct information from my system? I was trying to shortcut the process because I was compiling VLC for my RPi Zero W and removed those two. It compiled and installed successfully, but when I play a DVD it stutters slightly and I was curious if it was because I didn't indicate the mcpu and mfpu which made it un-optimized. The only reason I'm suspicious is because it will play 1080p files off of a USB but can't play a DVD. Anyone out there with success stories for RPi Zero W?
I don't recommend using VLC (even HW accelerated) on a first generation RPi or Zero. Long time ago I created a version for them (and published a tutorial), but it didn't work reliably for full HD videos, for example. The software overhead is much bigger than with omxplayer.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

mikerosenthal
Posts: 1
Joined: Sat Oct 21, 2017 2:51 pm

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Sat Oct 21, 2017 2:55 pm

Thank you so much for this tutorial. It's exactly what I needed! I ran through each step and got no errors anywhere along the way (a first for me...).

However, when I got to this:
Settings, simple, Video, output: select "OpenMAX IL video output"
I don't have OpenMax IL in my dropdown of output choices.

These exist in my decoder list when I query it from a command line:
omxil Audio/Video decoder (using OpenMAX IL)
omxil Video encoder (using OpenMAX IL)

So I think it must be installed, but I can't seem to select it in VLC.

Any thoughts on what I might be doing wrong? Or any tips on how to force VLC to use this decoder from a command line instead of in the Preferences?

-Mike

gkreidl
Posts: 5249
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Tutorial: Compile VLC with HW acceleration - Stretch, RPi 2/3

Sat Oct 21, 2017 8:48 pm

mikerosenthal wrote:
Sat Oct 21, 2017 2:55 pm
Thank you so much for this tutorial. It's exactly what I needed! I ran through each step and got no errors anywhere along the way (a first for me...).

However, when I got to this:
Settings, simple, Video, output: select "OpenMAX IL video output"
I don't have OpenMax IL in my dropdown of output choices.

These exist in my decoder list when I query it from a command line:
omxil Audio/Video decoder (using OpenMAX IL)
omxil Video encoder (using OpenMAX IL)

So I think it must be installed, but I can't seem to select it in VLC.

Any thoughts on what I might be doing wrong? Or any tips on how to force VLC to use this decoder from a command line instead of in the Preferences?

-Mike
Can you show me your list of output devices (snapshot)?
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 19 guests