Archive for the tag 'ffmpeg'

SB-Shibu

FFmpeg error

FFmpeg error

After installing FFMpeg , when you execute the command : ffmpeg or ffmpeg -v, you may receive an error.

ffmpeg: error while loading shared libraries: libavformat.so.50:

Resolution :

Execute the following command :

export LD_LIBRARY_PATH=/usr/local/lib:LD_LIBRARY_PATH

But this value will be cleared once you log off that session.

So it is better to save this value in bashrc.

vi .bashrc
LD_LIBRARY_PATH=/usr/local/lib
SB-Shibu

FFMPEG in Debian

FFMPEG in Debian

Install the essentials

apt-get update
apt-get upgrade
apt-get install libjpeg-progs libjpeg62 libjpeg62-dev libsdl1.2-dev php5-dev build-essential

Create a directory and download all the files inside it

cd /usr/local/ffmpeg
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
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://ftp.penguin.cz/pub/users/utx/amr/amrnb-6.1.0.4.tar.bz2

Extract all the files

tar zxvf flvtool2_1.0.5_rc6.tgz
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
bzip2 -cd amrnb-6.1.0.4.tar.bz2 | tar xvf -

We need a codec directory

mkdir /usr/local/lib/codecs/

Install Ruby on Rails, subversion & ncurses

apt-get install subversion ruby libcurses-ruby

Run some SVN queries

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

Copy Codecs for mplayer

mv /usr/local/ffmpeg/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

We also need to secure the tmp directory

mkdir /usr/local/ffmpeg/tmp
chmod 777 /usr/local/ffmpeg/tmp
export TMPDIR=/usr/local/ffmpeg/tmp

Install lame

cd /usr/local/ffmpeg/lame-3.97
./configure
make && make install

Install libogg

cd /usr/local/ffmpeg/libogg-1.1.3
./configure && make && make install

Install libvorbis

cd /usr/local/ffmpeg/libvorbis-1.1.2
./configure && make && make install

Install flvtool2

cd /usr/local/ffmpeg/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Install mplayer & mencoder

cd /usr/local/ffmpeg/mplayer
./configure –enable-jpeg
make && make install

Install AMR (for 3gp conversion)

cd /usr/local/ffmpeg/amrnb-6.1.0.4
./configure
make && make install

Install ffmpeg

cd /usr/local/ffmpeg/ffmpeg/
./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared –enable-amr-nb
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
ln -s /usr/local/lib/libamrnb.so.2 /usr/lib/libamrnb.so.2

Install ffmpeg-php

cd /usr/local/ffmpeg/ffmpeg-php-0.5.0/
phpize
./configure
make
make install

You now need to add the new ffmpeg-php module to the php.ini file

pico /etc/php5/apache2/php.ini
extension=ffmpeg.so (add this line to the end of the file)

Restart & done

/etc/init.d/apache2 restart

Verify your work:

php -r ‘phpinfo();’ | grep ffmpeg

This is a common error when we issue a “php -v” over command line or when we browse a phpinfo.php on a site.

To quickly fix this problem you will need to recompile your ffmpeg-php again.

How we fix this?

1)

  1. #cd %ffmpeg-php-DIR%
  2. #vi ffmpeg-php.c

remove/comment the call to av_free_static()

save.

2)

rebuild ffmpeg-php and place the new ffmpeg.so on your extension directory.

 

Should be fixed.

 

 

Nick

HOW-TO FFMPEG under Linux.

On the last few months, we have seen a lot of customers trying to setup his own Video Sharing site (ex: youtube clone) with no luck, the implementation it’s not that hard to setup your linux server to allow video streaming. There are a lot of youtube sites around that may do this, what you only need is to setup your linux system to work with the requirements. Due this we have made this HOW TO FFMPEG post so customers and non-customers would do this by their end.

Requirements:

FFMPEG
FFMPEG-PHP
Mplayer
Mencoder
flv2tool (RUBY ON RAILS REQUIRED)
LAME MP3 Encoder
Libogg
Libvorbis

—————————–

1) We download all the necessary packages.

  1. cd /usr/local/src
  2. wget http://www.serverbuddies.com/files/ffmpeg/essential-20061022.tar.bz2
  3. wget http://www.serverbuddies.com/files/ffmpeg/ffmpeg-php-0.5.0.tbz2
  4. wget http://www.serverbuddies.com/files/ffmpeg/flvtool2_1.0.5_rc6.tgz
  5. wget http://www.serverbuddies.com/files/ffmpeg/lame-3.97.tar.gz
  6. wget http://www.serverbuddies.com/files/ffmpeg/libogg-1.1.3.tar.gz
  7. wget http://www.serverbuddies.com/files/ffmpeg/libvorbis-1.1.2.tar.gz
  8. svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
  9. svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

2) in order to install all the packages, we extract all of them.

  1. tar xzvf flvtool2_1.0.5_rc6.tgz
  2. tar xzvf lame-3.97.tar.gz
  3. tar xzvf libogg-1.1.3.tar.gz
  4. tar xzvf libvorbis-1.1.2.tar.gz
  5. tar xzvf flvtool2_1.0.5_rc6.tgz
  6. tar xjvf essential-20061022.tar.bz2
  7. tar xjvf ffmpeg-php-0.5.0.tbz2

3) We create a codecs directory so we can use it as default codec dir later. Then we copy the mplayer codecs to the new directory.

  1. mkdir /usr/local/lib/codecs/
  2. mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
  3. chmod -R 755 /usr/local/lib/codecs/

4) We create a temporary TMP dir in order to safe compile everything.

  1. mkdir /usr/local/src/tmp
  2. chmod 777 /usr/local/src/tmp
  3. export TMPDIR=/usr/local/src/tmp

5) We start compiling & installing packages

a) For LAME:

  1. cd /usr/local/src/lame-3.97
  2. ./configure
  3. make
  4. make install

b) For LIBOGG:

  1. cd /usr/local/src/libogg-1.1.3
  2. ./configure
  3. make
  4. make install

c) For LIBVORBIS:

  1. cd /usr/local/src/libvorbis-1.1.2
  2. ./configure
  3. make
  4. make install

d) For FLVTOOL2:

  1. cd /usr/local/src/flvtool2_1.0.5_rc6/
  2. ruby setup.rb config
  3. ruby setup.rb setup
  4. ruby setup.rb install

e) For MPlayer:

  1. cd /usr/local/src/mplayer
  2. ./configure
  3. make
  4. make install

f) For FFMPEG:

  1. cd /usr/local/src/ffmpeg/
  2. ./configure –enable-libmp3lame –enable-shared
  3. make
  4. make install

Some necessary linking,

  1. ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
  2. ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
  3. ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
  4. ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
  5. ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51

e) For FFMPEG-PHP:

  1. cd /usr/local/src/ffmpeg-php-0.5.0/
  2. phpize
  3. ./configure
  4. make
  5. make install

Finally, we include the ffmpeg-php module to our php.ini

  1. echo ‘extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so’ >> /usr/local/Zend/etc/php.ini

Restart apache:

  1. service httpd restart

DONE!

Your installation is finish, now you need to check if the video streamin is working correctly on your website.

Keep in mind that most of the sites have different video rate conversion, this does not mean the installation is wrong, you will need to look on the PHP code of your video streaming site to see if its using ffmpeg and mencoder command line properly.