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.
- 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.
- 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
- 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
- Lets install now the ffmpeg by executing:
yum -y --enablerepo=atrpms install ffmpeg
- To verify if ffmpeg is already installed:
ffmpeg -version
or
which ffmpeg
- 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
- 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.
Comments
arpeggio
Wed, 09/23/2015 - 22:10
In reply to I cannot install atrpms repository in my centos(6&7) machine by pandiyan (not verified)
The atrpms repository is down
The atrpms repository is down http://unix.stackexchange.com/questions/229661/is-atrpms-dead. You can also use its mirror repository:
rpm -ivh https://www.mirrorservice.org/sites/dl.atrpms.net/el7-x86_64/atrpms/stable/atrpms-repo-7-7.el7.x86_64.rpm
... then continue guide above from step #3.
ffmpeg package
there is no package available http://dl.atrpms.net/all/atrpms-repo-6-7.el6.x86_64.rpm
ATRPMS mirrors
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
Please help me: How to install FFMPEG-PHP extension?
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!
arpeggio
Thu, 12/15/2016 - 16:21
In reply to Please help me: How to install FFMPEG-PHP extension? by Mark Edwards (not verified)
In my application I used…
In my application I used direct shell execution of ffmpeg and no ffmpeg-php extension. Please check sample code at step # 7 of the article above.
Mark Edwards (not verified)
Thu, 12/15/2016 - 23:20
In reply to In my application I used… by arpeggio
After installing FFMPEG, how to install the FFMPEG-PHP extension
Yes, I did as in the article and everything went well. I have FFMPEG installed. The question is how to install the FFMPEG-PHP extension in accordance with the codes of your article?
Help me, please.
arpeggio
Fri, 12/16/2016 - 12:36
In reply to After installing FFMPEG, how to install the FFMPEG-PHP extension by Mark Edwards (not verified)
I have not installed and…
I have not installed and used ffmpeg-php extension in my application. In other words the sample code at step # 7 of the article above will work without installing ffmpeg-php extension. The ffmpeg-php extension mentioned above is just FYI.
I cannot install atrpms repository in my centos(6&7) machine
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
[[email protected] 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.