Basic instructions (provided you've set up your toolchain and downloaded, untar'd everything)
configure fdk_aac and build
CCPREFIX="/opt/tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi-"
CC="arm-bcm2708hardfp-linux-gnueabi-gcc"
CFLAGS="-O3 -march=armv6zk -mfpu=vfp -mfloat-abi=hard"
./configure --host=arm-linux --prefix=/home/david/built_ffmpeg/ --enable-static --disable-shared
make -j$(nproc) && make install
configure x264 and build
./configure --host=arm-linux --enable-static --cross-prefix=${CCPREFIX} --prefix=/home/david/built_ffmpeg/ --extra-cflags='-O3 -march=armv6zk -mfpu=vfp -mfloat-abi=hard' --extra-ldflags='-O3 -march=armv6zk -mfpu=vfp -mfloat-abi=hard'
make -j$(nproc) && make install
configure and build ffmpeg
(Note: I disable everything but libx264 and libfdk_aac because that's all I need)
./configure --enable-cross-compile --cross-prefix=${CCPREFIX} --arch=armel --target-os=linux --prefix=/home/david/built_ffmpeg/ \
--disable-all \
--enable-gpl \
--enable-libx264 \
--enable-nonfree \
--enable-libfdk_aac \
--extra-cflags="-I/home/david/built_ffmpeg/include -O3 -march=armv6zk -mfpu=vfp -mfloat-abi=hard" \
--extra-ldflags="-L/home/david/built_ffmpeg/lib" \
--extra-libs=-ldl
make -j$(nproc) && make install
Clearly replacing "/home/david/built_ffmpeg" for your prefix
Note: these cflags don't seem to change cpu load.
Troubleshooting:
If you are getting "No valid C compiler found", but the toolchain is in your path and on your CCPREFIX, then most likely you are missing some libraries to use it (the toolchain uses shared libraries, which you might not have)
Run:
echo "int main(){0;}" | arm-bcm2708hardfp-linux-gnueabi-gcc -x c -
To test your toolchain. It shouldn't work, and will tell you which library you are missing. Install it and try again.
If you are trying to compile ffmpeg with x264 and you've built it with --enable-static you'll likely get the error "libx264 not found" ( just like this ), even though the cflags, ldflags and prefix are all OK.
The problem is that (as you can see in your config.log) you don't have some OpenGL libraries.
The solution is on the next post ( here ) and tells you to add these flags
--disable-opencl \ --disable-avs \ --disable-cli \ --disable-ffms \ --disable-gpac \ --disable-lavf \ --disable-swscale
If you are trying to build the alsa lib and get "configure: error: C compiler cannot create executables" you need to set the CC environment variable:
CC="arm-bcm2708hardfp-linux-gnueabi-gcc" ./configure --host=arm-linux --prefix=YOUR_PREFIXIf you get an error saying it can’t find arm-linux-gnueabihf/python2.7/pyconfig.h you can add
--disable-python
to the configure flags (or get the relevant files from https://packages.debian.org/sid/armhf/libpython2.7-dev/filelist )This is how I stream to my nginx-rtmp server.
raspivid -n -vs -ih -pf high -t 0 -ISO 800 -ex fixedfps -w 1280 -h 720 -fps $fps -g $((2*fps)) -b $bw -o - \
| ../ffmpeg \
-framerate $fps -r $fps -i - \
-f alsa -ar $ar -ac 1 -itsoffset 10 -i btheadset \
-c:v copy -r $fps -vsync drop \
-c:a libfdk_aac -afterburner 0 -async 1 -ar 48000 -ac 1 -b:a 48k \
-tune zerolatency -bufsize 100k \
-rtmp_buffer 100 -rtmp_live live \
-f flv rtmp://$HOST:1935/$STREAM/movie
The CPU load is ~20%.
If I only encode audio, the CPU load is about ~13%.