Flash streaming with mod flvx
From www.mosalov.com
Contents |
[edit]
Prepare video for streaming
There are two steps:
- convert video from some format to flv format using mencoder;
- 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%
[edit]
Install mod_flvx
I hope you have already installed Apache web server.
- Download mod_flvx.c
- Compile and install module:
$ sudo /usr/local/apache2/bin/apxs -i -a -c mod_flvx.c
- Add
AddHandler flv-stream .flv
to /usr/local/apache2/conf/httpd.cond
- Reload configuration:
sudo kill -1 `cat /usr/local/apache2/logs/httpd.pid`
[edit]
How to install mod_flvx under Windows?
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
[edit]
Install flv player and publish your video
Scrubber is a flv player.
- 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 #
- 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> - HOST
- is your site's hostname;
- FILE
- is a path to your .flv movie.
where
[edit]
How it works together?
[edit]
Download
There is an archive of
- mencoder.exe
- flvtool2.exe
- convert.bat
- sample index.html
- sample test.flv
- ...
[edit]
Links
- Original blog entry of Paul Querna about mod_flvx
- mod_flvx. Передача потокового Flash видео
- FLVTool2 — Flash video and meta data manipulation
- Using Lighttpd, Mplayer/Mencoder and Flvtool2 to Implement Flash Video Streaming
- How to create and use Flash video metadata to add cue-points with flvtool2
[edit]
flv players
[edit]
