Changes between Version 9 and Version 10 of CompilationGuide/RaspberryPi
- Timestamp:
- May 3, 2014, 2:48:06 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CompilationGuide/RaspberryPi
v9 v10 1 1 [[PageOutline(1-100,Contents)]] 2 2 3 = Introduction=3 == Introduction == 4 4 [[Image(Raspberry_Pi_600x400.jpg)]] 5 5 … … 12 12 (TODO: The comparison table of different ways to compile FFmpeg for Raspbian) 13 13 14 = Cross-compiling FFmpeg for Raspbian=14 == Cross-compiling FFmpeg for Raspbian == 15 15 We will describe here the method to cross-compile FFmpeg for Raspbian. First, we will prepare our build environment. Then we will show how to compile common additional libraries that FFmpeg might use (for example libx264). And finally we'll show how to compile the latest (and greatest) version of FFmpeg that will run on Raspbian. 16 16 17 == Preparing the environment==17 === Preparing the environment === 18 18 To successfully cross-compile things, we need something called a [http://en.wikipedia.org/wiki/Toolchain Toolchain] (a set of programming tools that are used to create another computer program). We need a toolchain that will be able to produce binaries, specific to the ARM architecture and the Raspbian itself. Now, there are a lot of already created toolchains for Raspbian and if you like to speed up things, you could just go find one of them and install it, but be aware that whatever toolchain you download, it might not be optimized for both your own operating system and Raspbian. If you compile your own toolchain, you can be sure that you'll be able to use all the available optimizations that your operating system and your Raspbian support. 19 19 20 20 The [http://crosstool-ng.org/ crosstool-ng] is a tool used to create a custom toolchain. We'll use it to create our own toolchain which we can then use to compile anything we want for the Raspbian. So, let's prepare everything to first build our toolchain. 21 21 22 === Building the crosstool-ng===22 ==== Building the crosstool-ng ==== 23 23 The following section is mostly inspired by [http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/ How to build a cross compiler for your Raspberry Pi]. 24 24 … … 38 38 Although, the error complained about "makeinfo", it appears that, in Debian, this package is named "texinfo". Also consider installing texi2html package. 39 39 40 === Building the toolchain===40 ==== Building the toolchain ==== 41 41 Now that we built crosstool-ng, we can build our RPi toolchain. 42 42 … … 79 79 }}} 80 80 81 === Quick test of the toolchain===81 ==== Quick test of the toolchain ==== 82 82 Let's make a quick sanity check of our ARM compiler: 83 83 … … 99 99 Copy the "test" binary to your RPi and run it. It should display a familiar "Hello, world!" text. 100 100 101 == Compiling additional libraries needed for FFmpeg==101 === Compiling additional libraries needed for FFmpeg === 102 102 This section will describe how to compile some common libraries that are usually used by FFmpeg, like libx264 or libaacplus, etc. 103 103 104 === Compiling libaacplus===104 ==== Compiling libaacplus ==== 105 105 {{{ 106 106 cd /my/path/where/i/keep/my/source/code … … 124 124 That way you are telling the compiler where are the dependencies, that you also compiled for RPi, located, in order to successfully compile that "other library" too. 125 125 126 === Compiling libx264===126 ==== Compiling libx264 ==== 127 127 {{{ 128 128 cd /my/path/where/i/keep/my/source/code … … 136 136 Note that we use CCPREFIX environment variable here, to specify the prefix of all the tools in a toolchain, to be used for this build (it instructs the shell not to call cc, gcc, g++ and other standard tools, but rather to call /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-cc, /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc, /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++, etc that will build ARM binaries and libraries). 137 137 138 === Compiling ALSA library===138 ==== Compiling ALSA library ==== 139 139 {{{ 140 140 cd /my/path/where/i/keep/my/source/code … … 147 147 }}} 148 148 149 == Compiling FFmpeg==149 === Compiling FFmpeg === 150 150 This part is the same for all the subsequent examples: 151 151 {{{ … … 155 155 }}} 156 156 157 === Basic FFmpeg, without additional libraries===157 ==== Basic FFmpeg, without additional libraries ==== 158 158 {{{ 159 159 ./configure --enable-cross-compile --cross-prefix=${CCPREFIX} --arch=armel --target-os=linux --prefix=/my/path/were/i/keep/built/arm/stuff … … 162 162 }}} 163 163 164 === FFmpeg with libaacplus, libx264 and alsa-lib===164 ==== FFmpeg with libaacplus, libx264 and alsa-lib ==== 165 165 {{{ 166 166 ./configure --enable-cross-compile --cross-prefix=${CCPREFIX} --arch=armel --target-os=linux --prefix=/my/path/were/i/keep/built/arm/stuff --enable-gpl --enable-libx264 --enable-nonfree --enable-libaacplus --extra-cflags="-I/my/path/were/i/keep/built/arm/stuff/include" --extra-ldflags="-L/my/path/were/i/keep/built/arm/stuff/lib" --extra-libs=-ldl … … 174 174 }}} 175 175 176 = Conclusion=176 == Conclusion == 177 177 After you've built your FFmpeg for RPi, copy `ffmpeg`, `ffplay` and `ffserver` binaries from "/my/path/were/i/keep/built/arm/stuff/bin/" to your Raspberry Pi and try it to see how it works :) 178 178
