Setup ffmpeg on CentOS 7

I am developing a PHP application that requires converting mp3 to ogg audio format and this will be run on CentOS 7 Linux distro. The ffmpeg is perfect application to accomplish this task. The following steps are tested running on my Linode server running Centos 7 64-bit.

  1. ffmpeg requires libdc1394-devel and it is available in epel repository. Execute the following command to install epel repository:
          
    rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
          
        

    Note: As of this writing the "http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm" is the latest. If this URL returns 404 error it means that new version is released, you may want to browse "http://dl.fedoraproject.org/pub/epel/7/x86_64/e/" to look for that new released version.

  2. ffmpeg is available in ATRPMS Repo. The ATRPMS Repo (http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm) is down, we'll use mirror:
          
    rpm -ivh https://www.mirrorservice.org/sites/dl.atrpms.net/el7-x86_64/atrpms/stable/atrpms-repo-7-7.el7.x86_64.rpm
          
        
  3. Modify the atrpms.repo to update its baseurl:
          
    vi /etc/yum.repos.d/atrpms.repo
          
        

    Under [atrpms] change the baseurl and enabled from:

          
    baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
    enabled=1
          
        

    ... to:

          
    baseurl=https://www.mirrorservice.org/sites/dl.atrpms.net/el$releasever-$basearch/atrpms/stable
    enabled=0
          
        
  4. Lets install now the ffmpeg by executing:
          
    yum -y --enablerepo=atrpms install ffmpeg
          
        
  5. To verify if ffmpeg is already installed:
          
    ffmpeg -version
          
        

    or

          
    which ffmpeg
          
        
  6. To convert mp3 to ogg format, execute the following command:
          
    wget https://ia802508.us.archive.org/5/items/testmp3testfile/mpthreetest.mp3
    ffmpeg -i mpthreetest.mp3 -c:a libvorbis -q:a 4 mpthreetest.ogg
          
        
  7. There is PHP library available here but for simplicity the following PHP codes will suffice:
          
    function convert_mp3_ogg($mp3file) {
      if (`which ffmpeg`) {
        $oggfile = preg_replace('/\.mp3$/', '.ogg', $mp3file);
        shell_exec("ffmpeg -i $mp3file -c:a libvorbis -q:a 4 $oggfile");
        return TRUE;
      }
      return FALSE;
    }
          
        

To know more about ffmepeg check their website.

Tags

Comments

when i run the
#rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm

package epel-release-7-5.noarch is already installed
[root@aryan used]# rpm -ivh http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
Retrieving http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
curl: (7) Failed connect to dl.atrpms.net:80; Connection timed out
error: skipping http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm - transfer failed
..
pleases what is this error ...why this error is occuring.please help me guys.

there is no package available http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm

You can use one of these mirrors:
https://www.mirrorservice.org/sites/dl.atrpms.net/el7-x86_64/atrpms/stable/atrpms-repo-7-7.el7.x86_64.rpm
https://mirror.its.sfu.ca/mirror/CentOS-Third-Party/atrpms/el7-x86_64/stable/atrpms-repo-7-7.el7.x86_64.rpm
http://ftp-stud.fht-esslingen.de/Mirrors/atrpms/dl.atrpms.net/el7-x86_64/atrpms/stable/atrpms-repo-7-7.el7.x86_64.rpm

Hello. I'm new to Linux!
I have a CentOS 7, 64-bit, VPS with Apache / MySQL / PHP server on host Ocean Digital.
I followed all the commands according to your article. I used the ATRPMS mirror: https://mirror.its.sfu.ca/mirror/Centos-Third-Party/atrpms/el7-x86_64/stable/atrpms-repo-7-7.el7.x86_64.rpm
I modified the atrpms.repo and updated the baseurl to: baseurl = https: //mirror.its.sfu.ca/mirror/CentOS-Third-Party/atrpms/el$releasever-$basearch/stable
Enabled = 0
Installed FFMPEG without errors. When I make the command (being as ROOT) ffmpeg -version displays the screen:

Ffmpeg version 2.2.1
Built on Jun 17 2014 01:25:46 with gcc 4.8.2 (GCC) 20140120 (Red Hat 4.8.2-16)
Configuration: --prefix = / usr --libdir = / usr / lib64 --shlibdir = / usr / lib64 --mandir = / usr / share / man --enable-shared --enable-runtime -cpudetect --enable- Gable --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable -x11grab --enable -vdpau --disable-avisynth --enable-frei0r --enable -libdc1394 --enable- Libsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags = '-O2 -g -pipe -Wall -Wp, -D_FORTIFY_SOURCE = 2 -fexceptions -fstack-protector-strong --param = ssp-buffer-size = 4 -grecord-gcc-switches -m64 -mtune = generic -fPIC '--disable-stripping
Libavutil 52. 66,100 / 52 66,100
Libavcodec 55. 52.102 / 55. 52.102
Libavformat 55. 33,100 / 55. 33,100
Libavdevice 55. 10,100 / 55. 10,100
Libavfilter 4. 2.100 / 4. 2.100
Libswscale 2. 5.102 / 2. 5.102
Libswresample 0. 18,100 / 0. 18,100
Libpostproc 52. 3,100 / 52 3,100

So, I congratulate you on the article. Now, how do I install FFMPEG-PHP extension following a compatible way? The version of my PHP is 5.4.16 with Apache version 2.4.6 and MySQL Version: 5.5.50-MariaDB. Please help me!

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.