dimanche 16 mai 2010
Compiler Ffmpeg sous Debian Lenny en mode full static
Par david techer, dimanche 16 mai 2010 à 02:38 :: Multiméda sous GNU/Linux
Introduction
Motivation
Le mode de compilation de ffmpeg a changé depuis quelques temps. Il est maintenant possible de la compiler en mode statique complet. J'ai été agréablement surpris par cette possibilité car celà  me facilite beaucoup la phase de compilation.
Pour mon usage personnel lors d'un déploiment temporaire sur une de mes machines, je n'y vois que des avantages par rapport malheureusement à  la politique du paquet officiel Debian de ffmpeg que je trouve très limité bien que Debian constitue l'une de mes distributions préférées. Pour Debian, tous les formats ne sont pas fournis en raison de certaines licences ou que les dépots ne soient pas mis à  jour réguilèrement
Exemple de format supporté
Voici un exemple de format méconnu de l'usage de ffmpeg mais au combien bien intéressant: le couple Dirac/Schroedinger. Je prendrais ici un vidéo bien connue de tout geek:
Lecteur Ffplay après compilation: Vidéo Big Bucks Bunny au format Schroedinger
Ci-dessus, le lecteur ffplay joue la vidéo Big Bucks Bunny au format Schroedinger. Cette vidéo est disponible à  http://dirac.kw.bbc.co.uk/download/video/maybefinal/bbb-tr1000.ts. Malheureusement on obtiendrait un écran noir en se contentant des dépots officiels de Debian
On peut aussi avoir les informations sur cette vidéo
root@bremko:/var/lib/david/# /opt/ffmpeg//bin/ffmpeg -i bbb-tr1000.ts FFmpeg version git-7e8d959, Copyright (c) 2000-2010 the FFmpeg developers built on May 16 2010 17:27:52 with gcc 4.3.2 configuration: --prefix=/opt/ffmpeg --enable-libdirac --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-libopenc ore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libfaad --enable-libfaadbin --enable-libfaac --enable-gpl --enable-nonfree --enable-pthreads --extra-cflags='-I$TOOLS_MULTIMEDIA_DIR/include/ -I $TOOLS_MULTIMEDIA_DIR/include/a52dec/ -I$TOOLS_MULTIMEDIA_DIR/include/lame/ \ -I$TOOLS_MULTIMEDIA_DIR/include/ -I$TOOLS_MULTIMEDIA_DIR/include/ao -I$TOOLS_MULTIMEDIA_DIR/include/libyasm -I$TOOLS_MULTIMEDIA_DI R/include/ogg -I$TOOLS_MULTIMEDIA_DIR/include/SDL -I$TOOLS_MULTIMEDIA_DIR/include/speex -I$TOOLS_MULTIMEDIA_DIR/include/vorbis -I$TOOLS_MULTIMEDIA_DIR/include/theora -I$TOOLS_MULTIMEDIA_DIR/include/schroeding er-1.0 -I$TOOLS_MULTIMEDIA_DIR/include/dirac -I$TOOLS_MULTIMEDIA_DIR/include/opencore-amrnb/ -I$TOOLS_MULTIMEDIA_DIR/include/opencore-amrwb/' --extra-ldflags=-L/opt/multimedia/lib libavutil 50.15. 2 / 50.15. 2 libavcodec 52.67. 0 / 52.67. 0 libavformat 52.62. 0 / 52.62. 0 libavdevice 52. 2. 0 / 52. 2. 0 libavfilter 1.20. 0 / 1.20. 0 libswscale 0.10. 0 / 0.10. 0 [mpegts @ 0x90fb4c0]max_analyze_duration reached Input #0, mpegts, from 'bbb-tr1000.ts': Duration: 00:09:56.12, start: 61835.685522, bitrate: 1373 kb/s Program 1 Stream #0.0[0x44]: Video: libschroedinger, yuv420p, 640x360, 28.28 fps, 24 tbr, 90k tbn, 24 tbc Stream #0.1[0x45]: Audio: mp2, 48000 Hz, 2 channels, s16, 256 kb/s At least one output file must be specified
Après cette mise en bouche, je suis donc d'attaque pour recompiler ffmpeg
Pré-requis
- Avoir une Debian Lenny fraà ®chement installée physiquement ou virtuellement (Xen, Vmware etc...)
- Préparer deux ou trois tasses de café
- Une prière ou deux à  réciter (on ne sait jamais) car les compilations ne sont longues pas mais leur nombre est important
Plan
- Pour que l'environnement de compilation soit 100% opérationnel, j'ai opté pour une installation d'une Lenny fraà ®chement installée. Disposant de Xen à  la maison, je me construis donc un domU sous Lenny. On peut tout aussi avoir effectué une installation de base sur un machine.
- On installe ensuite les paquets .deb de base requis.
- On compile ensuite les divers paquets...
Xen - mise en place d'un domU tout frais sous Lenny (optionnel)
On configure donc notre fichier /etc/xen-tools/xen-tools.conf
melina:~# grep -vE '^(#|$)' /etc/xen-tools/xen-tools.conf lvm = xen-vm install-method = debootstrap size = 20Gb # Disk image size. memory = 512Mb # Memory size swap = 128Mb # Swap size fs = ext3 # use the EXT3 filesystem for the disk image. dist = lenny # Default distribution to install. image = sparse # Specify sparse vs. full disk images. gateway = 192.168.2.253 netmask = 255.255.255.0 broadcast = 192.168.2.255 passwd = 1 accounts = 1 kernel = /boot/vmlinuz-`uname -r` initrd = /boot/initrd.img-`uname -r` arch = i386 mirror = http://ftp.us.debian.org/debian/ ext3_options = noatime,nodiratime,errors=remount-ro ext2_options = noatime,nodiratime,errors=remount-ro xfs_options = defaults reiser_options = defaults serial_device = hvc0 disk_device = xvda output = /etc/xen/machines extension = .cfgOn installe le domU
melina:~# xen-create-image --force --hostname=melina-xen08 --ip=192.168.2.230 \ --config=/etc/xen-tools/xen-tools.conf --role=udev General Information -------------------- Hostname : melina-xen08 Distribution : lenny Partitions : swap 128Mb (swap) / 20Gb (ext3) Image type : full Memory size : 512Mb Kernel path : /boot/vmlinuz-2.6.26-2-xen-686 Initrd path : /boot/initrd.img-2.6.26-2-xen-686 Networking Information ---------------------- IP Address 1 : 192.168.2.230 [MAC: 00:16:3E:D5:F9:A8] Netmask : 255.255.255.0 Broadcast : 192.168.2.255 Gateway : 192.168.2.253 Creating swap on /dev/xen-vm/melina-xen08-swap Done Creating ext3 filesystem on /dev/xen-vm/melina-xen08-disk Done Installation method: debootstrap Done Running hooks Done Role: udev File: /etc/xen-tools/role.d/udev Role script completed. Creating Xen configuration file Done Setting up root password Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully All done Logfile produced at: /var/log/xen-tools/melina-xen08.logOn démarre la machine
melina:~# xm create /etc/xen/machines/melina-xen08.cfg Using config file "/etc/xen/machines/melina-xen08.cfg". Started domain melina-xen08
Installation des paquets .deb de base
Rien de plus simple que
apt-get install git make gcc libc6-dev g++ git-core autotools-dev autoconf autoconf2.13 autoconf-archive gnu-standards \ autoconf-doc automake1.4 m4 libtool unzip libtool bzip2 python2.5 gettext strace libx11-dev xserver-xorg-dev pkg-config
Remarques:
- Les paquets
libx11-dev
etxserver-xorg-dev
sont utils pour pouvoir compiler le lecteur ffplay - Le paquet pkg-config s'avère d'une grande aide pour les compilations
Compilations
Environnement de compilation
On va- créer deux dossiers. Le premier servira de dépot pour les sources téléchargées (SRC) . Le second contiendra les divers binaires issus des compilations (TOOL_MULTIMEDIA_DIR)
- mettre à  jour les variables d'environnement (PATH et LD_LIBRARY_PATH)
Pour celà  , dans un fichier multimedia_env.sh
, on met donc
export SRC=/mnt/sources export TOOLS_MULTIMEDIA_DIR=/opt/multimedia export PATH=${TOOLS_MULTIMEDIA_DIR}/bin:${PATH} export LD_LIBRARY_PATH=${TOOLS_MULTIMEDIA_DIR}/lib:${LD_LIBRARY_PATH} export PKG_CONFIG_PATH=${TOOLS_MULTIMEDIA_DIR}/lib/pkgconfig/:${PKG_CONFIG_PATH}On source ce fichier et on crée les répertoires attendus
melina-xen08:~# source multimedia_env.sh melina-xen08:~# mkdir -pv $SRC $TOOLS_MULTIMEDIA_DIR mkdir: création du répertoire `/mnt/sources' mkdir: création du répertoire `/opt/multimedia'
OPEN-AMR
cd $SRC wget "http://sourceforge.net/projects/opencore-amr/files/opencore-amr/0.1.2/opencore-amr-0.1.2.tar.gz/download" tar xvzf opencore-amr-0.1.2.tar.gz cd opencore-amr-0.1.2 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install
FAAC
cd $SRC wget "http://sourceforge.net/projects/faac/files/faac-src/faac-1.28/faac-1.28.tar.gz/download" tar xvzf faac-1.28.tar.gz cd faac-1.28 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes --with-mp4v2 && make && make install
FAAD
cd $SRC wget "http://sourceforge.net/projects/faac/files/faad2-src/faad2-2.7/faad2-2.7.tar.gz/download" tar xvzf faad2-2.7.tar.gz cd faad2-2.7 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes --with-mpeg4ip --with-drm && make && make install
OGG, VORBIS et THEORA
cd $SRC wget http://downloads.xiph.org/releases/ao/libao-1.0.0.tar.gz tar xvzf libao-1.0.0.tar.gz cd libao-1.0.0 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes make make install cd $SRC wget http://downloads.xiph.org/releases/ogg/libogg-1.2.0.tar.gz tar xvzf libogg-1.2.0.tar.gz cd libogg-1.2.0 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes make make install cd $SRC wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.1.tar.bz2 tar xvjf libvorbis-1.3.1.tar.bz2 cd libvorbis-1.3.1 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes make install cd $SRC wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2 tar xvjf libtheora-1.1.1.tar.bz2 cd libtheora-1.1.1 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes --with-ogg=/opt/multimedia \ --with-vorbis=/opt/multimedia/ --wtih-sdl=/opt/multimedia/ make && make install
SPEEX
C'esr cette version qu'il faut et non la 1.0.5 car elle ne se compilera pascd $SRC wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz tar xvzf speex-1.2rc1.tar.gz cd speex-1.2rc1 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes --with-ogg=/opt/multimedia --with-vorbis=/opt/multimedia/ make && make install
YASM
cd $SRC wget http://www.tortall.net/projects/yasm/releases/yasm-1.0.0.tar.gz tar xvzf yasm-1.0.0.tar.gz cd yasm-1.0.0 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install
NASM
cd $SRC wget http://www.nasm.us/pub/nasm/releasebuilds/2.08.01/nasm-2.08.01.tar.bz2 tar xvjf nasm-2.08.01.tar.bz2 cd nasm-2.08.01 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install
LAME
cd $SRC wget http://sourceforge.net/projects/lame/files/lame/3.98.4/lame-3.98.4.tar.gz/download tar xvzf lame-3.98.4.tar.gz cd lame-3.98.4 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes --enable-nasm && make && make install
A52
cd $SRC wget http://liba52.sourceforge.net/files/a52dec-0.7.4.tar.gz tar xvzf a52dec-0.7.4.tar.gz cd a52dec-0.7.4 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install
XVID
cd $SRC wget http://downloads.xvid.org/downloads/xvidcore-1.2.1.tar.gz tar xvzf xvidcore-1.2.1.tar.gz cd xvidcore cd build/generic/ ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install
X264
cd $SRC wget http://downloads.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20100420-2245.tar.bz2 tar xvjf x264-snapshot-20100420-2245.tar.bz2 cd x264-snapshot-20100420-2245 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes &&\ make && make install
DIRAC et SCHROEDINGER
cd $SRC wget http://sourceforge.net/projects/dirac/files/dirac-codec/Dirac-1.0.2/dirac-1.0.2.tar.gz/download tar xvzf dirac-1.0.2.tar.gz cd dirac-1.0.2 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install cd $SRC wget http://code.entropywave.com/download/orc/orc-0.4.4.tar.gz tar xvzf orc-0.4.4.tar.gz cd orc-0.4.4 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install cd $SRC wget http://diracvideo.org/download/schroedinger/schroedinger-1.0.9.tar.gz tar xvzf schroedinger-1.0.9.tar.gz cd schroedinger-1.0.9 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-shared=no --enable-static=yes && make && make install
FFPLAY (optionnel)
Cette section est bien sà »r optionnelle à  moins que l'on veuille bénéficier du lecteurffplay
cd $SRC wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz tar xvzf SDL-1.2.14.tar.gz cd SDL-1.2.14 ./configure --prefix=$TOOLS_MULTIMEDIA_DIR --enable-static=yes --enable-shared=no && make && make install
FFMPEG
cd $SRC git clone git://git.ffmpeg.org/ffmpeg/ cd ffmpeg git clone git://git.ffmpeg.org/libswscale/ ./configure --prefix=/opt/ffmpeg --enable-libdirac --enable-libschroedinger --enable-libspeex \ --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-libx264 --enable-libxvid \ --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libfaad \ --enable-libfaadbin --enable-libfaac --enable-gpl --enable-nonfree --enable-pthreads \ --extra-cflags='-I$TOOLS_MULTIMEDIA_DIR/include/ -I$TOOLS_MULTIMEDIA_DIR/include/a52dec/ \ -I$TOOLS_MULTIMEDIA_DIR/include/lame/ -I$TOOLS_MULTIMEDIA_DIR/include/ \ -I$TOOLS_MULTIMEDIA_DIR/include/ao -I$TOOLS_MULTIMEDIA_DIR/include/libyasm \ -I$TOOLS_MULTIMEDIA_DIR/include/ogg -I$TOOLS_MULTIMEDIA_DIR/include/SDL \ -I$TOOLS_MULTIMEDIA_DIR/include/speex -I$TOOLS_MULTIMEDIA_DIR/include/vorbis \ -I$TOOLS_MULTIMEDIA_DIR/include/theora -I$TOOLS_MULTIMEDIA_DIR/include/schroedinger-1.0 \ -I$TOOLS_MULTIMEDIA_DIR/include/dirac -I$TOOLS_MULTIMEDIA_DIR/include/opencore-amrnb/ \ -I$TOOLS_MULTIMEDIA_DIR/include/opencore-amrwb/' \ --extra-ldflags=-L$TOOLS_MULTIMEDIA_DIR/lib make make install