vhost example.transcode.srs.com {
# the streaming transcode configs.
# @remark vhost can contains multiple transcode
transcode {
# whether the transcode enabled.
# if off, donot transcode.
# default: off.
enabled on;
# the ffmpeg
ffmpeg ./objs/ffmpeg/bin/ffmpeg;
# the transcode engine for matched stream.
# all matched stream will transcoded to the following stream.
# the transcode set name(ie. hd) is optional and not used.
# we will build the parameters to fork ffmpeg:
# ffmpeg <perfile>
# -i <iformat>
# <vfilter>
# -vcodec <vcodec> -b:v <vbitrate> -r <vfps> -s <vwidth>x<vheight> -profile:v <vprofile> -preset <vpreset>
# <vparams>
# -acodec <acodec> -b:a <abitrate> -ar <asample_rate> -ac <achannels>
# <aparams>
# -f <oformat>
# -y <output>
engine example {
# whether the engine is enabled
# default: off.
enabled on;
# pre-file options, before "-i"
perfile {
re;
rtsp_transport tcp;
}
# input format "-i", can be:
# off, do not specifies the format, ffmpeg will guess it.
# flv, for flv or RTMP stream.
# other format, for example, mp4/aac whatever.
# default: flv
iformat flv;
# ffmpeg filters, between "-i" and "-vcodec"
# follows the main input.
vfilter {
# the logo input file.
i ./doc/ffmpeg-logo.png;
# the ffmpeg complex filter.
# for filters, @see: http://ffmpeg.org/ffmpeg-filters.html
filter_complex 'overlay=10:10';
}
# video encoder name, "ffmpeg -vcodec"
# can be:
# libx264: use h.264(libx264) video encoder.
# png: use png to snapshot thumbnail.
# copy: donot encoder the video stream, copy it.
# vn: disable video output.
vcodec libx264;
# video bitrate, in kbps, "ffmepg -b:v"
# @remark 0 to use source video bitrate.
# default: 0
vbitrate 1500;
# video framerate, "ffmepg -r"
# @remark 0 to use source video fps.
# default: 0
vfps 25;
# video width, must be even numbers, "ffmepg -s"
# @remark 0 to use source video width.
# default: 0
vwidth 768;
# video height, must be even numbers, "ffmepg -s"
# @remark 0 to use source video height.
# default: 0
vheight 320;
# the max threads for ffmpeg to used, "ffmepg -thread"
# default: 1
vthreads 12;
# x264 profile, "ffmepg -profile:v"
# @see x264 -help, can be:
# high,main,baseline
vprofile main;
# x264 preset, "ffmpeg -preset"
# @see x264 -help, can be:
# ultrafast,superfast,veryfast,faster,fast
# medium,slow,slower,veryslow,placebo
vpreset medium;
# other x264 or ffmpeg video params, between "-preset" and "-acodec"
vparams {
# ffmpeg options, @see: http://ffmpeg.org/ffmpeg.html
t 100;
# 264 params, @see: http://ffmpeg.org/ffmpeg-codecs.html#libx264
coder 1;
b_strategy 2;
bf 3;
refs 10;
}
# audio encoder name, "ffmpeg -acodec"
# can be:
# libfdk_aac: use aac(libfdk_aac) audio encoder.
# copy: donot encoder the audio stream, copy it.
# an: disable audio output.
acodec libfdk_aac;
# audio bitrate, in kbps, "ffmpeg -b:a"
# [16, 72] for libfdk_aac.
# @remark 0 to use source audio bitrate.
# default: 0
abitrate 70;
# audio sample rate, "ffmpeg -ar"
# for flv/rtmp, it must be:
# 44100,22050,11025,5512
# @remark 0 to use source audio sample rate.
# default: 0
asample_rate 44100;
# audio channel, "ffmpeg -ac"
# 1 for mono, 2 for stereo.
# @remark 0 to use source audio channels.
# default: 0
achannels 2;
# other ffmpeg audio params, between "-ac" and "-f"/"-y"
aparams {
# audio params, @see: http://ffmpeg.org/ffmpeg-codecs.html#Audio-Encoders
# @remark SRS supported aac profile for HLS is: aac_low, aac_he, aac_he_v2
profile:a aac_low;
bsf:a aac_adtstoasc;
}
# output format, "ffmpeg -f" can be:
# off, do not specifies the format, ffmpeg will guess it.
# flv, for flv or RTMP stream.
# image2, for vcodec png to snapshot thumbnail.
# other format, for example, mp4/aac whatever.
# default: flv
oformat flv;
# output stream, "ffmpeg -y", variables:
# [vhost] the input stream vhost.
# [port] the input stream port.
# [app] the input stream app.
# [stream] the input stream name.
# [engine] the transcode engine name.
# we also support datetime variables.
# [2006], replace this const to current year.
# [01], replace this const to current month.
# [02], replace this const to current date.
# [15], replace this const to current hour.
# [04], replace this const to current minute.
# [05], replace this const to current second.
# [999], replace this const to current millisecond.
# [timestamp],replace this const to current UNIX timestamp in ms.
# @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]"
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
}
}
}