Flash streaming with mod flvx

From mosalov.com
Jump to: navigation, search

Prepare video for streaming

There are two steps:

  1. convert video from some format to flv format using mencoder;
  2. update meta information in flv file using FLVtool2.

I use a small batch file to do it.

E:\>convert.bat source.avi destination.flv

Where convert.bat is:

SET SRC=%1
SET DST=%2

SET MENCODER=c:\heap\mencoder-p4-svn-22472\mencoder.exe
SET FLVTOOL2=c:\heap\flvtool2-1.0.6\flvtool2.exe
SET VF=scale,kerndeint,crop=304:228:16:12,scale=320:240
SET LAVCOPTS=vcodec=flv:keyint=50:vbitrate=300:mbd=2:mv0:trell:v4mv:cbp:last_pred=3
SET LAVFOPTS=i_certify_that_my_video_stream_does_not_use_b_frames
SET FPS=15
SET SOUND=-oac mp3lame -lameopts abr:br=64 -srate 22050
SET VIDEO=-ofps %FPS% -ovc lavc -lavfopts %LAVFOPTS% -lavcopts %LAVCOPTS% -vf %VF%

REM Encode

%MENCODER% %SRC% -o %DST% -of lavf %SOUND% %VIDEO% %3 %4 %5 %6 %7 %8

REM Update meta information

%FLVTOOL2% -UP %DST%

Install mod_flvx

I hope you have already installed Apache web server.

  1. Download mod_flvx.c
  2. Compile and install module:
    $ sudo /usr/local/apache2/bin/apxs -i -a -c mod_flvx.c
    
  3. Add
    AddHandler flv-stream .flv
    

    to /usr/local/apache2/conf/httpd.cond

  4. Reload configuration:
    sudo kill -1 `cat /usr/local/apache2/logs/httpd.pid`
    

How to install mod_flvx under Windows?

N.B.: There is a buid of the old version of mod_flvx (08-Mar-2007 02:00).

I use Microsoft Visual Studio 2005 Express Edition to compile mod_flvx for XAMPP. There are:

  • archive of all files;
  • mod_flvx.so (just copy to modules/mod_flvx.so in your Apache tree).

There is a compile script:

cl.exe /nologo /MT /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG -I"C:\Program Files\xampp\apache\include" -c mod_flvx.c
link.exe  kernel32.lib /nologo /subsystem:windows /dll /machine:I386 /libpath:"C:\Program Files\xampp\apache\lib" libaprutil-1.lib libapr-1.lib libhttpd.lib mod_flvx.obj
rename mod_flvx.dll mod_flvx.so

Install flv player and publish your video

Scrubber is a flv player.

  1. Download FLVScrubber2.zip and unpack it on your site:
    m1 htdocs # mkdir FLVScrubber2
    m1 htdocs # cd FLVScrubber2/
    m1 FLVScrubber2 # wget http://topfstedt.de/FLVScrubber2/FLVScrubber2.zip
    m1 FLVScrubber2 # unzip FLVScrubber2.zip
    Archive:  FLVScrubber2.zip
      inflating: README.txt
      inflating: FLVScrubber2.swf
      inflating: FLVScrubber2.fla
    m1 FLVScrubber2 #
    
  2. Create somewhere on your site a page with following code:
    <object width="323" height="283">
         <param
              name="movie"
              value="http://HOST/FLVScrubber2/FLVScrubber2.swf?file=http://HOST/FILE.flv&bufferTime=3&startAt=0&autoStart=false" />
         <param name="allowScriptAccess" value="sameDomain" />
         <param name="allowFullScreen" value="true" />
         <embed 
              src="http://HOST/FLVScrubber2/FLVScrubber2.swf?file=http://HOST/FILE.flv&bufferTime=3&startAt=0&autoStart=false"
              type="application/x-shockwave-flash"
              allowScriptAccess="sameDomain"
              allowFullScreen="true"
              width="323" height="283" />
    </object>
    
  3. where

    HOST
    is your site's hostname;
    FILE
    is a path to your .flv movie.

How it works together?


Download

There is an archive of

  • mencoder.exe
  • flvtool2.exe
  • convert.bat
  • sample index.html
  • sample test.flv
  • ...

Links

flv players

flv and MediaWiki

Comments

<comments />