| 1 | = Compile FFmpeg on Ubuntu = |
| 2 | |
| 3 | This guide provides instructions to compile and install FFmpeg, x264, libvpx, and dependencies on Ubuntu Oneiric Ocelot 11.10. |
| 4 | |
| 5 | '''Note:''' Copy and paste the whole code box for each step. |
| 6 | |
| 7 | == Preparation == |
| 8 | Remove any existing packages: |
| 9 | {{{ |
| 10 | sudo apt-get -y remove ffmpeg x264 libvpx-dev libx264-dev |
| 11 | }}} |
| 12 | |
| 13 | Get the dependencies: |
| 14 | {{{ |
| 15 | sudo apt-get update |
| 16 | sudo apt-get -y install build-essential checkinstall git libfaac-dev libjack-jackd2-dev \ |
| 17 | libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev \ |
| 18 | libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev texi2html yasm zlib1g-dev |
| 19 | }}} |
| 20 | |
| 21 | == Installation == |
| 22 | === x264 ===#x264 |
| 23 | H.264 video encoder. The following commands will get the current source files, compile, and install x264. |
| 24 | {{{ |
| 25 | cd |
| 26 | git clone git://git.videolan.org/x264 |
| 27 | cd x264 |
| 28 | ./configure --enable-static |
| 29 | make |
| 30 | sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \ |
| 31 | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \ |
| 32 | --fstrans=no --default |
| 33 | }}} |
| 34 | |
| 35 | '''Note:''' See [http://ubuntuforums.org/showpost.php?p=11483157&postcount=1945 using snapshots] if you are having connection issues with the Git server. |
| 36 | |
| 37 | === libvpx ===#libvpx |
| 38 | VP8 video encoder and decoder. |
| 39 | {{{ |
| 40 | cd |
| 41 | git clone http://git.chromium.org/webm/libvpx.git |
| 42 | cd libvpx |
| 43 | ./configure |
| 44 | make |
| 45 | sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 46 | --deldoc=yes --fstrans=no --default |
| 47 | }}} |
| 48 | |
| 49 | === FFmpeg ===#ffmpeg |
| 50 | {{{ |
| 51 | cd |
| 52 | git clone --depth 1 git://source.ffmpeg.org/ffmpeg |
| 53 | cd ffmpeg |
| 54 | ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \ |
| 55 | --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 \ |
| 56 | --enable-nonfree --enable-version3 --enable-x11grab |
| 57 | make |
| 58 | sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 59 | --deldoc=yes --fstrans=no --default |
| 60 | hash x264 ffmpeg ffplay ffprobe |
| 61 | }}} |
| 62 | 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. |
| 63 | |
| 64 | == Optional Installation == |
| 65 | === qt-faststart === |
| 66 | 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`. |
| 67 | {{{ |
| 68 | cd ~/ffmpeg |
| 69 | make tools/qt-faststart |
| 70 | sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \ |
| 71 | --deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \ |
| 72 | /usr/local/bin/qt-faststart |
| 73 | }}} |
| 74 | |
| 75 | === Add `lavf` support to x264 === |
| 76 | 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. |
| 77 | {{{ |
| 78 | cd ~/x264 |
| 79 | make distclean |
| 80 | ./configure --enable-static |
| 81 | make |
| 82 | sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \ |
| 83 | awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \ |
| 84 | --fstrans=no --default |
| 85 | }}} |
| 86 | |
| 87 | == Updating FFmpeg ==#update |
| 88 | 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: |
| 89 | {{{ |
| 90 | sudo apt-get -y remove ffmpeg x264 libx264-dev libvpx-dev |
| 91 | sudo apt-get update |
| 92 | sudo apt-get -y install build-essential git checkinstall yasm texi2html \ |
| 93 | libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev \ |
| 94 | libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev \ |
| 95 | libvorbis-dev libx11-dev libxfixes-dev zlib1g-dev |
| 96 | }}} |
| 97 | |
| 98 | === x264 === |
| 99 | {{{ |
| 100 | cd ~/x264 |
| 101 | make distclean |
| 102 | git pull |
| 103 | }}} |
| 104 | Now run `./configure`, `make`, and `make install` as shown in the [#x264 Install x264] section. |
| 105 | |
| 106 | === libvpx === |
| 107 | {{{ |
| 108 | cd ~/libvpx |
| 109 | make clean |
| 110 | git pull |
| 111 | }}} |
| 112 | Now run `./configure`, `make`, and `make install` as shown in the [#libvpx Install libvpx] section. |
| 113 | |
| 114 | === FFmpeg === |
| 115 | {{{ |
| 116 | cd ~/ffmpeg |
| 117 | make distclean |
| 118 | git pull |
| 119 | }}} |
| 120 | Now run `./configure`, `make`, and `make install` as shown in the [#ffmpeg Install FFmpeg] section. |
| 121 | |
| 122 | == Reverting Changes Made by This Guide == |
| 123 | To remove FFmpeg/x264 and other packages added for this guide: |
| 124 | {{{ |
| 125 | sudo apt-get -y autoremove x264 ffmpeg qt-faststart build-essential git checkinstall \ |
| 126 | yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libsdl1.2-dev libtheora-dev \ |
| 127 | libva-dev libvdpau-dev libvorbis-dev libvpx libx11-dev libxfixes-dev zlib1g-dev |
| 128 | }}} |
| 129 | Lastly, delete the x264, libvpx, and ffmpeg directories in your home folder. |
| 130 | |
| 131 | == If You Need Help == |
| 132 | Feel free to ask your questions at the #ffmpeg IRC channel or the [http://ffmpeg.org/contact.html ffmpeg-user] mailing list. |