采集(Ingest)指的是将文件(flv,mp4,mkv,avi,rmvb等等),流(RTMP,RTMPT,RTMPS,RTSP,HTTP,HLS等等),设备等的数据,转封装为RTMP流(若编码不是h264/aac则需要转码),推送到SRS。
采集基本上就是使用FFMPEG作为编码器,或者转封装器,将外部流主动抓取到SRS。
采集的部署实例参考:Ingest
采集的主要应用场景包括:
总之,采集的应用场景主要是“SRS拉流”;能拉任意的流,只要ffmpeg支持;不是h264/aac都没有关系,ffmpeg能转码。
SRS默认是支持“推流”,即等待编码器推流上来,可以是专门的编码设备,FMLE,ffmpeg,xsplit,flash等等。
如此,SRS的接入方式可以是“推流到SRS”和“SRS主动拉流”,基本上作为源站的功能就完善了。
Ingest需要在编译时打开:--with-ingest
。参考:Build
Ingest默认使用自带的ffmpeg,也可以不编译ffmpeg,使用自己的编转码工具。禁用默认的ffmpeg在编译时指定--without-ffmpeg
即可。参考:Build
Ingest的配置如下:
vhost your_vhost {
# ingest file/stream/device then push to SRS over RTMP.
# the name/id used to identify the ingest, must be unique in global.
# ingest id is used in reload or http api management.
ingest livestream {
# whether enabled ingest features
# default: off
enabled on;
# input file/stream/device
# @remark only support one input.
input {
# the type of input.
# can be file/stream/device, that is,
# file: ingest file specifies by url.
# stream: ingest stream specifeis by url.
# device: not support yet.
# default: file
type file;
# the url of file/stream.
url ./doc/source.200kbps.768x320.flv;
}
# the ffmpeg
ffmpeg ./objs/ffmpeg/bin/ffmpeg;
# the transcode engine, @see all.transcode.srs.com
# @remark, the output is specified following.
engine {
# @see enabled of transcode engine.
# if disabled or vcodec/acodec not specified, use copy.
# default: off.
enabled off;
# output stream. variables:
# [vhost] current vhost which start the ingest.
# [port] system RTMP stream port.
output rtmp://127.0.0.1:[port]/live?vhost=[vhost]/livestream;
}
}
}
ingest指令后面是ingest的id,全局需要唯一,用来标识这个ingest。在reload/http-api管理时才知道操作的是哪个。譬如,reload时用来检测哪些ingest更新了,需要通知那些已经存在的ingest,停止已经不存在的ingest。
其中,type
指定了输入的几种类型:
engine
指定了转码引擎参数:
注意:engine默认为copy,当:
实现方法:
参考:https://github.com/ossrs/srs/issues/55
Winlin 2014.4
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。