Showing posts with label ffmpeg. Show all posts
Showing posts with label ffmpeg. Show all posts

Monday, April 6, 2015

Install ffmpeg 2.6 into Linux Mint 17.1 (or 17)

I prefer ffmpeg to libav. The instructions found to "Compile FFmpeg on Ubuntu, Debian, or Mint" are thorough and work well, I like to do it differently though. I prefer to have ffmpeg installed through the package manager and I want it to replace libav. This is a quick guide how I do it.
This is an updated and simplified guide based on a previous blog and the official ffmpeg compilation instructions.

http://interknighterrant.blogspot.com/2014/03/replace-libav-with-ffmpeg-in-lm16.html
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
As a bonus, I decided to jot down notes as to what some more interesting (to me) commands actually are doing.

Installing Requirements

sudo apt-get update
sudo apt-get install checkinstall autoconf automake build-essential 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 libmp3lame-dev yasm libfdk-aac-dev libx264-dev x264 libopus-dev libvpx-dev

Remove libav (not installed by default)

sudo apt-get --purge remove libav-tools

Downloading and Preparing ffmpeg

mkdir $HOME/Downloads/ffmpeg
cd $HOME/Downloads/ffmpeg
wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && tar xjvf ffmpeg-snapshot.tar.bz2
cd ffmpeg

Compiling and Installing ffmpeg

./configure --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-makelibtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-version3 --enable-postproc --enable-avresample --enable-pic --enable-avisynth
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="2:`./version.sh`" --backup=no --deldoc=yes --fstrans=no --default
Two things interesting about this command. (1) checkinstall creates a .deb and installs it, which I thought was VERY cool when I came across it a few years ago. And (2) the `./version.sh` will update with each new release of ffmpeg as it calls the script that will simply print the ffmpeg version... this is a vast improvement over my old tutorial. Can't remember where I stumbled on this, but it stuck in my head and I have been using it for a bit.

Updating ldconfig

We need to tell Linux that there are some library files located in /usr/local/lib. How about we do this and practice using the terminal, shall we? If you prefer to do this via gedit look at the last guide I made for LM16.
sudo cp /etc/ld.so.conf /etc/ld.so.conf.bu
Create a BU of the configuration file.
cp /etc/ld.so.conf /tmp/ld.so.conf
Copy (as user) the configuration file into the /tmp folder (which is deleted every boot).
echo "/usr/local/lib" >> /tmp/ld.so.conf
Add a new line to the end of the temporary (user owned) configuration file with the text "/usr/local/lib" (this is called "appending" text to a document).
sudo cp /tmp/ld.so.conf /etc/ld.so.conf
As root, copy (and replace) the configuration file with the temporary configuration file.
sudo ldconfig -v
Update library locations with ldconfig.

Testing!

ffmpeg -version
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --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 --enable-version3 --enable-postproc --enable-avresample --enable-pic --enable-avisynth
libavutil      54. 22.100 / 54. 22.100
libavcodec     56. 34.100 / 56. 34.100
libavformat    56. 29.100 / 56. 29.100
libavdevice    56.  4.100 / 56.  4.100
libavfilter     5. 13.101 /  5. 13.101
libavresample   2.  1.  0 /  2.  1.  0
libswscale      3.  1.101 /  3.  1.101
libswresample   1.  1.100 /  1.  1.100
libpostproc    53.  3.100 / 53.  3.100
Aww yeah... sweet old success!

Removing ffmpeg installed with this guide / uninstall ffmpeg

sudo apt-get --purge remove ffmpeg

Re-installing libav after removal of ffmpeg

If desired, libav-tools is not installed by default in Linux Mint and might only be necessary if other software requires it.
sudo apt-get install libav-tools

Final Thoughts

I have used these same steps on several Linux Mint 17 and Linux Mint 17.1 builds now (I think this is my 5th time) and I have not had any issues. I use a few utilities tied in with .nemo_action scripts to automate some media tasks (like de-interlacing, adding an intro video, etc). I would love any suggestions on improvement to the process and I have fixed comments (I apologize to past readers who tried to comment and it would never show the comments).
The compilation guide for ffmpeg has you compile a lot of programs. After looking at repository versions compared to current stable versions, I found with the latest Linux Mint it just was not worth compiling all these different programs. Maybe if the libraries update in the next year or two I may feel inclined to do that though.

