- 影片轉 FLV 檔, 並製作影片截圖
- 在 lighttpd web server 使用加密網址, 隱藏實際影片路徑
- 免費的 Flash FLV Player
影片轉檔安裝 ffmpeg
安裝 flvtool2
影片轉 FLV 檔
ffmpeg -i myvideo.wmv -s 320x240 -r 15 -b 128k -ar 22050 -ab 32k -ac 2 -f flv myvideo.flv
參數說明
-i | input file name |
-s | set video frame size |
-r | set video frame rate |
-b | set video bit rate |
-ar | set audio sampling rate |
-ab | set audio bit rate |
-ac | set number of audio channels |
-f | force format |
加入 metadata
flvtool2 -U myvideo.flv myvideo.flv
製作影片截圖
#截錄第一個畫面 (frame)
ffmpeg -i myvideo.mpg -vframes 1 -s 320x240 -f image2myvideo.jpg
#截錄第 18.5 秒的畫面
ffmpeg -i myvideo.mpg -ss 18.5 -vframes 1 -s 320x240 -f image2myvideo.jpg
參數說明
-i | input file name |
-vframes | set the number of video frames to record |
-s | set frame size |
-ss | set the start time offset |
-f | force format |
-y | overwrite output files |
Ref: [DB75]: Using FFmpeg to Extract PNG Files
建置影片播放平台環境:
- lighttpd 1.4.11 以上
- DocumentRoot: /var/www/html
lighttpd 環境設定
安裝 lighttpd
vi lighttpd.conf
#注意順序: mod_secdownload 須在 mod_flv_streaming 之上
server.modules = (
...
"mod_secdownload",
"mod_flv_streaming",
...
)
flv-streaming.extensions = ( ".flv" )
secdownload.secret = "your_secret"
secdownload.document-root = "/var/www/videos/"
#.flv 存放的位置
secdownload.uri-prefix = "/dl/"
#編碼後的虛擬路徑
secdownload.timeout = 120
#Ref: LightTPD Docs -- Module: mod_secdownload
mkdir /var/www/videos :: 將 .flv 檔案置入 /var/www/videos
/etc/init.d/lighttpd restart :: 重新啟動 lighttpd
取用加密路徑
?
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19
|
#前置作業
<?php
|
;
$uri_prefix
=
"/dl/"
;
# filename
$f
= "/test.flv";
# current timestamp
$t
= time();
$t_hex
= sprintf("%08x", $t); $m
= md5($secret.$f.$t_hex);
?>
#輸出加密路徑 (output: /dl/xxxxxxxx...)
<?php printf(
'%s%s/%s%s', $uri_prefix, $m, $t_hex, $f, $f); ?>
JW FLV Player 使用範例
?
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<? php
|
$uri_prefix
=
"/dl/"
;
$f
= "/myvideo.flv"; $t
= time(); $t_hex
= sprintf("%08x", $t); $m
= md5($secret.$f.$t_hex); ?>
<
html> <
head> <
script type="text/javascript" src="swfobject.js"></script> </
head> <
body>
<
p id="player1"><a href="
http://www.adobe.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>
<
script type="text/javascript">
var s1 = new SWFObject("flvplayer.swf","single","300","240","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("file","<?php printf('%s%s/%s%s', $uri_prefix, $m, $t_hex, $f, $f); ?>");
s1.addVariable("image","myvideo.jpg");
s1.addVariable("displayheight","240");
s1.write("player1"); </
script>
</
body> </
html>
JW FLV Player 播放實例
備註: 以上影片係用 Nikon Coolpix 4300 攝錄, 只有畫面沒有聲音
JW FLV Player 相關網頁
Free Flash Video Players
參考資料
相關網頁