UnixServerAdmin

Server Administration & Management

ffmpeg.so: undefined symbol: av_free_static

When we issue a “php -v” over command line or when we browse a phpinfo.php on a site this error occours.

Go to the source directory ffmpeg-phpXX.XX

# vi ffmpeg-php.c

comment the line
———————–
av_free_static()
———————–

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

# phpize

# ./configure

# make

# make install

October 2, 2011 Posted by | FFMPEG | | Leave a comment

How to converting flv files to avi & mpeg using ffmpeg

FFMPEG is a good tool in linux which can be used to covert videos in to different format.

convertting flv format video to avi and mpg.

1) Run ffmpeg command :-

# ffmpeg -i input.flv output.avi

Here -i stands for input and output.avi is the output file in avi or mpg.

2) Advanced Options :-

# ffmpeg -i input.flv -ab 56 -ar 22050 -b 500 -s 320×240 output.mpg

where

-ab is audio bitrate with default of 64kbps
-ar is audio samplerate with default of 44100Hz
-b is video bitrate with delault of 2000kbps
-s is size with default of 160x128px

October 1, 2011 Posted by | FFMPEG | , | Leave a comment

“ffmpeg headers not found” error while installing ffmpeg in cPanel Servers

The error received is

checking for ffmpeg support… yes, shared
checking for ffmpeg headers… configure: error: ffmpeg headers not
found. Make sure you’ve built ffmpeg as shared libs using the –enable-shared option

This is due to missing header files in  “/usr/local/include/ffmpeg” directory.

Check whether the directory “/usr/local/include/ffmpeg” exists else create it.

# mkdir /usr/local/include/ffmpeg

The copy the header files.

# cp -p /usr/local/src/ffmpeg/libavformat/avio.h /usr/local/include/ffmpeg

# cp -p /usr/local/src/ffmpeg/libavformat/avformat.h /usr/local/include/ffmpeg

# cp -p /usr/local/src/ffmpeg/libavcodec/avcodec.h /usr/local/include/ffmpeg

You need to install your ffmpeg again. After installing the ffmpeg, install ffmpeg-php.

September 30, 2011 Posted by | FFMPEG | | Leave a comment

How to converting Audio & Videos using FFMPEG

1) This will convert video.mov to video.flv

# ffmpeg -i video.mov video.flv

2) Converting 3GP to FLV using FFMPEG

# ffmpeg -i video.3gp -sameq -an video.flv

This will convert video.3gp file to video.flv (Sound will be disaled in video.flv)

3) Converting Mpeg to FLV using FFMPEG

# ffmpeg -i video.mpeg video.flv

This will convert video.mpeg file to video.flv

4) Converting MPEG to 3GP using FFMPEG

# ffmpeg -i video.mpeg -ab 8.85k -acodec libamr_wb -ac 1 -ar 16000 -vcodec h263 -s qcif video.3gp

5) Converting AVI to FLV using FFMPEG

# ffmpeg -i video.avi -s 500×500 video.flv ( resolution of video.flv wil be  500×500)

6)Creating video thumbnails using ffmpeg

# ffmpeg  -itsoffset -4  -i video.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320×240 video.jpg

This command generates a 320×240 sized PNG thumbnail at the 4th second in the video.

Audio conversion:-

1) Converting WMV to FLV using FFMPEG

# ffmpeg -i audio.wmv audio.flv

This will convert audio.wmv file to audio.flv.

2) Converting AMR to MP3 using FFMPEG

# ffmpeg -i audio1.amr -ar 25050 audio1.mp3

This will convert audio.amr file to audio.mp3  with audio rate of  25.05 KHz

3)Converting WMV to MP3 using FFMPEG

# ffmpeg -i audio1.wmv audio1.mp3

This will convert audio1.wmv file to audio1.mp3

4) Converting aac to mp3 using FFMPEG

# ffmpeg -i audio1.aac -ar 25050 -ab 32 audio1.mp3

This will convert audio.aac to audio.mp3 with audio rate 25.05 KHz and Audio BitRate 32KHz

September 29, 2011 Posted by | FFMPEG | , | Leave a comment

How to install FFMPEG from source code and its modules

This post will provide you with the instructions to download and install ffmpeg, ffmpeg-php, flvtool, lame, mplayer, libogg, libvorbis, mencoder, and other codecs used with ffmpeg. This is used by most of your video sites and youtube clones for video streaming.

1. Create a new Directory under the src folder

# mkdir /usr/local/src/ffmpeg
# cd /usr/local/src/ffmpeg

2. Download all the Sources

# 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

3. Uncompress all the source files

# bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar
# tar zxvf flvtool2_1.0.5_rc6.tgz
# tar zxvf lame-3.97.tar.gz
# bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar
# tar zxvf libogg-1.1.3.tar.gz
# tar zxvf libvorbis-1.1.2.tar.gz

4. Create the new codecs directory and move the codecs

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

5. Install SVN and Ruby

# yum install subversion
# yum install ruby
# yum install ncurses-devel

6. Download the latest FFMPEG and Mplayer from the subversion

# svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
# svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

7. Compile LAME

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

8.Compile libOGG

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

9.Compile libVorbis

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

10.Compile flvtool2

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

11.Compile MPlayer

# cd /usr/local/src/ffmpeg/mplayer
# ./configure
# make
# make install

12.Compile FFMPEG

# cd /usr/local/src/ffmpeg/ffmpeg
# ./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared
# echo ‘#define HAVE_LRINTF 1? >> config.h
# make
# make install

13.Create symblinks

# 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

14.Compile FFMPEG-PHP

# cd /usr/local/src/ffmpeg/ffmpeg-php-0.5.0
# phpize
# ./configure

——————————————————————-
There’s a small issue in this version of ffmpeg-php which, when “make” is run, will cause the following error:

gcc -I. -I/usr/local/src/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/usr/local/src/ffmpeg-php-0.6.0/include -I/usr/local/src/ffmpeg-php-0.6.0/main -I/usr/local/src/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include/libavcodec/ -I/usr/local/include/libavformat/ -I/usr/local/include/libavutil/ -I/usr/local/include/libswscale/ -I/usr/local/include/libavfilter/ -I/usr/local/include/libavdevice/ -I/usr/include/php -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c -fPIC -DPIC -o .libs/ffmpeg_frame.o
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zim_ffmpeg_frame_toGDImage’:
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function)
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.)
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zim_ffmpeg_frame_ffmpeg_frame’:
/usr/local/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1

To correct this issue, we’ll update ffmpeg_frame.c and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32

# vi ffmpeg_frame.c

:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32
:wq!
———————————————————————

Now we can proceed with compiling:

# make
# make install

15.Install FFMPEG-PHP (make sure the php.ini path is correct.)

Get correct php.ini path add the extesion ffmpeg.so Usually it is given as extension=ffmpeg.so and the extension_dir=/usr/local/lib/php/extensions/   Make sure that the ffmpeg.so is in /usr/local/lib/php/extensions/

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

Or the best way is to check the path for extension_dir in php.ini Then locate the file ffmpeg.so. Copy the file ffmpeg.so to extension_dir and add the line extension=ffmpeg.so in php.ini

# vi /etc.php.ini
——————-
extension=ffmpeg.so
——————-

16.Restart Apache to load FFMPEG-PHP

# service httpd restart

17.Verify the installation

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

If you get a few lines such as
———————————————————–
ffmpeg
ffmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.0
ffmpeg.allow_persistent => 0 => 0
———————————————————–

Then everything is installed and working fine.

September 28, 2011 Posted by | FFMPEG | , | Leave a comment