Skip to content

Instantly share code, notes, and snippets.

@nathandarnell
Created July 4, 2014 18:59
Show Gist options
  • Save nathandarnell/fb927d73990ecd6a8e59 to your computer and use it in GitHub Desktop.
Save nathandarnell/fb927d73990ecd6a8e59 to your computer and use it in GitHub Desktop.
CROSS COMPILING FFMPEG FOR THE RASPBERRY PI
This is how to cross compile ffmpeg with x264 support for the Raspberry Pi on a Debian 6 64bit host.
Build environment
First set up your build environment by installing the build-essential and git packages from the Debian repo and cloning the debian cross compiling toolchain from GitHub:
$ sudo apt-get install build-essential git-core
$ sudo git clone https://github.com/raspberrypi/tools.git /opt/tools
Next, setup the CFLAGS environment variable with the correct options for the Broadcom BCM2835 SoC and create a variable to point to the toolchain binaries we downloaded in the previous step.
$ export CFLAGS="-O2 -pipe -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -w"
$ export CCPREFIX="/opt/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi-"
Build ffmpeg
Now we have everything we need we can download the source code and start building.
Start with the ffmpeg source code
$ git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
Now the x264 libraries which will download in to the main ffmpeg source tree to keep things nice and tidy
$ cd ffmpeg
$ git clone git://git.videolan.org/x264
Now to actually compile the source code:
x264
$ cd x264
$ ./configure --host=arm-linux --cross-prefix=${CCPREFIX} --enable-static
$ make
$ cd ..
ffmpeg
$ ./configure --enable-cross-compile --cross-prefix=${CCPREFIX} \
--arch=armel --target-os=linux --enable-gpl --enable-libx264 \
--extra-cflags="-Ix264/" --extra-ldflags="-Lx264/"
$ make
If all has gone well you should be left with a ffmpeg binary which you can transfer to your Raspberry Pi.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment