Welcome to the Serviio Wiki. This space is intended to store community knowledge about Serviio and it's various setups. You can post and update working installation tutorials, startup scripts and similar.

Building FFmpeg on Linux

Overview

This guide aims to provide the details on building the latest version of FFmpeg from source on Linux (as well as some other important dependencies) with the aim to provide the best support for Serviio; it is adapted from this guide and assumes that APT is the package manager of choice. This can likely be adapted to build FFmpeg on Windows using Cygwin or MinGW.

Updates

2nd June 2013

*Updated to cover x264 requirements in Serviio 1.3
*Moved libvpx to optional section at the end
*Removed yasm from the initial apt-get install list seeing as its now built from source

26th March 2013

*Update to cover libass and yasm 1.2 for Serviio 1.2

Build Procedure

The below process is written by Serviio users. It will replace all existing libraries and tools with the new ones.

You can also follow a guide supplied by FFmpeg developers themselves, which will instead build ffmpeg in an isolated location. If you do this, you will need to use the ffmpeg.location system property to tell Serviio which ffmpeg binary to use e.g. add

-Dffmpeg.location=/home/username/ffmpeg/ffmpeg

to bin/serviio.sh.

Remove Existing Versions of Packages

The first step to ensuring a good install of FFmpeg is to remove any exisiting installations of the libraries and utilities which will be built from source throughout this guide to ensure that there are no conflicts which can lead to problems which are difficult to diagnose:

On some Linux systems (i.e. Ubuntu), removing librtmp0 will cause half the system to uninstall and do irreparable damage. If you get asked to remove ~500MB of software when running the command above, remove librtmp0 from the command above and re-run it.

sudo apt-get remove ffmpeg x264 libx264-dev libvpx-dev librtmp0 librtmp-dev

Install Essential Build Tools and Libraries

There are several tools and libraries required to build the software in this guide. Much of this software should be available in the repositories for your Linux distribution and can be installed this way:

sudo apt-get update
sudo apt-get install build-essential checkinstall git libfaac-dev libjack-jackd2-dev \
  libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev \
  libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev texi2html zlib1g-dev \
  libssl1.0.0 libssl-dev libxvidcore-dev libxvidcore4 libass-dev

Yasm

Yasm is an assembler and is recommended for x264 and FFmpeg. Version 1.2 is required to build the latest x264 and FFmpeg sources.

cd ~
mkdir src
cd src
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no \
  --deldoc=yes --fstrans=no --default

Build and Install x264

x264 is one of the most popular implementations of the H.264 video compression algorithm which is used to compress video on blu-ray discs and is often the codec of choice for distributing high definition content on the internet. FFmpeg supports using the x264 library to compress video content.

x264 is required for streaming to iOS devices using MediaBrowser, and for the Enhanced profile option in ServiiGo.

To acquire and build x264, perform the following:

cd ~/src
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
    awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
    --fstrans=no --default

NOTE: New version of x264 contains by default support of OpenCL. If not installed or without sense (example Ubuntu 12.04LTS on VMWare) add to configure additional option –disable-opencl.

./configure --disable-opencl

Without this option ffmpeg could not be configured (ERROR: libx264 not found).

Build and Install librtmp

librtmp provides support for the RTMP content streaming protocol developed by Adobe and commonly used to distribute content to flash video players on the web. FFmpeg supports using the librtmp library to stream content from RTMP sources. To acquire and build librtmp, perform the following:

cd ~/src
git clone git://git.ffmpeg.org/rtmpdump
cd rtmpdump
make SYS=posix
sudo checkinstall --pkgname=rtmpdump --pkgversion="2:$(date +%Y%m%d%H%M)-git" --backup=no \
    --deldoc=yes --fstrans=no --default

Build and Install FFmpeg

It is now time to build FFmpeg:

This guide uses latest FFmpeg source, Serviio is tailored to work with a certain version though - the source can be downloaded at http://www.serviio.org/download
There have been a number of reports that you must use the version of FFmpeg source that is provided on the Serviio download page on Ubuntu if you want Http Live Streaming to work (required for MediaBrowser iOS and ServiiGo Enhanced profiles).

cd ~/src

To use the lastest version of ffmpeg

git clone --depth 1 git://git.videolan.org/ffmpeg

Else, to use the version that Serviio ships with

wget http://download.serviio.org/opensource/ffmpeg-N-54096-ge41bf19.tar.gz
tar xvf ffmpeg-N-54096-ge41bf19.tar.gz

Then

cd ffmpeg
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
    --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 \
    --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-librtmp \
    --enable-libxvid --enable-libass
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="99:$(date +%Y%m%d%H%M)-git" --backup=no \
  --deldoc=yes --fstrans=no --default

Optional Libraries

Additional libraries that aren't used by Serviio. You may want them if you use other software that uses ffmpeg.

Build and Install libvpx

libvpx is an emerging open video compression library which is gaining popularity for distributing high definition video content on the internet. FFmpeg supports using the libvpx library to compress video content (although Serviio does not). To acquire and build libvpx, perform the following:

cd ~/src
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \
    --deldoc=yes --fstrans=no --default

Now rebuild ffmpeg by following the above steps except add

 --enable-libvpx

to the long ./configure command

Add Additional Support to x264 (Lavf)

Now that FFmpeg is built and installed, it is a good idea to re-configure and rebuild x264 to add additional functionality; see here for more information:

sudo apt-get remove x264
cd ~/src/x264
rm *.deb
make distclean
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
    awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
    --fstrans=no --default

Conclusion

At this point, FFmpeg is installed and Serviio should now use the newly built version. Please visit the forum if you need assistance with this guide.

Note

If you receive error:
ffmpeg: error while loading shared libraries: librtmp.so.1: cannot open shared object file: No such file or directory

Then do as follows

sudo nano /etc/ld.so.conf

Add the following line to the file

include /usr/local/lib/

Save the file

Now enter

ldconfig

Now reboot machine

Print/export