How to use ffmpeg if libmp3lame support is not present
12th April 2008
I’m providing regularly updated compiled linux and freebsd ffmpeg binaries, and also described how to use ffmpeg on shared hostings if not all the required libraries (like libmp3lame) are present. However, the solution recommended might not “fit all”, so here is another one – simpler and even more portable/universal than setting LD_LIBRARY_PATH.
The solution is simple – I first proposed it in the Getting ffmpeg working with flashvideo on various platforms issue page on Drupal.org.
The idea is: if the original audio stream in the file is already compressed (most of the time it is), then you do not need to recompress it – and do not need libmp3lame or any other audio codec! To achieve the “ffmpeg direct stream copy” functionality, you can add one of the two options:
-vcodec copy will direct-stream-copy video (no re-compression),
-acodec copy will direct-stream-copy audio (no re-compression).
In other words, ffmpeg option -acodec copy should just copy the original audio from input file to output file without alteration, and will not require any audio codecs support.
Sample command line could be (in the example, a 1-minute fragment of the input file is just copied into the output file):
ffmpeg -t 00:01:00 -i movie.avi -vcodec copy -acodec copy preview.avi
This tip is based on the information initially obtained from the ffmpeg-user mailing list archive for June of 2005.
May 22nd, 2008 at 3:43
This article shows how to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source. It should work on most systems, however may need some tweaking from system to sytem.
cd /usr/local/src
Download source tarballs:
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget http://www4.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
Extract the tarballs:
tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf flvtool2_1.0.5_rc6.tgz
tar jxvf essential-20061022.tar.bz2
tar jxvf ffmpeg-php-0.5.0.tbz2
tar zxvf flvtool2_1.0.5_rc6.tgz
Make a directory to store all the codecs:
mkdir /usr/local/lib/codecs/
Install any necessary packages:
yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ gcc4-gfortran
yum install subversion ruby ncurses-devel
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update
cd /usr/local/src
Copy codecs for mplayer:
mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
If you are using secure tmp:
mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp
Installing Lame:
cd /usr/local/src/lame-3.97
./configure
make && make install
Installing Libogg:
cd /usr/local/src/libogg-1.1.3
./configure && make && make install
Installing libvorbis:
cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install
Installing flvtool2:
cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd /usr/local/src/mplayer
./configure && make && make install
Installing ffmpeg:
cd /usr/local/src/ffmpeg/
./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared
make && make install
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
Installing ffmpeg-php:
cd /usr/local/src/ffmpeg-php-0.5.0/
phpize
./configure
make
make install
Note: Make sure this is the correct php.ini for this server.
echo ‘extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so’ >> /usr/local/Zend/etc/php.ini
Restart apache:
service httpd restart
May 22nd, 2008 at 9:07
Thanks for extended information! I wonder who would be the initial author of this short manual – little search gives too many results to figure it out
One notice, though: this “manual” assumes that the person has full access to the Linux PC; my advice in this and linked posts is targeted at shared hosting users, who do not have sufficient access rights, but still (after some tweaking) can use ffmpeg/libmp3lame/etc for the multimedia purposes on their websites.
July 9th, 2008 at 22:20
hi,
nice tutorial.
October 13th, 2008 at 18:28
Hi,
Your tutorial was just perfect, I’ve done all the steps and all exept:
./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared
did not work as I had to change the command to:
./configure -–enable-libmp3lame –-enable-libvorbis –-disable-mmx –-enable-shared
And also remobed the –enable-libogg from the list as the new ffmpeg dose not include the –enable-libogg on the ./configure
Thank you very much