diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2011-07-13 14:08:14 +0000 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2011-07-13 14:09:36 +0000 |
commit | 45773eb2659fae5029e6e42a5f0a7803224f6e2b (patch) | |
tree | 37352e6d71483a867c4e4658ddb7b6c0bb785bd5 | |
parent | 0a0431e1d7533f60f26e74a4eb3c1eec0e6189d5 (diff) | |
download | mmtest-45773eb2659fae5029e6e42a5f0a7803224f6e2b.tar.gz |
Add ffmpeg builder
Allow using it
-rwxr-xr-x | creator/build-ffmpeg | 86 | ||||
-rwxr-xr-x | creator/create-testfiles | 34 | ||||
-rw-r--r-- | creator/patches/faac/faac-1.28-compile.patch | 17 | ||||
-rw-r--r-- | creator/patches/flac/flac-1.2.1-gcc-4.3.patch | 10 |
4 files changed, 131 insertions, 16 deletions
diff --git a/creator/build-ffmpeg b/creator/build-ffmpeg new file mode 100755 index 0000000..cf4a07e --- /dev/null +++ b/creator/build-ffmpeg @@ -0,0 +1,86 @@ +#!/bin/bash -e +# This script builds a version of ffmpeg that is compatible with +# create-testfiles (support for all relevant codecs, current +# version). + +FFMPEGDIR="`mktemp -d /tmp/ffmpegbuildXXXXXX`" +if [ -z "$FFMPEGDIR" ]; then + echo "If you care about predictable symlink attacks, you should really install mktemp" 1>&2 + FFMPEGDIR="/tmp/ffmpegbuild.$$" + mkdir -p "$FFMPEGDIR" +fi + +SRCDIR="`dirname $0`" +[ "$SRCDIR" = "." ] && SRCDIR="`pwd`" + +cd "$FFMPEGDIR" +git clone git://review.webmproject.org/libvpx.git +git clone git://git.videolan.org/x264.git +wget http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz +wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz +wget http://downloads.xiph.org/releases/theora/libtheora-1.2.0alpha1.tar.xz +wget http://switch.dl.sourceforge.net/project/lame/lame/3.98.4/lame-3.98.4.tar.gz +wget http://ignum.dl.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.bz2 +wget http://garr.dl.sourceforge.net/project/flac/flac-src/flac-1.2.1-src/flac-1.2.1.tar.gz +wget http://ffmpeg.org/releases/ffmpeg-0.8.tar.bz2 +tar xf libogg-1.2.2.tar.gz +tar xf libvorbis-1.3.2.tar.gz +tar xf libtheora-1.2.0alpha1.tar.xz +tar xf lame-3.98.4.tar.gz +tar xf faac-1.28.tar.bz2 +tar xf flac-1.2.1.tar.gz +tar xf ffmpeg-0.8.tar.bz2 + +CPUS=`getconf _NPROCESSORS_ONLN` +[ -z "$CPUS" ] && CPUS=`cat /proc/cpuinfo |grep processor |wc -l` +[ -z "$CPUS" ] && CPUS=2 + +export CFLAGS="-O2 -fomit-frame-pointer -fweb -frename-registers -ffast-math -Wl,-O2 -I\"$FFMPEGDIR\"/include -L\"$FFMPEGDIR\"/lib" +export CXXFLAGS="$CFLAGS" +export LDFLAGS="$CFLAGS" +export PKG_CONFIG_PATH="$FFMPEGDIR"/lib/pkgconfig:"$PKG_CONFIG_PATH" + +for i in libvpx x264 libvorbis libogg libtheora lame faac flac; do + echo $i + cd $i* + if [ -d "$SRCDIR"/patches/$i ]; then + for j in "$SRCDIR"/patches/$i/*; do + patch -p1 <$j + done + fi + if [ "$i" = "libvpx" ]; then + FLAGS="--disable-shared" + elif [ "$i" = "libtheora" ]; then + FLAGS="--enable-static --disable-shared --disable-spec" + else + FLAGS="--enable-static --disable-shared" + fi + ./configure --prefix="$FFMPEGDIR" $FLAGS + make -j$CPUS + make install + cd .. +done + +cd ffmpeg-* +./configure \ + --prefix="$FFMPEGDIR" \ + --enable-static \ + --enable-pthreads \ + --enable-gpl \ + --enable-nonfree \ + --enable-avfilter \ + --enable-libtheora \ + --enable-libvpx \ + --enable-libx264 \ + --enable-libvorbis \ + --enable-libfaac \ + --enable-libmp3lame \ + --extra-cflags="$CFLAGS" \ + --extra-ldflags="$CFLAGS" +make -j$CPUS +make install +cd .. + +echo +echo Use +echo FFMPEG=\""$FFMPEGDIR"/bin/ffmpeg\" \""$SRCDIR/create-testfiles"\" YourContent.mp4 diff --git a/creator/create-testfiles b/creator/create-testfiles index 7aae63d..51867ae 100755 --- a/creator/create-testfiles +++ b/creator/create-testfiles @@ -6,12 +6,14 @@ # List of supported codecs: # http://developer.android.com/guide/appendix/media-formats.html +[ -z "$FFMPEG" ] && FFMPEG=`which ffmpeg` + if [ "$#" -lt 1 ]; then echo "Usage: $0 InputFile" exit 1 fi -if ! which ffmpeg &>/dev/null; then - echo "Install ffmpeg >= 0.8 and put it in your PATH" +if ! [ -x "$FFMPEG" ]; then + echo "Install ffmpeg >= 0.8 and put it in your PATH (or set FFMPEG)" exit 2 fi if ! which mplayer &>/dev/null; then @@ -30,9 +32,9 @@ IN="$1" # ================ # AAC audio # Maximum supported - 160k, 48k sample rate -ffmpeg -y -i "$IN" -vn -acodec libfaac -ab 160k -ar 48000 -ac 2 test-AAC-Stereo-96k.m4a +"$FFMPEG" -y -i "$IN" -vn -acodec libfaac -ab 160k -ar 48000 -ac 2 test-AAC-Stereo-96k.m4a # Minimum supported - 8k sample rate, low bitrate -ffmpeg -y -i "$IN" -vn -acodec libfaac -strict experimental -ab 32k -ar 8000 -ac 1 test-AAC-Mono-8k.m4a +"$FFMPEG" -y -i "$IN" -vn -acodec libfaac -strict experimental -ab 32k -ar 8000 -ac 1 test-AAC-Mono-8k.m4a # FIXME we probably want to add an He-AACv2 sample when a free encoder # becomes available # Non-free encoder for testing could be built with @@ -42,15 +44,15 @@ ffmpeg -y -i "$IN" -vn -acodec libfaac -strict experimental -ab 32k -ar 8000 -ac # Done after WAV because ffmpeg doesn't support AMR directly # FLAC (Android 3.1+) -ffmpeg -y -i "$IN" -vn -acodec flac -ac 2 -ar 44100 test-flac.flac +"$FFMPEG" -y -i "$IN" -vn -acodec flac -ac 2 -ar 44100 test-flac.flac # MP3 -ffmpeg -y -i "$IN" -vn -acodec libmp3lame -ab 64k test-MP3.mp3 +"$FFMPEG" -y -i "$IN" -vn -acodec libmp3lame -ab 64k test-MP3.mp3 # We can't create a Midi file from a recording, so we're skipping this # Ogg Vorbis -ffmpeg -y -i "$IN" -vn -acodec libvorbis -f ogg -ab 64k test-Vorbis.ogg +"$FFMPEG" -y -i "$IN" -vn -acodec libvorbis -f ogg -ab 64k test-Vorbis.ogg # PCM/WAVE mplayer "$IN" -benchmark -vc null -vo null -ao pcm:fast:waveheader:file=test-PCM.wav @@ -73,32 +75,32 @@ sox -S test-PCM16.wav -c 1 -r 8000 -t amr-nb test-AMR-NB.3gp # == Video-only == # ================ # H.263 -ffmpeg -y -i "$IN" -vcodec h263 -s cif -r 25 -vb 768000 -an -f 3gp test-H.263.3gp +"$FFMPEG" -y -i "$IN" -vcodec h263 -s cif -r 25 -vb 768000 -an -f 3gp test-H.263.3gp # H.264 AVC Baseline Profile -ffmpeg -y -i "$IN" -vcodec libx264 -vb 1024000 -vpre libx264-baseline -an -f mp4 test-H.264.m4v +"$FFMPEG" -y -i "$IN" -vcodec libx264 -vb 1024000 -vpre libx264-baseline -an -f mp4 test-H.264.m4v # MPEG-4 SP -ffmpeg -y -i "$IN" -vcodec mpeg4 -vb 768000 -an -f mp4 test-MPEG4_SP.mp4 +"$FFMPEG" -y -i "$IN" -vcodec mpeg4 -vb 768000 -an -f mp4 test-MPEG4_SP.mp4 # VP8 -ffmpeg -y -i "$IN" -vcodec libvpx -vb 768000 -an -f webm test-VP8.webm +"$FFMPEG" -y -i "$IN" -vcodec libvpx -vb 768000 -an -f webm test-VP8.webm # ========================== # == Combined Audio/Video == # ========================== # H.263 + AAC in a 3gp container -ffmpeg -y -i "$IN" -vcodec h263 -s cif -r 25 -vb 768000 -acodec libfaac -ac 1 -ar 8000 -ab 32000 -f 3gp test-H.263-AAC.3gp +"$FFMPEG" -y -i "$IN" -vcodec h263 -s cif -r 25 -vb 768000 -acodec libfaac -ac 1 -ar 8000 -ab 32000 -f 3gp test-H.263-AAC.3gp # H.264 AVC Baseline + AAC in an mp4 container -ffmpeg -y -i "$IN" -vcodec libx264 -vb 1024000 -vpre libx264-baseline -acodec aac -strict experimental -ab 96000 -f mp4 test-H.264-AAC.mp4 +"$FFMPEG" -y -i "$IN" -vcodec libx264 -vb 1024000 -vpre libx264-baseline -acodec aac -strict experimental -ab 96000 -f mp4 test-H.264-AAC.mp4 # Same thing at a much higher resolution and bitrate -ffmpeg -y -i "$IN" -s hd1080 -vcodec libx264 -vb 2048000 -vpre libx264-baseline -acodec aac -strict experimental -ab 96000 -f mp4 test-H.264-AAC-HD.mp4 +"$FFMPEG" -y -i "$IN" -s hd1080 -vcodec libx264 -vb 2048000 -vpre libx264-baseline -acodec aac -strict experimental -ab 96000 -f mp4 test-H.264-AAC-HD.mp4 # MPEG-4 SP + MP3 in an mp4 container -ffmpeg -y -i "$IN" -vcodec mpeg4 -vb 768000 -acodec libmp3lame -ab 64000 -f mp4 test-MPEG4-MP3.mp4 +"$FFMPEG" -y -i "$IN" -vcodec mpeg4 -vb 768000 -acodec libmp3lame -ab 64000 -f mp4 test-MPEG4-MP3.mp4 # VP8 + Vorbis in a WebM container (Android 2.3.3+) -ffmpeg -y -i "$IN" -vcodec libvpx -vb 1024000 -vpre libvpx-360p -f webm -acodec libvorbis -ab 48000 test-VP8-Vorbis.webm +"$FFMPEG" -y -i "$IN" -vcodec libvpx -vb 1024000 -vpre libvpx-360p -f webm -acodec libvorbis -ab 48000 test-VP8-Vorbis.webm diff --git a/creator/patches/faac/faac-1.28-compile.patch b/creator/patches/faac/faac-1.28-compile.patch new file mode 100644 index 0000000..cc715ab --- /dev/null +++ b/creator/patches/faac/faac-1.28-compile.patch @@ -0,0 +1,17 @@ +--- faac-1.28/common/mp4v2/mpeg4ip.h.ark 2011-06-07 19:26:04.680615623 +0200 ++++ faac-1.28/common/mp4v2/mpeg4ip.h 2011-06-07 19:26:12.087281975 +0200 +@@ -120,14 +120,6 @@ + #endif + #include <sys/param.h> + +-#ifdef __cplusplus +-extern "C" { +-#endif +-char *strcasestr(const char *haystack, const char *needle); +-#ifdef __cplusplus +-} +-#endif +- + #define OPEN_RDWR O_RDWR + #define OPEN_CREAT O_CREAT + #define OPEN_RDONLY O_RDONLY diff --git a/creator/patches/flac/flac-1.2.1-gcc-4.3.patch b/creator/patches/flac/flac-1.2.1-gcc-4.3.patch new file mode 100644 index 0000000..e7aad37 --- /dev/null +++ b/creator/patches/flac/flac-1.2.1-gcc-4.3.patch @@ -0,0 +1,10 @@ +--- flac-1.2.1/examples/cpp/encode/file/main.cpp.ark 2008-03-26 17:28:17.000000000 +0100 ++++ flac-1.2.1/examples/cpp/encode/file/main.cpp 2008-03-26 17:28:26.000000000 +0100 +@@ -30,6 +30,7 @@ + + #include <stdio.h> + #include <stdlib.h> ++#include <string.h> + #include "FLAC++/metadata.h" + #include "FLAC++/encoder.h" + |