| 1 | | = Compile FFmpeg on Ubuntu 12.10, 12.04, and 11.10 = |
| 2 | | |
| 3 | | [[PageOutline(2, Contents)]] |
| 4 | | |
| 5 | | This guide supports '''Ubuntu 12.10 (Quantal Quetzal)''', '''Ubuntu 12.04 (Precise Pangolin)''', and '''Ubuntu 11.10 (Oneiric Ocelot)'''. Separate guides are available for [wiki:UbuntuCompilationGuideLucid Ubuntu 10.04 (Lucid Lynx)] and [wiki:UbuntuCompilationGuideHardy Ubuntu 8.04 (Hardy Heron)]. This guide will provide the latest FFmpeg code and enable several external encoding and decoding libraries: ''fdk-aac'' (AAC encoder), ''libfaac'' (AAC encoder), ''libmp3lame'' (MP3 encoder), ''libopencore-amr'' (AMR encoder/decoder), ''libtheora'' (Theora encoder), ''libvorbis'' (Vorbis encoder), ''libvpx'' (VP8 encoder/decoder), and ''libx264'' (H.264 encoder). These are optional and may be omitted if desired. This guide will also install many filters, including the `subtitles` filter for hardcoding subtitles (see the filter list in the [wiki:FilteringGuide#ListofFilters Filtering Guide]). |
| 6 | | |
| 7 | | '''Note:''' Copy and paste the whole code box for each step. |
| 8 | | |
| 9 | | == Preparation == |
| 10 | | |
| 11 | | Remove any existing packages: |
| 12 | | {{{ |
| 13 | | sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm |
| 14 | | }}} |
| 15 | | |
| 16 | | Get the dependencies ('''Ubuntu Desktop''' users): |
| 17 | | {{{ |
| 18 | | sudo apt-get update |
| 19 | | sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \ |
| 20 | | libgpac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev \ |
| 21 | | libsdl1.2-dev libspeex-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev \ |
| 22 | | libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev |
| 23 | | }}} |
| 24 | | |
| 25 | | Get the dependencies ('''Ubuntu Server''' or headless users): |
| 26 | | {{{ |
| 27 | | sudo apt-get update |
| 28 | | sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \ |
| 29 | | libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libspeex-dev \ |
| 30 | | libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev |
| 31 | | }}} |
| 32 | | |
| 33 | | == Installation == |
| 34 | | |
| 35 | | === Yasm === |
| 36 | | |
| 37 | | Yasm is an assembler and is recommended for x264 and FFmpeg. |
| 38 | | {{{ |
| 39 | | cd |
| 40 | | wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz |
| 41 | | tar xzvf yasm-1.2.0.tar.gz |
| 42 | | cd yasm-1.2.0 |
| 43 | | ./configure |
| 44 | | make |
| 45 | | sudo checkinstall --pkgname=yasm --pkgversion="1.2.0" --backup=no \ |
| 46 | | --deldoc=yes --fstrans=no --default |
| 47 | | }}} |
| 48 | | |
| 49 | | === x264 === |
| 50 | | H.264 video encoder. The following commands will get the current source files, compile, and install x264. See the [wiki:x264EncodingGuide x264 Encoding Guide] for some usage examples. |
| 51 | | {{{ |
| 52 | | cd |
| 53 | | git clone --depth 1 git://git.videolan.org/x264.git |
| 54 | | cd x264 |
| 55 | | ./configure --enable-static |
| 56 | | make |
| 57 | | sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \ |
| 58 | | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \ |
| 59 | | --fstrans=no --default |
| 60 | | }}} |
| 61 | | |
| 62 | | '''Note:''' You can download the nightly [ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 x264 source snapshot] as an alternative to using `git`. |
| 63 | | |
| 64 | | === fdk-aac === |
| 65 | | AAC audio encoder. |
| 66 | | {{{ |
| 67 | | cd |
| 68 | | git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git |
| 69 | | cd fdk-aac |
| 70 | | autoreconf -fiv |
| 71 | | ./configure --disable-shared |
| 72 | | make |
| 73 | | sudo checkinstall --pkgname=fdk-aac --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 74 | | --deldoc=yes --fstrans=no --default |
| 75 | | }}} |
| 76 | | |
| 77 | | '''Note:''' You can download a [https://github.com/mstorsjo/fdk-aac/zipball/master fdk-aac source snapshot] as an alternative to using `git`. |
| 78 | | |
| 79 | | === libvpx === |
| 80 | | VP8 video encoder and decoder. |
| 81 | | {{{ |
| 82 | | cd |
| 83 | | git clone --depth 1 http://git.chromium.org/webm/libvpx.git |
| 84 | | cd libvpx |
| 85 | | ./configure --disable-examples --disable-unit-tests |
| 86 | | make |
| 87 | | sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 88 | | --deldoc=yes --fstrans=no --default |
| 89 | | }}} |
| 90 | | |
| 91 | | '''Note:''' You can download a [http://code.google.com/p/webm/downloads/list libvpx source snapshot] as an alternative to using `git`. |
| 92 | | |
| 93 | | === opus === |
| 94 | | Opus audio encoder and decoder. |
| 95 | | {{{ |
| 96 | | cd |
| 97 | | git clone --depth 1 git://git.xiph.org/opus.git |
| 98 | | cd opus |
| 99 | | ./autogen.sh |
| 100 | | ./configure --disable-shared |
| 101 | | make |
| 102 | | sudo checkinstall --pkgname=libopus --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 103 | | --deldoc=yes --fstrans=no --default |
| 104 | | }}} |
| 105 | | |
| 106 | | === FFmpeg === |
| 107 | | |
| 108 | | '''Note:''' Ubuntu Server users should remove `--enable-x11grab` from the following command: |
| 109 | | |
| 110 | | {{{ |
| 111 | | cd |
| 112 | | git clone --depth 1 git://source.ffmpeg.org/ffmpeg |
| 113 | | cd ffmpeg |
| 114 | | ./configure --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame \ |
| 115 | | --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libvorbis \ |
| 116 | | --enable-libopus --enable-libvpx --enable-x11grab --enable-libx264 --enable-nonfree --enable-version3 |
| 117 | | make |
| 118 | | sudo checkinstall --pkgname=ffmpeg --pkgversion="7:$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 119 | | --deldoc=yes --fstrans=no --default |
| 120 | | hash -r |
| 121 | | }}} |
| 122 | | |
| 123 | | '''Note:''' You can download the nightly [http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 FFmpeg source snapshot] as an alternative to using `git`. |
| 124 | | |
| 125 | | == Finish == |
| 126 | | Installation is now complete and FFmpeg is now ready for use. You can keep the x264, libvpx, and ffmpeg directories in your home directory if you plan on updating later. See [#update Updating FFmpeg] below for more details. Some optional steps are next followed by instructions on updating FFmpeg and finally instructions on reverting all changes made by this guide. |
| 127 | | |
| 128 | | ---- |
| 129 | | |
| 130 | | == Optional Installation == |
| 131 | | === qt-faststart === |
| 132 | | This is a useful tool if you're showing your H.264 in MP4 videos on the web. It relocates some data in the video to allow playback to begin before the file is completely downloaded. Usage: `qt-faststart input.mp4 output.mp4`. When converting files with ffmpeg you can add `-movflags faststart` to have the same effect. |
| 133 | | {{{ |
| 134 | | cd ~/ffmpeg |
| 135 | | make tools/qt-faststart |
| 136 | | sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 137 | | --deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \ |
| 138 | | /usr/local/bin/qt-faststart |
| 139 | | }}} |
| 140 | | |
| 141 | | === Add `lavf` support to x264 === |
| 142 | | This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly. See a [http://ubuntuforums.org/showpost.php?p=11243462&postcount=1839 more detailed explanation] of what this means. |
| 143 | | {{{ |
| 144 | | cd ~/x264 |
| 145 | | make distclean |
| 146 | | ./configure --enable-static |
| 147 | | make |
| 148 | | sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \ |
| 149 | | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \ |
| 150 | | --fstrans=no --default |
| 151 | | }}} |
| 152 | | |
| 153 | | ---- |
| 154 | | |
| 155 | | == Updating FFmpeg ==#update |
| 156 | | Development of FFmpeg and x264 is active and an occasional update can give you new features and bug fixes. First, remove some packages and then update the dependencies: |
| 157 | | {{{ |
| 158 | | sudo apt-get -y remove ffmpeg x264 libx264-dev libvpx-dev |
| 159 | | sudo apt-get update |
| 160 | | sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \ |
| 161 | | libgpac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev \ |
| 162 | | libsdl1.2-dev libspeex-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev \ |
| 163 | | libxext-dev libxfixes-dev texi2html yasm zlib1g-dev |
| 164 | | }}} |
| 165 | | |
| 166 | | === x264 === |
| 167 | | {{{ |
| 168 | | cd ~/x264 |
| 169 | | make distclean |
| 170 | | git pull |
| 171 | | }}} |
| 172 | | Now run `./configure`, `make`, and `checkinstall` as shown in the [#x264 Install x264] section. |
| 173 | | |
| 174 | | === fdk-aac === |
| 175 | | {{{ |
| 176 | | cd ~/fdk-aac |
| 177 | | make distclean |
| 178 | | git pull |
| 179 | | }}} |
| 180 | | Now run `./configure`, `make`, and `checkinstall` as shown in the [#fdk-aac Install fdk-aac] section. |
| 181 | | |
| 182 | | === libvpx === |
| 183 | | {{{ |
| 184 | | cd ~/libvpx |
| 185 | | make clean |
| 186 | | git pull |
| 187 | | }}} |
| 188 | | Now run `./configure`, `make`, and `checkinstall` as shown in the [#libvpx Install libvpx] section. |
| 189 | | |
| 190 | | === opus === |
| 191 | | {{{ |
| 192 | | cd ~/opus |
| 193 | | make distclean |
| 194 | | git pull |
| 195 | | }}} |
| 196 | | Now run `./configure`, `make`, and `checkinstall` as shown in the [#opusoptional Install opus] section. |
| 197 | | |
| 198 | | === FFmpeg === |
| 199 | | {{{ |
| 200 | | cd ~/ffmpeg |
| 201 | | make distclean |
| 202 | | git pull |
| 203 | | }}} |
| 204 | | Now run `./configure`, `make`, and `checkinstall` as shown in the [#FFmpeg Install FFmpeg] section. |
| 205 | | |
| 206 | | ---- |
| 207 | | |
| 208 | | == Reverting Changes Made by This Guide == |
| 209 | | To remove FFmpeg, x264, and other packages installed for this guide: |
| 210 | | {{{ |
| 211 | | sudo apt-get autoremove autoconf automake build-essential checkinstall fdk-aac ffmpeg git libass-dev \ |
| 212 | | libgpac-dev libjack-jackd2-dev libmp3lame-dev libsdl1.2-dev libspeex-dev libtheora-dev libtool \ |
| 213 | | libva-dev libvdpau-dev libvorbis-dev libvpx libx11-dev libxfixes-dev opus qt-faststart texi2html \ |
| 214 | | x264 yasm zlib1g-dev |
| 215 | | }}} |
| 216 | | Lastly, delete the `x264`, `fdk-aac`, `libvpx`, `opus`, and `ffmpeg` directories in your home folder. |
| 217 | | |
| 218 | | == If You Need Help == |
| 219 | | Feel free to ask your questions at the #ffmpeg IRC channel or the [http://ffmpeg.org/contact.html ffmpeg-user] mailing list. |
| | 1 | This article has been merged with the main [[UbuntuCompilationGuide|Compile FFmpeg on Ubuntu, Debian, and Linux Mint]] article. |