One-stop Installation Guide for Create a Linux Server-side FLV conversion environment

2007-8-6 Update: Based on the my own FLV conversion knowledge, I have started a Web 2.0 service call – VCASMO. It is a video + PowerPoint online presentation platform.

If you want to convert other video format to FLV (sorenson codec), everybody will suggest using FFmpeg. In fact, only FFmpeg is not enough for successfully create a server-side command line conversion environment to create FLV with video and audio, plus the FLV 1.1 metadata information. I have stroked for a whole day to setup my Linux server (Fedora Core 3), so I wrote down my note here for other people and myself as a reference.

Purely install FFmpeg is not enough, the FLV converted has no audio, because FLV audio codec is mp3, so you need LAME support. Moreover, the FLV converted has no metadata, you cannot know the dimension, duration such important information for a FLV player swf. Therefore, you need another free tool: FLVTool2, which is written in Ruby, so I have to install Ruby in my server, too.

Overall installation order: LAME->FFmpeg->Ruby->FLVTool2, if you want to access video info through FFmpeg in php, you can install ffmpeg-php, too.

Please login as root first:

Install LAME
Download from LAME site, type the following command to compile and install it:
./configure --enable-shared --prefix=/usr
make
make install

enable-shared to make sure FFmpeg can use LAME later. Type lame in command line to see help after install succeed.

Note: you can also use yum to install FFmpeg, it will install dependency LAME, too, so you can skip this step.
yum install ffmpeg

Install FFmpeg
Download from FFmpeg site through CVS, type the following command to get the latest copies from CVS and save to your $home (currenly path after login into consule) with folder name “ffmpeg”:cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg
To compile and install it, type the following command:
./configure --enable-gpl --enable-mp3lame --enable-shared --prefix=/usr
make clean && make
make install

enable-shared to make sure ffmpeg-php can use FFmpeg later (if you do not use ffmpeg-php, you do not need –enable-shared –prefix=/usr). Type ffmpeg in command line to see help after install succeed.

Note: you can also use yum to install FFmpeg:
yum install ffmpeg

Install Ruby
Download from Ruby site, type the following command to compile and install it:
./configure
make
make install

Install FLVTool2
Download from FLVTool2 site, type the following command to compile and install it:
ruby setup.rb config
ruby setup.rb setup
sudo ruby setup.rb install

Type flvtool2 in command line to see help after install succeed.


Installation is completed here. If you want to access video infomation easily in php, there is a ffmpeg-php you can try. You can follow the instruction inside the package to install it. I installed it as a Shared Extension and did not edit php.ini to add extension=ffmpeg.so When I try its test_ffmpeg.php to verfiy the installation. I saw an error:Unable to load dynamic library './ffmpeg.so' - ./ffmpeg.so: cannot open shared object file: No such file or directoryYou have to copy ffmpeg.so to your php extension folder, or like me, I just copy the file to the same folder of the php script is located.

Follow up

Other Reference

