【nginx-rtmp】10、指令(Directives)之 视频点播(Video on demand)

六、视频点播(Video on demand)

1、play

语法:play dir|http://loc [dir|http://loc]*

上下文:rtmp, server, application

从指定的目录或者http链接播放flv或者mp4文件,如果参数是以http://开头,那么说明在播放前要把文件从远程http连接下载,要整个文件下载完成后才能播放。
你可以使用本地nginx来缓存文件到本地机器。
Play flv or mp4 file from specified directory or HTTP location.
If the argument is prefixed with http:// then it is assumed that file should be downloaded from remote http location before playing.
Note playing is not started until the whole file is downloaded. You can use local nginx to cache files on local machine.

在单个play指令中可以指定多个路径,当指定了多个play指令时,这个路径列表会合并,并从高优先级继承,尝试从每一个路径播放直到找到一个成功的路径。
如果没找到相关的路径,将会向客户端发送一个错误状态。
Multiple play locations can be specified in a single play directive. When multiple play directives are specified the location lists are merged and inherited from higher scopes.
An attempt to play each location is made until a successful location is found. If such location is not found error status is sent to client.

有索引的FLVs播放时会随机寻址播放(?),没索引的FLVs在播放时不能寻址/暂停(仅重启模式)。使用FLV索引器(如yamdi)来做索引。
Indexed FLVs are played with random seek capability. Unindexed FLVs are played with seek/pause disabled (restart-only mode). Use FLV indexer (for example, yamdi) for indexing.

如果你播放的FLVs是使用record指令录制的(?),请别忘了在播放前提供索引(?),它们被创建为无索引(?)。
If you play FLVs recorded with the record directive please do not forget to index them before playing. They are created unindexed.

Mp4文件只在音频和视频编码都被RTMP支持的时候才能播放,最常见的情形是 H264/AAC。
Mp4 files can only be played if both video and audio codec are supported by RTMP. The most common case is H264/AAC.

application vod {
    play /var/flvs;
}

application vod_http {
    play http://myserver.com/vod;
}

application vod_mirror {
    # try local location first, then access remote location
    play /var/local_mirror http://myserver.com/vod;
}

播放 /var/flvs/dir/file.flv :

ffplay rtmp://localhost/vod//dir/file.flv

”vod“后面的两个斜杠是使ffplay使用”vod“和 应用名 和 剩下的url部分作为播放路径
The two slashes after vod make ffplay use vod and application name and the rest of the url as playpath.



2、play_temp_path

语法:play_temp_path dir

上下文:rtmp, server, application

在播放前设置远程VOD文件的保存到本地的路径,默认是 /tmp。
Sets location where remote VOD files are stored before playing. Default is /tmp;

play_temp_path /www;
play http://example.com/videos;


3、play_local_path

语法:play_local_path dir

上下文:rtmp, server, application

设置远程VOD文件在下载完成后,要从 play_temp_path复制到的位置,如果设置为空将禁用这功能,默认值就是空,这个功能可用于缓存远程文件到本地。
Sets location where remote VOD files copied from play_temp_path directory after they are completely downloaded.
Empty value disables the feature. By default it's empty. The feature can be used for caching remote files locally.

这个路径应该与play_temp_path在同一个设备上。
This path should be on the same device as play_temp_path.

# search file in /tmp/videos.
# if not found play from remote location
# and store in /tmp/videos

play_local_path /tmp/videos;
play /tmp/videos http://example.com/videos;



参考:https://github.com/arut/nginx-rtmp-module/wiki/Directives


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值