Apache Configuration
Download the
mod_flvx.soandmod_h264_streaming.somodules.
Note: Make sure the x86/x64 versions of Apache and the modules match [the modules below are for Apache x86 2.2 and earlier].
Download link: http://pan.baidu.com/s/1dEzYX4d Password: jb0iEdit
apache\conf\httpd.conf, findLoadModule, and add the following at the end of (or near) theLoadModulesection:1 2 3 4LoadModule flvx_module modules/mod_flvx.so AddHandler flv-stream .flv LoadModule h264_streaming_module modules/mod_h264_streaming.so AddHandler h264-streaming.extensions .mp4Restart Apache. If Apache fails to start, verify that the module versions match your Apache version.
Video Playback Example
Download ckplayer
Any web video player will work. This example uses ckplayer. Download link:
http://www.ckplayer.com/
Configuration guide:
http://www.ckplayer.com/tool/flashvars.htmPlace the ckplayer folder in the website root directory, and place the sample video
example.flvin the website root directory.Create
video.htmlwith the following code:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18<html> <meta charset="utf8"> <head> <title>Streaming Video Playback</title> </head> <body> <div id="a1"></div> <script type="text/javascript" src="/ckplayer/ckplayer.js" charset="utf-8"></script> <script type="text/javascript"> var flashvars={ f:'http://localhost/example.flv', c:0 }; var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'}; CKobject.embedSWF('/ckplayer/ckplayer.swf','a1','ckplayer_a1','600','400',flashvars,params); </script> </body> </html>Open a browser and visit
http://localhost/video.html. You should be able to drag the video scrollbar.
Chrome result:
IE result:
—-Update 20160106—-
The previous test had issues because the FLV file was too small, so it was likely downloaded locally before playback.
The correct way to verify Apache streaming is:Prepare a larger MP4/FLV file and replace the video URL above;
Open Chrome (recommended), and enter
http://localhost/example.mp4?start=10;If the video starts playing from the 10-second mark and supports seeking, the Apache configuration is successful.
The ckplayer mentioned above still requires waiting for the download to complete before sequential playback. It is recommended to use video.js instead, though it requires HTML5 browser support.
HTML code:
| |
After testing, the video can be seeked to any position and played even before it is fully loaded. With this, Apache has achieved pseudo-streaming video playback.