89 replies on “One-stop Installation Guide for Create a Linux Server-side FLV conversion environment”

  1. Hi nice how to!

    But i got one problem, there is no sound in the .flv file?

    “FFmpeg version HEAD, Copyright (c) 2000-2004 Fabrice Bellard
    configuration:
    libavutil version: 49.0.0
    libavcodec version: 51.9.0
    libavformat version: 50.4.0
    built on Oct 10 2006 14:11:16, gcc: 3.3.1 (SuSE Linux)
    Input #0, mpeg, from ‘2352545623236433.mpeg’:
    Duration: 00:00:14.3, start: 0.220000, bitrate: 1204 kb/s
    Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 320×240, 104857 kb/s, 25.00 fps(r)
    Stream #0.1[0x1c0]: Audio: mp2, 32000 Hz, stereo, 128 kb/s
    File ‘video2.flv’ already exists. Overwrite ? [y/N] y
    Output #0, flv, to ‘video2.flv’:
    Stream #0.0: Video: flv, yuv420p, 320×240, q=2-31, 200 kb/s, 25.00 fps(c)
    Stream mapping:
    Stream #0.0 -> #0.0
    [flv @ 0x4034b6e0]removing common factors from framerate
    Press [q] to stop encoding
    frame= 445 q=1.6 Lsize= 526kB time=17.8 bitrate= 242.1kbits/s
    video:519kB audio:0kB global headers:0kB muxing overhead 1.342197%”

    Please help me 🙂

  2. i followed all steps from
    http://luar.com.hk/blog/?p=669
    and it went all ok but still it returns output without sound

    here is the output i reace when i run
    ffmpeg -i Eric_Promo1.wmv -ar 22050 -ab 32 -f flv -s 320×240 – | flvtool2 -U stdin video.flv

    i get …

    FFmpeg version SVN-r6674, Copyright (c) 2000-2006 Fabrice Bellard, et al.
    configuration:
    libavutil version: 49.0.2
    libavcodec version: 51.22.0
    libavformat version: 50.6.0
    built on Oct 27 2006 12:24:26, gcc: 4.1.1 20060525 (Red Hat 4.1.1-1)

    Seems that stream 0 comes from film source: 1000.00 (1000/1) -> 31.25 (125/4)
    Input #0, asf, from ‘Eric_Promo1.wmv’:
    Duration: 00:01:10.5, start: 2.000000, bitrate: 302 kb/s
    Stream #0.0: Video: msmpeg4, yuv420p, 320×240, 31.25 fps(r)
    Stream #0.1: Audio: mp2, 32000 Hz, stereo, 64 kb/s
    Output #0, flv, to ‘pipe:’:
    Stream #0.0: Video: flv, yuv420p, 320×240, q=2-31, 200 kb/s, 31.25 fps(c)
    Stream mapping:
    Stream #0.0 -> #0.0
    Press [q] to stop encoding
    [msmpeg4 @ 0x84b31d8]overreading 17 bits.8 bitrate= 403.2kbits/s
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 78 bits
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]ac-tex damaged at 13 14
    [msmpeg4 @ 0x84b31d8]
    error while decoding block: 13 x 14 (5)
    [msmpeg4 @ 0x84b31d8]Error at MB: 307
    [msmpeg4 @ 0x84b31d8]concealing 110 DC, 110 AC, 110 MV errors
    [msmpeg4 @ 0x84b31d8]ignoring overflow at 15 14ate= 352.2kbits/s
    [msmpeg4 @ 0x84b31d8]ac-tex damaged at 16 14
    [msmpeg4 @ 0x84b31d8]
    error while decoding block: 16 x 14 (5)
    [msmpeg4 @ 0x84b31d8]Error at MB: 310
    [msmpeg4 @ 0x84b31d8]concealing 192 DC, 192 AC, 192 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 1 bits
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]ignoring overflow at 19 14rate= 301.3kbits/s
    [msmpeg4 @ 0x84b31d8]overreading 44 bits9.4 bitrate= 276.1kbits/s
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 35 bits4.0 bitrate= 255.6kbits/s
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]ac-tex damaged at 15 14
    [msmpeg4 @ 0x84b31d8]
    error while decoding block: 15 x 14 (5)
    [msmpeg4 @ 0x84b31d8]Error at MB: 309
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]ac-tex damaged at 17 14bitrate= 251.2kbits/s
    [msmpeg4 @ 0x84b31d8]
    error while decoding block: 17 x 14 (5)
    [msmpeg4 @ 0x84b31d8]Error at MB: 311
    [msmpeg4 @ 0x84b31d8]concealing 231 DC, 231 AC, 231 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 115 bits.7 bitrate= 246.6kbits/s
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 46 bits8.7 bitrate= 243.5kbits/s
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]ac-tex damaged at 13 14
    [msmpeg4 @ 0x84b31d8]
    error while decoding block: 13 x 14 (5)
    [msmpeg4 @ 0x84b31d8]Error at MB: 307
    [msmpeg4 @ 0x84b31d8]concealing 193 DC, 193 AC, 193 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 13 bits3.5 bitrate= 240.9kbits/s
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 13 bits
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    [msmpeg4 @ 0x84b31d8]overreading 106 bits
    [msmpeg4 @ 0x84b31d8]concealing 300 DC, 300 AC, 300 MV errors
    frame= 2197 q=5.3 Lsize= 2043kB time=70.3 bitrate= 238.0kbits/s
    video:2008kB audio:0kB global headers:0kB muxing overhead 1.718160%

  3. Hi

    I am using php,ffmpeg converstion of files(avi,mpeg..) into .flv file. Now i need to add meta data (header) to the flv file.

    So, please help me regording this info.

    Cheers,
    Praveen

  4. I’m working on a site, but my friend can’t see the video’s playing in the flash player. I have put the debugger mode on but all videos you can see running in the background. Can you guys view the movies running with IE and FF? Please do let me know cause he says its something about the scripts but all my other friends can see all. For the converting I have used FFMPEG. For me all runs fine, but for him it runs sometimes yes and sometimes not. Can anyone help me. This is the site: http://eunoia.estebanmedia.com

  5. Hi, I followed the above steps and compiled ffmpeg source. the installation went fine. But when I try to run the binary (ffmpeg) it gives this error.
    ffmpeg: error while loading shared libraries: libavformat.so.51: cannot open shared object file: No such file or directory

    Any suggestions please?

  6. Hi,
    A very nice guide for ffmpeg installation.
    I am new to php and i have to use ffmpeg in my site to
    1)convert video files to flv format.
    2)Make 5 thumbnails from frame 5 to 10 of the video.
    3) Run the video in flash player

    Can anybody guide me through this ASAP.

  7. HI. I see instalation process but I no make ffmpeg.so.
    First I tar xjf ffmpeg-php.X.X.X.bz2, then cd /ffmpeg , and phpize. but than it happend this error:
    ————————————–
    [root@trader ffmpeg-php-0.5.0]# phpize
    Configuring for:
    PHP Api Version: 20031224
    Zend Module Api No: 20041030
    Zend Extension Api No: 220040412
    /usr/bin/phpize: line 105: aclocal: command not found
    ———————————
    So do you have any SUGGESTION about this????

    10x alot:)

    ps. I’m have PLESK in my PC

  8. In response to message 11 (no sound), I found the lame instructions needed to be changed (add –enable-mp3lame –enable-gpl) …

    cd [lame src directory]
    make clean
    ./configure –enable-mp3lame –enable-gpl –enable-shared –prefix=/usr
    make
    make install

    Voila! Sound.

    Brian

  9. Sorry, my last comment is wrong, the make command is for ffmpeg and it is the same as the instructions. However, for some reason, re-making ffmpeg with the above instructions (cd into ffmpeg) sorted the sound.

    Sorry for the noise.

    Brian

  10. the option: –mp3lame for the ffmpeg install is wrong, it should read –libmp3lame, mp3lame is no longer an option with the most current revision of ffmpeg. Other than that, everything went fine.

  11. Hi all

    Very nice site! Very informative to say the least
    Great Post, now it would be nice to convert some WMV files that are conflictive to get absolutely transparent to the user, any ideas?

  12. Hi,
    I have a new requirement in my website where i have to convert mpeg formet to flv formet automatically while user upload videos(Similar to what ppl did in http://www.youtube.com). Can any one suggest me how i can use FFMPEG effectivly for my requirement. I am working in windows XP & my application developed using Java..
    any ideas????

  13. Hello,
    Great Guide!

    Can you help me? Once I Download LAME where do I upload it to on my server? And after that when I type:
    cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg

    into Terminal (My SSH) I get:
    -bash: cvs: command not found

    Thanks

  14. I already have ffmpeg and ruby on my server from host if anyone can help me i know nothing about this i am willing to pay for the help i really need the convert to flv on my site thanks

  15. Hi

    I am using php,ffmpeg converstion of files(avi,mpeg..) into .flv file. Now i need to add meta data (header) to the flv file.

    So, please help me regording this info.

    Cheers,
    Praveen

  16. to kim (http://luar.com.hk/blog/?p=669#comment-59439):

    if you have problem says

    `ffmpeg: error while loading shared libraries: libavformat.so.51: cannot open shared object file: No such file or directory`

    then, you should finalize the codec setups by doing this

    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

  17. Latest ffmpeg adds FLV metadata what is enough to make video scrollable in player.

    I would suggest to use mencoder what have much wider possibilities about encoding and what will use ffmpeg libraries anyway.

    Ruby FLVtool2 will add some more extended information like keyframes index, so video can be played on players what support progressive streaming (e.g. google video, you can scroll video to any location without need to download it fully).

    FLVtool2 problem is that its veeeery slow and consumes alot of memory (i tried to process 350mb FLV file, it took 500mb RAM and needed around 40 minutes to finish it).

    Just an example for getting FLV video file from nearly ANY (mencoder supports hundreds of video formats) would be (taken from mencoder FAQ):

    mencoder input.avi -o output.flv -of lavf -oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3

    It will encode output video to 500kbits video data rate (video will be about 560kbits rate with audio together).

    In most cases its too much for web 😉 Reducing video framesize (e.g. 320×200 is sufficent for most web things), reducing frames per seconds and lowering bitrates can make output file really small (often 10% of original one)

  18. Pingback: Anytime Anyplace
  19. Should someone encounter the error
    Unknown option “–enable-mp3lame”

    Nevermind…
    The option has been changed to “–enable-libmp3lame”.

  20. when i install lame have problem.
    ./configure is no problem for lame
    however when i make have error
    i try to install in debian3.1/4 /centos 4/5
    also have the same problem….
    anyone can have me ?

    ==============================
    me.a -lm
    make[2]: Leaving directory `/tmp/lame-3.96.1/frontend’
    Making all in Dll
    make[2]: Entering directory `/tmp/lame-3.96.1/Dll’
    make[2]: Nothing to be done for `all’.
    make[2]: Leaving directory `/tmp/lame-3.96.1/Dll’
    Making all in debian
    make[2]: Entering directory `/tmp/lame-3.96.1/debian’
    make[2]: Nothing to be done for `all’.
    make[2]: Leaving directory `/tmp/lame-3.96.1/debian’
    Making all in doc
    make[2]: Entering directory `/tmp/lame-3.96.1/doc’
    Making all in html
    make[3]: Entering directory `/tmp/lame-3.96.1/doc/html’
    make[3]: Nothing to be done for `all’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/doc/html’
    Making all in man
    make[3]: Entering directory `/tmp/lame-3.96.1/doc/man’
    make[3]: Nothing to be done for `all’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/doc/man’
    make[3]: Entering directory `/tmp/lame-3.96.1/doc’
    make[3]: Nothing to be done for `all-am’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/doc’
    make[2]: Leaving directory `/tmp/lame-3.96.1/doc’
    Making all in include
    make[2]: Entering directory `/tmp/lame-3.96.1/include’
    make[2]: Nothing to be done for `all’.
    make[2]: Leaving directory `/tmp/lame-3.96.1/include’
    Making all in misc
    make[2]: Entering directory `/tmp/lame-3.96.1/misc’
    make[2]: Nothing to be done for `all’.
    make[2]: Leaving directory `/tmp/lame-3.96.1/misc’
    Making all in dshow
    make[2]: Entering directory `/tmp/lame-3.96.1/dshow’
    make[2]: Nothing to be done for `all’.
    make[2]: Leaving directory `/tmp/lame-3.96.1/dshow’
    Making all in ACM
    make[2]: Entering directory `/tmp/lame-3.96.1/ACM’
    Making all in ADbg
    make[3]: Entering directory `/tmp/lame-3.96.1/ACM/ADbg’
    make[3]: Nothing to be done for `all’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/ACM/ADbg’
    Making all in ddk
    make[3]: Entering directory `/tmp/lame-3.96.1/ACM/ddk’
    make[3]: Nothing to be done for `all’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/ACM/ddk’
    Making all in tinyxml
    make[3]: Entering directory `/tmp/lame-3.96.1/ACM/tinyxml’
    make[3]: Nothing to be done for `all’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/ACM/tinyxml’
    make[3]: Entering directory `/tmp/lame-3.96.1/ACM’
    make[3]: Nothing to be done for `all-am’.
    make[3]: Leaving directory `/tmp/lame-3.96.1/ACM’
    make[2]: Leaving directory `/tmp/lame-3.96.1/ACM’
    Making all in mac
    make[2]: Entering directory `/tmp/lame-3.96.1/mac’
    make[2]: Nothing to be done for `all’.
    make[2]: Leaving directory `/tmp/lame-3.96.1/mac’
    make[2]: Entering directory `/tmp/lame-3.96.1′
    make[2]: Nothing to be done for `all-am’.
    make[2]: Leaving directory `/tmp/lame-3.96.1′
    make[1]: Leaving directory `/tmp/lame-3.96.1′

Comments are closed.