RTMP文件下载
今天在使用techtalks观看ACL视频时,比较卡顿,萌生了下载的想法
查看一下网页源代码,是flash播放,使用了flowplayer
1 下载
1.1 依赖
需要安装rtmpdump工具,ubuntu下apt-get即可
sudo apt-get install rtmpdump
1.2 下载
rtmpdump -r {server_url} -C B:0 -C Z: \
-C S:/{video_url} \
-C S:BounceAPI3.0 -C N:0.000000 -C S:mp4 \
-y mp4:{video_url} \
-o {save_name}
下面是stackexchange的一个例子
rtmpdump -r rtmp://flash.dce.harvard.edu/bounce -C B:0 -C Z: \
-C S:/2012/02/22872/L01/22872-20120124-L01-1-h264-av1248-16x9-852x480.mp4 \
-C S:BounceAPI3.0 -C N:0.000000 -C S:mp4 \
-y mp4:2012/02/22872/L01/22872-20120124-L01-1-h264-av1248-16x9-852x480.mp4 \
-o a.flv
RTMPDump v2.4-84-gdd57cd0
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
INFO: Connected...
Starting download at: 0.000 kB
[...]
3322.127 kB / 22.03 sec (0.3%)
2. 相关知识
下面介绍一下相关知识并记录一下经过
2.1 TECHTALK
下面是techtalk视频播放的代码片段,可以看到就是使用了一下flowplayer,下面对参数进行逐个说明。
<div id="videoplayer">
<!--
<embed src="/site_media/static/swf/weyplayerplus.swf" width="100%" height="480px" allowscriptaccess="always" allowfullscreen="true" id="swfContent" name="swfContent" flashvars="talkURL=rtmp://webcast.weyond.com/vod/emnlp/2016/mp4:t4 final 1.mp4#--#rtmp://webcast.weyond.com/vod/emnlp/2016/mp4:t4 final 1.mp4&ifPlayList=True&talkID=63415&startsFrom=-1&endsAt=-1"/></embed>
-->
<div id="collageview_videoplayer_div" class="collageview_videoplayer_div">
<a class="rtmp" href='emnlp/2016/mp4:t4 final 1.mp4' style="display:block;width:640px;height:480px;" id="flowplayer_presenter">
</a>
</div>
<script type="text/javascript">
$f("flowplayer_presenter", "/site_media/static/flowplayer/flowplayer.commercial-3.2.7.swf", {
key: '#$e6dbb014a27ff12b879',
clip: {
scaling : 'fit',
provider: 'rtmp',
start: -1,
},
plugins: {
rtmp: {
url: '/site_media/static/flowplayer/flowplayer.rtmp-3.2.3.swf',
netConnectionUrl: 'rtmp://webcast.weyond.com/vod'
}
}
});
</script>
2.2 flowplayer
2.2.1 简介
flowplayer是一个在线的视频播放器,可以嵌入在HTML中。
2.2.2 RTMP
RTMP是Adobe Systems开发的一种协议,用于在互联网,Flash播放器和服务器之间传输音频,视频和数据流。
flowplayer 有一个rtmp的插件,使用方式如下,详细可以参考rtmp flowplayer。
<div id="wowza" style="width:644px;height:276px;margin:0 auto;text-align:center">
<img src="/media/img/player/splash_black.jpg"
height="276" width="548" style="cursor:pointer" />
</div>
$f("wowza", "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf", {
// common configuration for each clip
clip: {
// each clip uses the rtmp provider
provider: 'rtmp'
},
// flowplayer add rtmp plugin
plugins: {
rtmp: {
url: "flowplayer.rtmp-3.2.13.swf", // RTMP plugin release
netConnectionUrl: 'rtmp://flowplayer.org:1935/fastplay' // rtmp服务器的地址
}
}
});
2.2.3 url
flowplayer提供了两种url的方式
1.html element herf
属性,可以参考multiple rtmp
<a class="rtmp" href="mp4:bbb-800"
style="background-image:url(/media/img/demos/bunny.jpg)">
<img src="/media/img/player/btn/play_text_large.png" />
</a>
2.js中clip的url
属性
$f(){
clip: {
url: 'mp4:vod/demo.flowplayer/buffalo_soldiers.mp4',
scaling: 'fit',
// configure clip to use hddn as our provider, referring to our rtmp plugin
provider: 'hddn'
},
}
如通过使用了方法2,方法1中的url会被覆盖[link]。(http://flash.flowplayer.org/documentation/configuration/clips.html)
2.2.4 clip
clip代表了在flowplayer中播放的视频,clip的url属性就是视频的链接
2.2.5 key
The configuration needs to include the license key, otherwise you will be seeing a Flowplayer text showing on top of the video. The installation happens between SCRIPT tags on your HTML page. The license key goes to the 3rd parameter of the flowplayer call, it’s included in the flowplayer configuration object. link
flowplayer("player",
"http://releases.flowplayer.org/swf/flowplayer.commercial-3.2.18.swf",{
// license key from your account
key: '#$7162d2d730cf607ac6d'
});
2.3 FLASH URL
格式为
rtmp://[wowza-ip-address]:[port]/[application]/[appInstance]/[prefix]:[path1]/[path2]/[streamName]
wowza-ip-address
: Wowza media server domain name or IP addressport
: TCP port to use for the connection (RTMP/RTMPE = 1935, RTMPT = 80, RTMPS = 443)application
: Application nameappInstance
: Application instance name (defaults to definst)prefix
: Content type prefix (flv, mp4, mp3 - in Wowza Streaming Engine software, defaults to mp4 if omitted)path1/path2/streamName
: Stream path and name
如果视频流没有路径,可以简写为
rtmp://[wowza-ip-address]:[port]/[application]/[prefix]:[streamName]
值得注意的是flash的视频名前需要添加类型前缀,即[prefix]:[streamName]
,比如flv, mp4, mp3。例如
# RTMP URL for application name vod and stream name mycoolvideo.mov
rtmp://mycompany.com/vod/mp4:mycoolvideo.mov
# RTMP URL for application name vod and stream name myvideos/mycoolvideo.mov
rtmp://mycompany.com/vod/_definst_/mp4:myvideos/mycoolvideo.mov
更多例子可以在wowza找到。