Monday, March 24, 2014

Replace libav with ffmpeg in LM16 / Ubuntu 13.10 (and Ubuntu 12.04 as well)

I prefer ffmpeg.  I think their compilation instructions are good, but wish to completely replace libav on my system and use ffmpeg exclusively (not just limited to a single user).  This isn't a post about why I make that choice, just a how I made it happen.

I have used the following pages in putting this how-to together:

I would love suggestions if there are ways to improve this process.

Compiling and Installation

Preparation

sudo apt-get update

sudo apt-get -y install checkinstall autoconf automake build-essential 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 libmp3lame-dev yasm

mkdir ~/Downloads/ffmpeg

cd ~/Downloads/ffmpeg

wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 && tar xjvf last_x264.tar.bz2

wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master && unzip fdk-aac.zip

wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz && tar xzvf lame-3.99.5.tar.gz

wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz && tar xzvf opus-1.1.tar.gz

wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2 && tar xjvf libvpx-v1.3.0.tar.bz2

wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && tar xjvf ffmpeg-snapshot.tar.bz2

sudo apt-get --purge remove libav-tools

Ubuntu 12.04 ONLY, Installation: yasm 1.2

On Ubuntu 12.04 you need to compile the latest yasm, as the one in the repository is too old to work properly for the rest of the software compilations.

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

sudo apt-get remove yasm

./configure

make

sudo checkinstall --pkgname=yasm --pkgversion="2:1.2.0" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libx264

cd ./x264-snapshot*

./configure --enable-static

make

sudo checkinstall --pkgname=libx264 --pkgversion="20140323-2245" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libfdk-aac

cd mstorsjo-fdk-aac*

autoreconf -fiv

./configure --disable-shared

make

sudo checkinstall --pkgname=libfdk-aac --pkgversion="1.3" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libopus

cd opus-1.1

./configure --disable-shared

make

sudo checkinstall --pkgname=libopus --pkgversion="1.1" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libvpx

cd libvpx-v1.3.0

./configure --disable-examples

make

sudo checkinstall --pkgname=libvpx --pkgversion="1.3" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: ffmpeg

cd ffmpeg

./configure --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --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 --enable-version3 --enable-postproc --enable-avresample --enable-pic --enable-avisynth

make

sudo checkinstall --pkgname=ffmpeg --pkgversion="7:2.1" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Final Adjustments

There is one thing left to do. We need to tell Linux that there are some library files located in /usr/local/lib

  1. sudo gedit /etc/ld.so.conf
  2. Add the text "/usr/local/lib" on a new line at the bottom of the document.
  3. Save changes and close gedit
  4. sudo ldconfig -v

Testing

ffmpeg -version
ffmpeg version 2.2.git
built on Mar 24 2014 15:22:19 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --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 --enable-version3 --enable-postproc
libavutil      52. 69.100 / 52. 69.100
libavcodec     55. 54.100 / 55. 54.100
libavformat    55. 35.100 / 55. 35.100
libavdevice    55. 11.100 / 55. 11.100
libavfilter     4.  3.100 /  4.  3.100
libswscale      2.  5.102 /  2.  5.102
libswresample   0. 18.100 /  0. 18.100
libpostproc    52.  3.100 / 52.  3.100

Success!

Un-install

To Un-install any changes made from this how-to, simply remove the packages like this:

sudo apt-get --purge remove libx264 libfdk-aac libopus libvpx ffmpeg

You may at that point re-install libav-tools if you choose to, like this:

sudo apt-get install libav-tools

End Thoughts

My larger goal is to get avxsynth to install and function. With stability. The options "--enable-avresample --enable-pic --enable-avisynth" is for ffms2 and avxsynth to work properly.

I will be posting a how to when I have got that installation ironed out correctly.