Compile FFmpeg on Ubuntu, Debian, or Mint
(from https://trac.ffmpeg.org/wiki/UbuntuCompilationGuide)
This guide for supported releases of Ubuntu, Debian, and Linux Mint will provide a local install of the latest FFmpeg tools and libraries including several external encoding and decoding libraries (codecs). This will not provide a system installation and therefore will not interfere with anything such as repository packages. Recent static builds are also available for lazy people or those who are unable to compile.
Get the Dependencies
Copy and paste the whole code box for each step.
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential git libass-dev libgpac-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \
libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev
JNexOnSoft : BackTrack5 R2에서는 위의 명령에 문제가 있음. Kali 1.0.5에서는 잘 수행됨.
mkdir ~/ffmpeg_sources
- Server users can omit the ffplay and x11 dependencies: libsdl1.2-dev libva-dev libvdpau-dev libx11-dev libxext-dev libxfixes-dev.
- Ubuntu 10.04 Lucid users will need to install the git-core package instead of the git package. Lucid lacks the package libva-dev. This can be ignored.
Compilation & Installation
One advantage to compiling is that you can build ffmpeg to your liking. If you do not require certain encoders you may skip the relevant section and then remove the appropriate ./configure option in FFmpeg. For example, if libopus is not needed, then skip that section and then remove --enable-libopus from the Install FFmpeg section.
Yasm
Yasm is an assembler used by x264 and FFmpeg.
Ubuntu 13.04 and Mint 15 users can alternatively install the yasm package from the repository instead of compiling.
cd ~/ffmpeg_sources
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin"
make
make install
make distclean
. ~/.profile
x264
H.264 video encoder. See the x264 Encoding Guide for more information and examples.
cd ~/ffmpeg_sources
git clone --depth 1 git://git.videolan.org/x264.git
cd x264
./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static
make
make install
make distclean
Note: You can download the nightly x264 source snapshot as an alternative to using git.
fdk-aac
AAC audio encoder. See the AAC Encoding Guide for more information and examples.
cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean
Note: You can download a fdk-aac source snapshot as an alternative to using git.
libmp3lame
MP3 audio encoder.
Most users can install the repository package:
sudo apt-get install libmp3lame-dev
JNexOnSoft : Kali 1.0.5 에서는 위의 명령만 실행함. 아래 소스빌드는 하지 않음.
Ubuntu 10.04 and Debian Squeeze users must compile:
sudo apt-get install nasm
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make
make install
make distclean
libopus
Opus audio decoder and encoder.
Ubuntu 13.04 and Mint 15 users can alternatively install the libopus-dev package from the repository instead of compiling.
cd ~/ffmpeg_sources
wget http://downloads.xiph.org/releases/opus/opus-1.0.3.tar.gz
tar xzvf opus-1.0.3.tar.gz
cd opus-1.0.3
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean
libvpx
VP8/VP9 video encoder and decoder. See the vpx (WebM) Encoding Guide for more information and examples.
Ubuntu 13.04 and Mint 15 users can alternatively install the libvpx-dev package from the repository instead of compiling.
cd ~/ffmpeg_sources
git clone --depth 1 http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure --prefix="$HOME/ffmpeg_build" --disable-examples
make
make install
make clean
Note: You can download a libvpx source snapshot as an alternative to using git.
ffmpeg
Note: Server users should remove --enable-x11grab from the following command:
cd ~/ffmpeg_sources
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$HOME/ffmpeg_build" \
--extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx \
--enable-libx264 --enable-nonfree --enable-x11grab
make
make install
make distclean
hash -r
Note: You can download the nightly FFmpeg source snapshot as an alternative to using git.
Finish
Installation is now complete and ffmpeg is now ready for use. Check to see if you're using your new ffmpeg:
$ ffmpeg 2>&1 | head -n1
ffmpeg version git-2013-05-18-5918b7a Copyright (c) 2000-2013 the FFmpeg developers
If you do not see FFmpeg developers in your output then something went wrong and you're probably using the fake "ffmpeg" from the repository.
You can keep the ffmpeg_sources directory if you plan on updating later. See Updating FFmpeg below for more details followed by instructions for reverting all changes made by this guide.
JNexOnSoft : ~/ffmpeg_build/share/ffmpeg/examples/ 에 있는 소스 코드 빌드.
#PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
#export PKG_CONFIG_PATH
#make
빌드하는데 시간 좀 걸림
만약 ffmepg tutorial 소스를 구하여 빌드하였는데, 아래와 같은 에러가 나온다면...
cc tutorial01.o -pthread -L/root/ffmpeg_build/lib -lavdevice -lavfilter -lpostproc -lavformat -lavcodec -lva -lXfixes -lXext -lX11 -lasound -lSDL -lx264 -lvpx -lvorbisenc -lvorbis -ltheoraenc -ltheoradec -logg -lopus -lmp3lame -lfdk-aac -lass -lz -lrt -ldl -lswresample -lswscale -lavutil -lm -o tutorial01
tutorial01.o: In function `main':
/root/workspace/streaming/sample-code/tutorial01.c:69: undefined reference to `av_open_input_file'
/root/workspace/streaming/sample-code/tutorial01.c:77: undefined reference to `dump_format'
/root/workspace/streaming/sample-code/tutorial01.c:100: undefined reference to `avcodec_open'
/root/workspace/streaming/sample-code/tutorial01.c:128: undefined reference to `avcodec_decode_video'
/root/workspace/streaming/sample-code/tutorial01.c:134: undefined reference to `img_convert'
collect2: error: ld returned 1 exit status
make: *** [tutorial01] Error 1
ffmpeg이 버전업 되면서 변경된 함수들이 있어서 발생하는 문제이므로, tutorial source를 최신 버전으로 다운받으면 문제가 해결된다.
new version : https://github.com/chelyaev/ffmpeg-tutorial
- streaming test (audio 만 출력됨, from http://playready.directtaps.net/smoothstreaming/)
컴파일한 ffmpeg 에 대한 동작을 확인하고 싶으면 아래 명령을 입력한다.
#ffplay http://playready.directtaps.net/smoothstreaming/ISMAAACLCPR/Taxi3_AACLC.mp4
- 로컬 PC에서 스트리밍 테스트를 하고 싶다면 아래 내용을 따라하도록 한다.
(1) ffserver.conf 수정
기본 ffserver.conf (
ffserver.conf)를 하나 구하여 아래 내용을 추가한다.
------------------------------------------------
RTSPPort 7000
<Stream what.mp4>
Format rtp
File "/mnt/01.backup/what01.mp4"
</Stream>
------------------------------------------------
(2) ffserver 실행
# ffserver -f ./ffserver.conf
(3) ffplay 실행
# ffplay rtsp://{ffserver IP}:7000/what.mp4
잠시 후 동영상이 플레이 된다.

(4) what.mp4 정보
Container : MPEG-4
Video Format : AVC
Audio Format : AAC
참고로... ffplay 로 동영상 플레이하면 괜찮지만, tutorial source로 play하면 견디기 힘들 정도의 성능을 보임.
RECENT COMMENT