0

Before I go ahead and wipe my whole system and start from scratch, is there a way I can avoid what just happened on trying to install ffmpeg? I still don't actually know the correct way to install it so it includes most functions which it DOES NOT on Centos 6.4 with STATIC version.

My /etc/lb folder is a mess after the command ldconfig -v which created symlinks and they conflict all over the place. The /etc/yum.repos.d folder is also a mess and the script I followed in a linux blog makes no sense to me and started errors in first place. I'd like to avoid that altogether next time around...is there a way I can do that? In other words not play around with writing repo scripts or touching that folder..that is when all the trouble began!

Better yet is there a safe method to employ that can be reversed? Starting to think Centos is a headache in as far as ffmpeg goes. Everyone else doing basic commands with it just downloads static version.

2

There are some licensing issues with some components of ffmpeg making it unpalatable to include in certain configurations for most distros, I think -- probably you are aware of this. Also, it includes a set of libraries that have been replaced some places with the libav fork.

If you are looking for static binaries, they're here. If that has not worked for you,1 it is not hard to build and install from source, in which case you can configure it anyway you want. The source tarballs are further down that page. The wiki has a page about compiling and installing on CentOS, although it is into $HOME, which is probably not what unless you have to (because, e.g., it's not your computer). Presuming it is your computer I'll give you a alternate-parallel guide to install it system-wide, which is preferable. You must do ALL of this su root or via sudo. It's simpler than it looks, BTW; 5 simple steps:

  1. Make sure you have the pre-reqs: yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel.

  2. mkdir -p /usr/local/src. Then move the tarball into there and unpack it: tar -xjf ffmpeg-2.1.3.tar.bz2 if you got the bzip2 ball or tar -xzf ffmpeg-2.1.3.tar.gz if you got the gzip ball. You may need to yum install tar (and/or bzip2 or gzip) if you don't have those already. Once all that's done, move into the created directory: cd ffmpeg-2.1.3.

  3. The potentially complicated part is configuration. You haven't said exactly what you want this for, but if it is just recoding from one common format to another, the default should be fine; I did this recently and I think it includes everything it can, but to be sure you may want to have a look at the list of available encoders and decoders:

    ./configure --list-encoders
    ./configure --list-decoders
    

    If there's anything there you know you want, you can make sure it gets built by including --enable-encoder=[whatever] (or --enable-decoder) when you configure. Presuming you are not re-distributing this, you might as well also use --enable-nonfree,1 which is the stuff the distros definitely leave out of their builds (and, I'd guess, the static binaries). So for example:

    ./configure --enable-encoder=mpeg4 --enable-encoder=pcm_u8 --enable-decoder=wmv3 --enable-nonfree --enable-gpl
    

    The last one (--enable-gpl) isn't enabled by default but pretty much everyone will want it; for more information, look at ./configure --help | less. Don't go crazy with this by listing every single encoder; I'm pretty sure they almost all get build in anyway. Choose one or two if you want and then if something doesn't work out, you can rebuild and re-install; it is easier the second time.

    Before you do the configure, have a look at the various libraries listed at the top of the wiki page under "Compilation & Installation" (x264, libfdk_aac, etc.) to see if there's anything there you want. You probably don't; if you don't recognize anything, don't worry about it. If you do:

    • Follow the directions there but leave out the --prefix="$HOME/ffmpeg_build" and --bindir="$HOME/bin switches to the individual ./configure commands.

    • Run ldconfig and make sure your $PATH is correct after that, see step #5.2 To be clear: you only need to do this now if you built third party libs.

  4. Build, check, install. If configure does not exit cleanly, leave a comment here with the output. Otherwise go ahead and make. If you have a multi-core system, speed that up with make -j N where N is a number of cores (your total - 1 is good if you want to use the system during the compile, total + 1 is ideal if you don't).

    If the build finished without error, make test (if that doesn't do anything make check -- I can't remember which is used). That should take a minute or two and finish without any failures. At that point you can do a make install.

  5. Set paths. The tools were installed into /usr/local/bin, so make sure that is at the beginning of your path, e.g.:

    > echo $PATH
    /usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:[...]
    

    Notice /usr/local/bin preceeds /usr/bin and likewise with sbin. This means if some distro version is installed, your custom one will take precedence. If your $PATH is not like that, create an /etc/profile.d/local.sh with one line in it:

    export PATH=/usr/local/bin:$PATH
    

    I'm not worried about sbin since nothing from ffmpeg (or generally, anything else) ends up there. Also execute that line now in in your current terminal. Other users will have to log in again to make it effective.

    Finally, you need to make sure the libraries are available to the system linker (see man ldconfig). Check:

    grep /usr/local/lib /etc/ld.so.conf.d/*
    

    If you do not get any output, create a file /etc/ld.so.conf.d/local.conf with one line:

    /usr/local/lib
    

    You can add /usr/local/lib64 on a 64-bit system. Ffmpeg doesn't install to there but some things do and you may end up doing this again with those somethings one day.

    Now run ldconfig. This is crucial. Without that, the system won't be able to find the libraries the ffmpeg binary is linked to.

You can undo all this with make uninstall. As mentioned in step #3, you can also re-built/install again later if you want to change the configuration. First make clean then start from #3 (you don't have to make uninstall first). At #5 all you'll have to do is ldconfig this time.


1. See my comment about --enable-nonfree in step #3. I haven't used the static binaries, but my guess is they do not include everything.

2. So the procedure if you are also building third party libs is to make and install all of them, then proceed with step #5, then #4, then all you have to do from #5 again afterward is run ldconfig.

2
  • WOW! I will definitely be learning a lot here, thank you so much for giving a step by step guide with explanation. The two main things I know I want is ffplay and subtitle hard coding other than that I will find things along the way for converting various streams. Thank you so much, I am sure I will come back with more questions trying to follow the above but I will first spend a good deal of time with trial and error.
    – cea
    Feb 23 '14 at 23:33
  • stuck on paths, I read carefully your instructions but ended up following ffmpeg.org document and it doesn't include paths and ldconfig command so everything is compiled now in ~/ but ffmpeg cannot be found. I am not advanced enough to fill in the gaps of your instructions and am still looking for clues.
    – cea
    Feb 28 '14 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.