full.conf 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106
  1. # all config for srs
  2. #############################################################################################
  3. # RTMP sections
  4. #############################################################################################
  5. # the rtmp listen ports, split by space, each listen entry is <[ip:]port>
  6. # for example, 192.168.1.100:1935 10.10.10.100:1935
  7. # where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935
  8. listen 1935;
  9. # the pid file
  10. # to ensure only one process can use a pid file
  11. # and provides the current running process id, for script,
  12. # for example, init.d script to manage the server.
  13. # default: ./objs/srs.pid
  14. pid ./objs/srs.pid;
  15. # the default chunk size is 128, max is 65536,
  16. # some client does not support chunk size change,
  17. # however, most clients support it and it can improve
  18. # performance about 10%.
  19. # default: 60000
  20. chunk_size 60000;
  21. # the log dir for FFMPEG.
  22. # if enabled ffmpeg, each transcoding stream will create a log file.
  23. # /dev/null to disable the log.
  24. # default: ./objs
  25. ff_log_dir ./objs;
  26. # the log level for FFMPEG.
  27. # info warning error fatal panic quiet
  28. # trace debug verbose
  29. # default: info
  30. ff_log_level info;
  31. # the log tank, console or file.
  32. # if console, print log to console.
  33. # if file, write log to file. requires srs_log_file if log to file.
  34. # default: file.
  35. srs_log_tank console;
  36. # the log level, for all log tanks.
  37. # can be: verbose, info, trace, warn, error
  38. # default: trace
  39. srs_log_level trace;
  40. # when srs_log_tank is file, specifies the log file.
  41. # default: ./objs/srs.log
  42. srs_log_file ./objs/srs.log;
  43. # the max connections.
  44. # if exceed the max connections, server will drop the new connection.
  45. # default: 1000
  46. max_connections 1000;
  47. # whether start as daemon
  48. # @remark: do not support reload.
  49. # default: on
  50. daemon off;
  51. # whether use utc_time to generate the time struct,
  52. # if off, use localtime() to generate it,
  53. # if on, use gmtime() instead, which use UTC time.
  54. # default: off
  55. utc_time off;
  56. # config for the pithy print in ms,
  57. # which always print constant message specified by interval,
  58. # whatever the clients in concurrency.
  59. # default: 10000
  60. pithy_print_ms 10000;
  61. # the work dir for server, to chdir(work_dir) when not empty or "./"
  62. # user can config this directory to change the dir.
  63. # @reamrk do not support reload.
  64. # default: ./
  65. work_dir ./;
  66. # whether quit when parent process changed,
  67. # used for supervisor mode(not daemon), srs should always quit when
  68. # supervisor process exited.
  69. # @remark conflict with daemon, error when both daemon and asprocess are on.
  70. # @reamrk do not support reload.
  71. # default: off
  72. asprocess off;
  73. # Whether client empty IP is ok, for example, health checking by SLB.
  74. # If ok(on), we will ignore this connection without warnings or errors.
  75. # default: on
  76. empty_ip_ok on;
  77. # Whether in docker. When SRS starting, it will detect the docker, however
  78. # it might detect failed, then read this config.
  79. # Default: off
  80. in_docker off;
  81. # For gracefully quit, wait for a while then close listeners,
  82. # because K8S notify SRS with SIGQUIT and update Service simultaneously,
  83. # maybe there is some new connections incoming before Service updated.
  84. # @see https://github.com/ossrs/srs/issues/1595#issuecomment-587516567
  85. # default: 2300
  86. grace_start_wait 2300;
  87. # For gracefully quit, final wait for cleanup in milliseconds.
  88. # @see https://github.com/ossrs/srs/issues/1579#issuecomment-587414898
  89. # default: 3200
  90. grace_final_wait 3200;
  91. # Whether force gracefully quit, never fast quit.
  92. # By default, SIGTERM which means fast quit, is sent by K8S, so we need to
  93. # force SRS to treat SIGTERM as gracefully quit for gray release or canary.
  94. # @see https://github.com/ossrs/srs/issues/1579#issuecomment-587475077
  95. # default: off
  96. force_grace_quit off;
  97. # Whether disable daemon for docker.
  98. # If on, it will set daemon to off in docker, even daemon is on.
  99. # default: on
  100. disable_daemon_for_docker on;
  101. # Whether auto reload by watching the config file by inotify.
  102. # default: off
  103. inotify_auto_reload off;
  104. # Whether enable inotify_auto_reload for docker.
  105. # If on, it will set inotify_auto_reload to on in docker, even it's off.
  106. # default: on
  107. auto_reload_for_docker on;
  108. # For tcmalloc, the release rate.
  109. # @see https://gperftools.github.io/gperftools/tcmalloc.html
  110. # @remark Should run configure --with-gperf
  111. # default: 0.8
  112. tcmalloc_release_rate 0.8;
  113. # Query the latest available version of SRS, write a log to notice user to upgrade.
  114. # @see https://github.com/ossrs/srs/issues/2424
  115. # @see https://github.com/ossrs/srs/issues/2508
  116. # Default: on
  117. query_latest_version on;
  118. # For system circuit breaker.
  119. circuit_breaker {
  120. # Whether enable the circuit breaker.
  121. # Default: on
  122. enabled on;
  123. # The CPU percent(0, 100) ever 1s, as system high water-level, which enable the circuit-break
  124. # mechanism, for example, NACK will be disabled if high water-level.
  125. # Default: 90
  126. high_threshold 90;
  127. # Reset the high water-level, if number of pulse under high_threshold.
  128. # @remark 0 to disable the high water-level.
  129. # Default: 2
  130. high_pulse 2;
  131. # The CPU percent(0, 100) ever 1s, as system critical water-level, which enable the circuit-break
  132. # mechanism, for example, TWCC will be disabled if high water-level.
  133. # @note All circuit-break mechanism of high-water-level scope are enabled in critical.
  134. # Default: 95
  135. critical_threshold 95;
  136. # Reset the critical water-level, if number of pulse under critical_threshold.
  137. # @remark 0 to disable the critical water-level.
  138. # Default: 1
  139. critical_pulse 1;
  140. # If dying, also drop packets for players.
  141. # Default: 99
  142. dying_threshold 99;
  143. # If CPU exceed the dying_pulse times, enter dying.
  144. # @remark 0 to disable the dying water-level.
  145. # Default: 5
  146. dying_pulse 5;
  147. }
  148. #############################################################################################
  149. # heartbeat/stats sections
  150. #############################################################################################
  151. # heartbeat to api server
  152. # @remark, the ip report to server, is retrieve from system stat,
  153. # which need the config item stats.network.
  154. heartbeat {
  155. # whether heartbeat is enabled.
  156. # default: off
  157. enabled off;
  158. # the interval seconds for heartbeat,
  159. # recommend 0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3,...,6,9,12,....
  160. # default: 9.9
  161. interval 9.3;
  162. # when startup, srs will heartbeat to this api.
  163. # @remark: must be a restful http api url, where SRS will POST with following data:
  164. # {
  165. # "device_id": "my-srs-device",
  166. # "ip": "192.168.1.100"
  167. # }
  168. # default: http://127.0.0.1:8085/api/v1/servers
  169. url http://127.0.0.1:8085/api/v1/servers;
  170. # the id of device.
  171. device_id "my-srs-device";
  172. # whether report with summaries
  173. # if on, put /api/v1/summaries to the request data:
  174. # {
  175. # "summaries": summaries object.
  176. # }
  177. # @remark: optional config.
  178. # default: off
  179. summaries off;
  180. }
  181. # system statistics section.
  182. # the main cycle will retrieve the system stat,
  183. # for example, the cpu/mem/network/disk-io data,
  184. # the http api, for instance, /api/v1/summaries will show these data.
  185. # @remark the heartbeat depends on the network,
  186. # for example, the eth0 maybe the device which index is 0.
  187. stats {
  188. # Whether enable the stat of system resources.
  189. # Default: on
  190. enabled on;
  191. # the index of device ip.
  192. # we may retrieve more than one network device.
  193. # default: 0
  194. network 0;
  195. # the device name to stat the disk iops.
  196. # ignore the device of /proc/diskstats if not configured.
  197. disk sda sdb xvda xvdb;
  198. }
  199. #############################################################################################
  200. # HTTP sections
  201. #############################################################################################
  202. # api of srs.
  203. # the http api config, export for external program to manage srs.
  204. # user can access http api of srs in browser directly, for instance, to access by:
  205. # curl http://192.168.1.170:1985/api/v1/reload
  206. # which will reload srs, like cmd killall -1 srs, but the js can also invoke the http api,
  207. # where the cli can only be used in shell/terminate.
  208. http_api {
  209. # whether http api is enabled.
  210. # default: off
  211. enabled on;
  212. # the http api listen entry is <[ip:]port>
  213. # for example, 192.168.1.100:1985
  214. # where the ip is optional, default to 0.0.0.0, that is 1985 equals to 0.0.0.0:1985
  215. # default: 1985
  216. listen 1985;
  217. # whether enable crossdomain request.
  218. # default: on
  219. crossdomain on;
  220. # the HTTP RAW API is more powerful api to change srs state and reload.
  221. raw_api {
  222. # whether enable the HTTP RAW API.
  223. # default: off
  224. enabled off;
  225. # whether enable rpc reload.
  226. # default: off
  227. allow_reload off;
  228. # whether enable rpc query.
  229. # Always off by https://github.com/ossrs/srs/issues/2653
  230. #allow_query off;
  231. # whether enable rpc update.
  232. # Always off by https://github.com/ossrs/srs/issues/2653
  233. #allow_update off;
  234. }
  235. # For https_api or HTTPS API.
  236. https {
  237. # Whether enable HTTPS API.
  238. # default: off
  239. enabled on;
  240. # The listen endpoint for HTTPS API.
  241. # default: 1990
  242. listen 1990;
  243. # The SSL private key file, generated by:
  244. # openssl genrsa -out server.key 2048
  245. # default: ./conf/server.key
  246. key ./conf/server.key;
  247. # The SSL public cert file, generated by:
  248. # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net"
  249. # default: ./conf/server.crt
  250. cert ./conf/server.crt;
  251. }
  252. }
  253. # embedded http server in srs.
  254. # the http streaming config, for HLS/HDS/DASH/HTTPProgressive
  255. # global config for http streaming, user must config the http section for each vhost.
  256. # the embed http server used to substitute nginx in ./objs/nginx,
  257. # for example, srs running in arm, can provides RTMP and HTTP service, only with srs installed.
  258. # user can access the http server pages, generally:
  259. # curl http://192.168.1.170:80/srs.html
  260. # which will show srs version and welcome to srs.
  261. # @remark, the http embedded stream need to config the vhost, for instance, the __defaultVhost__
  262. # need to open the feature http of vhost.
  263. http_server {
  264. # whether http streaming service is enabled.
  265. # default: off
  266. enabled on;
  267. # the http streaming listen entry is <[ip:]port>
  268. # for example, 192.168.1.100:8080
  269. # where the ip is optional, default to 0.0.0.0, that is 8080 equals to 0.0.0.0:8080
  270. # @remark, if use lower port, for instance 80, user must start srs by root.
  271. # default: 8080
  272. listen 8080;
  273. # the default dir for http root.
  274. # default: ./objs/nginx/html
  275. dir ./objs/nginx/html;
  276. # whether enable crossdomain request.
  277. # for both http static and stream server and apply on all vhosts.
  278. # default: on
  279. crossdomain on;
  280. # For https_server or HTTPS Streaming.
  281. https {
  282. # Whether enable HTTPS Streaming.
  283. # default: off
  284. enabled on;
  285. # The listen endpoint for HTTPS Streaming.
  286. # default: 8088
  287. listen 8088;
  288. # The SSL private key file, generated by:
  289. # openssl genrsa -out server.key 2048
  290. # default: ./conf/server.key
  291. key ./conf/server.key;
  292. # The SSL public cert file, generated by:
  293. # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net"
  294. # default: ./conf/server.crt
  295. cert ./conf/server.crt;
  296. }
  297. }
  298. #############################################################################################
  299. # Streamer sections
  300. #############################################################################################
  301. # the streamer cast stream from other protocol to SRS over RTMP.
  302. # @see https://github.com/ossrs/srs/tree/develop#stream-architecture
  303. # MPEGTS over UDP
  304. stream_caster {
  305. # whether stream caster is enabled.
  306. # default: off
  307. enabled on;
  308. # the caster type of stream, the casters:
  309. # mpegts_over_udp, MPEG-TS over UDP caster.
  310. caster mpegts_over_udp;
  311. # the output rtmp url.
  312. # for mpegts_over_udp caster, the typically output url:
  313. # rtmp://127.0.0.1/live/livestream
  314. output rtmp://127.0.0.1/live/livestream;
  315. # the listen port for stream caster.
  316. # for mpegts_over_udp caster, listen at udp port. for example, 8935.
  317. listen 8935;
  318. }
  319. # FLV
  320. stream_caster {
  321. # whether stream caster is enabled.
  322. # default: off
  323. enabled on;
  324. # the caster type of stream, the casters:
  325. # flv, FLV over HTTP by POST.
  326. caster flv;
  327. # the output rtmp url.
  328. # for flv caster, the typically output url:
  329. # rtmp://127.0.0.1/[app]/[stream]
  330. # for example, POST to url:
  331. # http://127.0.0.1:8936/live/livestream.flv
  332. # where the [app] is "live" and [stream] is "livestream", output is:
  333. # rtmp://127.0.0.1/live/livestream
  334. output rtmp://127.0.0.1/[app]/[stream];
  335. # the listen port for stream caster.
  336. # for flv caster, listen at tcp port. for example, 8936.
  337. listen 8936;
  338. }
  339. #############################################################################################
  340. # SRT server section
  341. #############################################################################################
  342. # @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026
  343. srt_server {
  344. # whether SRT server is enabled.
  345. # default: off
  346. enabled on;
  347. # The UDP listen port for SRT.
  348. listen 10080;
  349. # For detail parameters, please read wiki:
  350. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/srt-params
  351. # @see https://ossrs.io/lts/en-us/docs/v4/doc/srt-params
  352. maxbw 1000000000;
  353. connect_timeout 4000;
  354. peerlatency 300;
  355. recvlatency 300;
  356. # Default app for vmix, see https://github.com/ossrs/srs/pull/1615
  357. # default: live
  358. default_app live;
  359. }
  360. #############################################################################################
  361. # WebRTC server section
  362. #############################################################################################
  363. rtc_server {
  364. # Whether enable WebRTC server.
  365. # default: off
  366. enabled on;
  367. # The udp listen port, we will reuse it for connections.
  368. # default: 8000
  369. listen 8000;
  370. # The exposed candidate IPs, response in SDP candidate line. It can be:
  371. # * Retrieve server IP automatically, from all network interfaces.
  372. # eth0 Retrieve server IP by specified network interface name. # TODO: Implements it.
  373. # $CANDIDATE Read the IP from ENV variable, use * if not set.
  374. # x.x.x.x A specified IP address or DNS name, which can be access by client such as Chrome.
  375. # You can specific more than one interface name:
  376. # eth0 eth1 Use network interface eth0 and eth1. # TODO: Implements it.
  377. # Also by IP or DNS names:
  378. # 192.168.1.3 10.1.2.3 rtc.me # TODO: Implements it.
  379. # And by multiple ENV variables:
  380. # $CANDIDATE $EIP # TODO: Implements it.
  381. # @remark For Firefox, the candidate MUST be IP, MUST NOT be DNS name.
  382. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
  383. # default: *
  384. candidate *;
  385. # If api_as_candidates is on, SRS would try to use the IP of api server, specified by srs.sdk.js request:
  386. # api:string "http://r.ossrs.net:1985/rtc/v1/play/"
  387. # in this case, the r.ossrs.net and 39.107.238.185 will be added as candidates.
  388. # Default: on
  389. api_as_candidates on;
  390. # The IP family filter for auto discover candidate, it can be:
  391. # ipv4 Filter IP v4 candidates.
  392. # ipv6 Filter IP v6 candidates.
  393. # all Filter all IP v4 or v6 candidates.
  394. # For example, if set to ipv4, we only use the IPv4 address as candidate.
  395. # default: ipv4
  396. ip_family ipv4;
  397. # Whether use ECDSA certificate.
  398. # If not, use RSA certificate.
  399. # default: on
  400. ecdsa on;
  401. # Whether encrypt RTP packet by SRTP.
  402. # @remark Should always turn it on, or Chrome will fail.
  403. # default: on
  404. encrypt on;
  405. # We listen multiple times at the same port, by REUSEPORT, to increase the UDP queue.
  406. # Note that you can set to 1 and increase the system UDP buffer size by net.core.rmem_max
  407. # and net.core.rmem_default or just increase this to get larger UDP recv and send buffer.
  408. # default: 1
  409. reuseport 1;
  410. # Whether merge multiple NALUs into one.
  411. # @see https://github.com/ossrs/srs/issues/307#issuecomment-612806318
  412. # default: off
  413. merge_nalus off;
  414. # The black-hole to copy packet to, for debugging.
  415. # For example, when debugging Chrome publish stream, the received packets are encrypted cipher,
  416. # we can set the publisher black-hole, SRS will copy the plaintext packets to black-hole, and
  417. # we are able to capture the plaintext packets by wireshark.
  418. black_hole {
  419. # Whether enable the black-hole.
  420. # default: off
  421. enabled off;
  422. # The black-hole address for session.
  423. addr 127.0.0.1:10000;
  424. }
  425. }
  426. vhost rtc.vhost.srs.com {
  427. rtc {
  428. # Whether enable WebRTC server.
  429. # default: off
  430. enabled on;
  431. # Whether support NACK.
  432. # default: on
  433. nack on;
  434. # Whether directly use the packet, avoid copy.
  435. # default: on
  436. nack_no_copy on;
  437. # Whether support TWCC.
  438. # default: on
  439. twcc on;
  440. # The timeout in seconds for session timeout.
  441. # Client will send ping(STUN binding request) to server, we use it as heartbeat.
  442. # default: 30
  443. stun_timeout 30;
  444. # The strict check when process stun.
  445. # default: off
  446. stun_strict_check on;
  447. # The role of dtls when peer is actpass: passive or active
  448. # default: passive
  449. dtls_role passive;
  450. # The version of dtls, support dtls1.0, dtls1.2, and auto
  451. # default: auto
  452. dtls_version auto;
  453. # Drop the packet with the pt(payload type), 0 never drop.
  454. # default: 0
  455. drop_for_pt 0;
  456. ###############################################################
  457. # Whether enable transmuxing RTMP to RTC.
  458. # If enabled, transcode aac to opus.
  459. # default: off
  460. rtmp_to_rtc off;
  461. # Whether keep B-frame, which is normal feature in live streaming,
  462. # but usually disabled in RTC.
  463. # default: off
  464. keep_bframe off;
  465. ###############################################################
  466. # Whether enable transmuxing RTC to RTMP.
  467. # Default: off
  468. rtc_to_rtmp off;
  469. # The PLI interval in seconds, for RTC to RTMP.
  470. # Note the available range is [0.5, 30]
  471. # Default: 6.0
  472. pli_for_rtmp 6.0;
  473. }
  474. ###############################################################
  475. # For transmuxing RTMP to RTC, it will impact the default values if RTC is on.
  476. # Whether enable min delay mode for vhost.
  477. # default: on, for RTC.
  478. min_latency on;
  479. play {
  480. # set the MW(merged-write) latency in ms.
  481. # @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config.
  482. # default: 0 (For WebRTC)
  483. mw_latency 0;
  484. # Set the MW(merged-write) min messages.
  485. # default: 0 (For Real-Time, that is min_latency on)
  486. # default: 1 (For WebRTC, that is min_latency off)
  487. mw_msgs 0;
  488. }
  489. }
  490. #############################################################################################
  491. # RTMP/HTTP VHOST sections
  492. #############################################################################################
  493. # vhost list, the __defaultVhost__ is the default vhost
  494. # for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream.
  495. # for which cannot identify the required vhost.
  496. vhost __defaultVhost__ {
  497. }
  498. # the vhost scope configs.
  499. vhost scope.vhost.srs.com {
  500. # whether the vhost is enabled.
  501. # if off, all request access denied.
  502. # default: on
  503. enabled off;
  504. # whether enable min delay mode for vhost.
  505. # for min latency mode:
  506. # 1. disable the publish.mr for vhost.
  507. # 2. use timeout for cond wait for consumer queue.
  508. # @see https://github.com/ossrs/srs/issues/257
  509. # default: off (for RTMP/HTTP-FLV)
  510. # default: on (for WebRTC)
  511. min_latency off;
  512. # whether enable the TCP_NODELAY
  513. # if on, set the nodelay of fd by setsockopt
  514. # default: off
  515. tcp_nodelay off;
  516. # the default chunk size is 128, max is 65536,
  517. # some client does not support chunk size change,
  518. # vhost chunk size will override the global value.
  519. # default: global chunk size.
  520. chunk_size 128;
  521. # The input ack size, 0 to not set.
  522. # Generally, it's set by the message from peer,
  523. # but for some peer(encoder), it never send message but use a different ack size.
  524. # We can chnage the default ack size in server-side, to send acknowledge message,
  525. # or the encoder maybe blocked after publishing for some time.
  526. # Default: 0
  527. in_ack_size 0;
  528. # The output ack size, 0 to not set.
  529. # This is used to notify the peer(player) to send acknowledge to server.
  530. # Default: 2500000
  531. out_ack_size 2500000;
  532. }
  533. # set the chunk size of vhost.
  534. vhost chunksize.srs.com {
  535. # @see scope.vhost.srs.com
  536. chunk_size 128;
  537. }
  538. # the vhost disabled.
  539. vhost removed.srs.com {
  540. # @see scope.vhost.srs.com
  541. enabled off;
  542. }
  543. # vhost for stream cluster for RTMP/FLV
  544. vhost cluster.srs.com {
  545. # The config for cluster.
  546. cluster {
  547. # The cluster mode, local or remote.
  548. # local: It's an origin server, serve streams itself.
  549. # remote: It's an edge server, fetch or push stream to origin server.
  550. # default: local
  551. mode remote;
  552. # For edge(mode remote), user must specifies the origin server
  553. # format as: <server_name|ip>[:port]
  554. # @remark user can specifies multiple origin for error backup, by space,
  555. # for example, 192.168.1.100:1935 192.168.1.101:1935 192.168.1.102:1935
  556. origin 127.0.0.1:1935 localhost:1935;
  557. # For edge(mode remote), whether open the token traverse mode,
  558. # if token traverse on, all connections of edge will forward to origin to check(auth),
  559. # it's very important for the edge to do the token auth.
  560. # the better way is use http callback to do the token auth by the edge,
  561. # but if user prefer origin check(auth), the token_traverse if better solution.
  562. # default: off
  563. token_traverse off;
  564. # For edge(mode remote), the vhost to transform for edge,
  565. # to fetch from the specified vhost at origin,
  566. # if not specified, use the current vhost of edge in origin, the variable [vhost].
  567. # default: [vhost]
  568. vhost same.edge.srs.com;
  569. # For edge(mode remote), when upnode(forward to, edge push to, edge pull from) is srs,
  570. # it's strongly recommend to open the debug_srs_upnode,
  571. # when connect to upnode, it will take the debug info,
  572. # for example, the id, source id, pid.
  573. # please see https://ossrs.net/lts/zh-cn/docs/v4/doc/log
  574. # default: on
  575. debug_srs_upnode on;
  576. # For origin(mode local) cluster, turn on the cluster.
  577. # @remark Origin cluster only supports RTMP, use Edge to transmux RTMP to FLV.
  578. # default: off
  579. # TODO: FIXME: Support reload.
  580. origin_cluster off;
  581. # For origin (mode local) cluster, the co-worker's HTTP APIs.
  582. # This origin will connect to co-workers and communicate with them.
  583. # please see https://ossrs.io/lts/en-us/docs/v4/doc/origin-cluster
  584. # TODO: FIXME: Support reload.
  585. coworkers 127.0.0.1:9091 127.0.0.1:9092;
  586. }
  587. }
  588. # vhost for edge, edge and origin is the same vhost
  589. vhost same.edge.srs.com {
  590. # @see cluster.srs.com
  591. cluster {
  592. mode remote;
  593. origin 127.0.0.1:1935 localhost:1935;
  594. token_traverse off;
  595. }
  596. }
  597. # vhost for edge, edge transform vhost to fetch from another vhost.
  598. vhost transform.edge.srs.com {
  599. # @see cluster.srs.com
  600. cluster {
  601. mode remote;
  602. origin 127.0.0.1:1935;
  603. vhost same.edge.srs.com;
  604. }
  605. }
  606. # the vhost for srs debug info, whether send args in connect(tcUrl).
  607. vhost debug.srs.com {
  608. # @see cluster.srs.com
  609. cluster {
  610. debug_srs_upnode on;
  611. }
  612. }
  613. # the vhost which forward publish streams.
  614. vhost same.vhost.forward.srs.com {
  615. # forward stream to other servers.
  616. forward {
  617. # whether enable the forward.
  618. # default: off
  619. enabled on;
  620. # forward all publish stream to the specified server.
  621. # this used to split/forward the current stream for cluster active-standby,
  622. # active-active for cdn to build high available fault tolerance system.
  623. # format: {ip}:{port} {ip_N}:{port_N}
  624. destination 127.0.0.1:1936 127.0.0.1:1937;
  625. }
  626. }
  627. # the play specified configs
  628. vhost play.srs.com {
  629. # for play client, both RTMP and other stream clients,
  630. # for instance, the HTTP FLV stream clients.
  631. play {
  632. # whether cache the last gop.
  633. # if on, cache the last gop and dispatch to client,
  634. # to enabled fast startup for client, client play immediately.
  635. # if off, send the latest media data to client,
  636. # client need to wait for the next Iframe to decode and show the video.
  637. # set to off if requires min delay;
  638. # set to on if requires client fast startup.
  639. # default: on
  640. gop_cache off;
  641. # the max live queue length in seconds.
  642. # if the messages in the queue exceed the max length,
  643. # drop the old whole gop.
  644. # default: 30
  645. queue_length 10;
  646. # about the stream monotonically increasing:
  647. # 1. video timestamp is monotonically increasing,
  648. # 2. audio timestamp is monotonically increasing,
  649. # 3. video and audio timestamp is interleaved/mixed monotonically increasing.
  650. # it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format
  651. # however, some encoder cannot provides this feature, please set this to off to ignore time jitter.
  652. # the time jitter algorithm:
  653. # 1. full, to ensure stream start at zero, and ensure stream monotonically increasing.
  654. # 2. zero, only ensure stream start at zero, ignore timestamp jitter.
  655. # 3. off, disable the time jitter algorithm, like atc.
  656. # @remark for full, correct timestamp only when |delta| > 250ms.
  657. # @remark disabled when atc is on.
  658. # default: full
  659. time_jitter full;
  660. # vhost for atc for hls/hds/rtmp backup.
  661. # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0.
  662. # when atc is on, server delivery rtmp stream by absolute time.
  663. # atc is used, for instance, encoder will copy stream to master and slave server,
  664. # server use atc to delivery stream to edge/client, where stream time from master/slave server
  665. # is always the same, client/tools can slice RTMP stream to HLS according to the same time,
  666. # if the time not the same, the HLS stream cannot slice to support system backup.
  667. #
  668. # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html
  669. # @see http://www.baidu.com/#wd=hds%20hls%20atc
  670. #
  671. # @remark when atc is on, auto off the time_jitter
  672. # default: off
  673. atc off;
  674. # whether use the interleaved/mixed algorithm to correct the timestamp.
  675. # if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase.
  676. # if off, use time_jitter to correct the timestamp if required.
  677. # @remark to use mix_correct, atc should on(or time_jitter should off).
  678. # default: off
  679. mix_correct off;
  680. # whether enable the auto atc,
  681. # if enabled, detect the bravo_atc="true" in onMetaData packet,
  682. # set atc to on if matched.
  683. # always ignore the onMetaData if atc_auto is off.
  684. # default: off
  685. atc_auto off;
  686. # set the MW(merged-write) latency in ms.
  687. # SRS always set mw on, so we just set the latency value.
  688. # the latency of stream >= mw_latency + mr_latency
  689. # the value recomment is [300, 1800]
  690. # @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config.
  691. # default: 350 (For RTMP/HTTP-FLV)
  692. # default: 0 (For WebRTC)
  693. mw_latency 350;
  694. # Set the MW(merged-write) min messages.
  695. # default: 0 (For Real-Time, min_latency on)
  696. # default: 1 (For WebRTC, min_latency off)
  697. # default: 8 (For RTMP/HTTP-FLV, min_latency off).
  698. mw_msgs 8;
  699. # the minimal packets send interval in ms,
  700. # used to control the ndiff of stream by srs_rtmp_dump,
  701. # for example, some device can only accept some stream which
  702. # delivery packets in constant interval(not cbr).
  703. # @remark 0 to disable the minimal interval.
  704. # @remark >0 to make the srs to send message one by one.
  705. # @remark user can get the right packets interval in ms by srs_rtmp_dump.
  706. # default: 0
  707. send_min_interval 10.0;
  708. # whether reduce the sequence header,
  709. # for some client which cannot got duplicated sequence header,
  710. # while the sequence header is not changed yet.
  711. # default: off
  712. reduce_sequence_header on;
  713. }
  714. }
  715. # vhost for time jitter
  716. vhost jitter.srs.com {
  717. # @see play.srs.com
  718. # to use time_jitter full, the default config.
  719. play {
  720. }
  721. # to use mix_correct.
  722. play {
  723. time_jitter off;
  724. mix_correct on;
  725. }
  726. play {
  727. atc on;
  728. mix_correct on;
  729. }
  730. # to use atc
  731. play {
  732. atc on;
  733. }
  734. }
  735. # vhost for atc.
  736. vhost atc.srs.com {
  737. # @see play.srs.com
  738. play {
  739. atc on;
  740. atc_auto on;
  741. }
  742. }
  743. # the MR(merged-read) setting for publisher.
  744. # the MW(merged-write) settings for player.
  745. vhost mrw.srs.com {
  746. # @see scope.vhost.srs.com
  747. min_latency off;
  748. # @see play.srs.com
  749. play {
  750. mw_latency 350;
  751. mw_msgs 8;
  752. }
  753. # @see publish.srs.com
  754. publish {
  755. mr on;
  756. mr_latency 350;
  757. }
  758. }
  759. # the vhost for min delay, do not cache any stream.
  760. vhost min.delay.com {
  761. # @see scope.vhost.srs.com
  762. min_latency on;
  763. # @see scope.vhost.srs.com
  764. tcp_nodelay on;
  765. # @see play.srs.com
  766. play {
  767. mw_latency 100;
  768. mw_msgs 4;
  769. gop_cache off;
  770. queue_length 10;
  771. }
  772. # @see publish.srs.com
  773. publish {
  774. mr off;
  775. }
  776. }
  777. # whether disable the sps parse, for the resolution of video.
  778. vhost no.parse.sps.com {
  779. # @see publish.srs.com
  780. publish {
  781. parse_sps on;
  782. }
  783. }
  784. # the vhost to control the stream delivery feature
  785. vhost stream.control.com {
  786. # @see scope.vhost.srs.com
  787. min_latency on;
  788. # @see scope.vhost.srs.com
  789. tcp_nodelay on;
  790. # @see play.srs.com
  791. play {
  792. mw_latency 100;
  793. mw_msgs 4;
  794. queue_length 10;
  795. send_min_interval 10.0;
  796. reduce_sequence_header on;
  797. }
  798. # @see publish.srs.com
  799. publish {
  800. mr off;
  801. firstpkt_timeout 20000;
  802. normal_timeout 7000;
  803. }
  804. }
  805. # the publish specified configs
  806. vhost publish.srs.com {
  807. # the config for FMLE/Flash publisher, which push RTMP to SRS.
  808. publish {
  809. # about MR, read https://github.com/ossrs/srs/issues/241
  810. # when enabled the mr, SRS will read as large as possible.
  811. # default: off
  812. mr off;
  813. # the latency in ms for MR(merged-read),
  814. # the performance+ when latency+, and memory+,
  815. # memory(buffer) = latency * kbps / 8
  816. # for example, latency=500ms, kbps=3000kbps, each publish connection will consume
  817. # memory = 500 * 3000 / 8 = 187500B = 183KB
  818. # when there are 2500 publisher, the total memory of SRS at least:
  819. # 183KB * 2500 = 446MB
  820. # the recommended value is [300, 2000]
  821. # default: 350
  822. mr_latency 350;
  823. # the 1st packet timeout in ms for encoder.
  824. # default: 20000
  825. firstpkt_timeout 20000;
  826. # the normal packet timeout in ms for encoder.
  827. # default: 5000
  828. normal_timeout 7000;
  829. # whether parse the sps when publish stream.
  830. # we can got the resolution of video for stat api.
  831. # but we may failed to cause publish failed.
  832. # @remark If disabled, HLS might never update the sps/pps, it depends on this.
  833. # default: on
  834. parse_sps on;
  835. }
  836. }
  837. # the vhost for anti-suck.
  838. vhost refer.anti_suck.com {
  839. # refer hotlink-denial.
  840. refer {
  841. # whether enable the refer hotlink-denial.
  842. # default: off.
  843. enabled on;
  844. # the common refer for play and publish.
  845. # if the page url of client not in the refer, access denied.
  846. # if not specified this field, allow all.
  847. # default: not specified.
  848. all github.com github.io;
  849. # refer for publish clients specified.
  850. # the common refer is not overridden by this.
  851. # if not specified this field, allow all.
  852. # default: not specified.
  853. publish github.com github.io;
  854. # refer for play clients specified.
  855. # the common refer is not overridden by this.
  856. # if not specified this field, allow all.
  857. # default: not specified.
  858. play github.com github.io;
  859. }
  860. }
  861. # the security to allow or deny clients.
  862. vhost security.srs.com {
  863. # security for host to allow or deny clients.
  864. # @see https://github.com/ossrs/srs/issues/211
  865. security {
  866. # whether enable the security for vhost.
  867. # default: off
  868. enabled on;
  869. # the security list, each item format as:
  870. # allow|deny publish|play all|<ip>
  871. # for example:
  872. # allow publish all;
  873. # deny publish all;
  874. # allow publish 127.0.0.1;
  875. # deny publish 127.0.0.1;
  876. # allow play all;
  877. # deny play all;
  878. # allow play 127.0.0.1;
  879. # deny play 127.0.0.1;
  880. # SRS apply the following simple strategies one by one:
  881. # 1. allow all if security disabled.
  882. # 2. default to deny all when security enabled.
  883. # 3. allow if matches allow strategy.
  884. # 4. deny if matches deny strategy.
  885. allow play all;
  886. allow publish all;
  887. }
  888. }
  889. # vhost for http static and flv vod stream for each vhost.
  890. vhost http.static.srs.com {
  891. # http static vhost specified config
  892. http_static {
  893. # whether enabled the http static service for vhost.
  894. # default: off
  895. enabled on;
  896. # the url to mount to,
  897. # typical mount to [vhost]/
  898. # the variables:
  899. # [vhost] current vhost for http server.
  900. # @remark the [vhost] is optional, used to mount at specified vhost.
  901. # @remark the http of __defaultVhost__ will override the http_server section.
  902. # for example:
  903. # mount to [vhost]/
  904. # access by http://ossrs.net:8080/xxx.html
  905. # mount to [vhost]/hls
  906. # access by http://ossrs.net:8080/hls/xxx.html
  907. # mount to /
  908. # access by http://ossrs.net:8080/xxx.html
  909. # or by http://192.168.1.173:8080/xxx.html
  910. # mount to /hls
  911. # access by http://ossrs.net:8080/hls/xxx.html
  912. # or by http://192.168.1.173:8080/hls/xxx.html
  913. # @remark the port of http is specified by http_server section.
  914. # default: [vhost]/
  915. mount [vhost]/hls;
  916. # main dir of vhost,
  917. # to delivery HTTP stream of this vhost.
  918. # default: ./objs/nginx/html
  919. dir ./objs/nginx/html/hls;
  920. }
  921. }
  922. # vhost for http flv/aac/mp3 live stream for each vhost.
  923. vhost http.remux.srs.com {
  924. # http flv/mp3/aac/ts stream vhost specified config
  925. http_remux {
  926. # whether enable the http live streaming service for vhost.
  927. # default: off
  928. enabled on;
  929. # the fast cache for audio stream(mp3/aac),
  930. # to cache more audio and send to client in a time to make android(weixin) happy.
  931. # @remark the flv/ts stream ignore it
  932. # @remark 0 to disable fast cache for http audio stream.
  933. # default: 0
  934. fast_cache 30;
  935. # the stream mount for rtmp to remux to live streaming.
  936. # typical mount to [vhost]/[app]/[stream].flv
  937. # the variables:
  938. # [vhost] current vhost for http live stream.
  939. # [app] current app for http live stream.
  940. # [stream] current stream for http live stream.
  941. # @remark the [vhost] is optional, used to mount at specified vhost.
  942. # the extension:
  943. # .flv mount http live flv stream, use default gop cache.
  944. # .ts mount http live ts stream, use default gop cache.
  945. # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required.
  946. # .aac mount http live aac stream, ignore video and audio aac codec required.
  947. # for example:
  948. # mount to [vhost]/[app]/[stream].flv
  949. # access by http://ossrs.net:8080/live/livestream.flv
  950. # mount to /[app]/[stream].flv
  951. # access by http://ossrs.net:8080/live/livestream.flv
  952. # or by http://192.168.1.173:8080/live/livestream.flv
  953. # mount to [vhost]/[app]/[stream].mp3
  954. # access by http://ossrs.net:8080/live/livestream.mp3
  955. # mount to [vhost]/[app]/[stream].aac
  956. # access by http://ossrs.net:8080/live/livestream.aac
  957. # mount to [vhost]/[app]/[stream].ts
  958. # access by http://ossrs.net:8080/live/livestream.ts
  959. # @remark the port of http is specified by http_server section.
  960. # default: [vhost]/[app]/[stream].flv
  961. mount [vhost]/[app]/[stream].flv;
  962. }
  963. }
  964. # the http hook callback vhost, srs will invoke the hooks for specified events.
  965. vhost hooks.callback.srs.com {
  966. http_hooks {
  967. # whether the http hooks enable.
  968. # default off.
  969. enabled on;
  970. # when client connect to vhost/app, call the hook,
  971. # the request in the POST data string is a object encode by json:
  972. # {
  973. # "action": "on_connect",
  974. # "client_id": 1985,
  975. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  976. # "tcUrl": "rtmp://video.test.com/live?key=d2fa801d08e3f90ed1e1670e6e52651a",
  977. # "pageUrl": "http://www.test.com/live.html", "server_id": "vid-werty"
  978. # }
  979. # if valid, the hook must return HTTP code 200(Status OK) and response
  980. # an int value specifies the error code(0 corresponding to success):
  981. # 0
  982. # support multiple api hooks, format:
  983. # on_connect http://xxx/api0 http://xxx/api1 http://xxx/apiN
  984. # @remark For SRS4, the HTTPS url is supported, for example:
  985. # on_connect https://xxx/api0 https://xxx/api1 https://xxx/apiN
  986. on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients;
  987. # when client close/disconnect to vhost/app/stream, call the hook,
  988. # the request in the POST data string is a object encode by json:
  989. # {
  990. # "action": "on_close",
  991. # "client_id": 1985,
  992. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  993. # "send_bytes": 10240, "recv_bytes": 10240, "server_id": "vid-werty"
  994. # }
  995. # if valid, the hook must return HTTP code 200(Status OK) and response
  996. # an int value specifies the error code(0 corresponding to success):
  997. # 0
  998. # support multiple api hooks, format:
  999. # on_close http://xxx/api0 http://xxx/api1 http://xxx/apiN
  1000. # @remark For SRS4, the HTTPS url is supported, for example:
  1001. # on_close https://xxx/api0 https://xxx/api1 https://xxx/apiN
  1002. on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients;
  1003. # when client(encoder) publish to vhost/app/stream, call the hook,
  1004. # the request in the POST data string is a object encode by json:
  1005. # {
  1006. # "action": "on_publish",
  1007. # "client_id": 1985,
  1008. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  1009. # "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
  1010. # }
  1011. # if valid, the hook must return HTTP code 200(Status OK) and response
  1012. # an int value specifies the error code(0 corresponding to success):
  1013. # 0
  1014. # support multiple api hooks, format:
  1015. # on_publish http://xxx/api0 http://xxx/api1 http://xxx/apiN
  1016. # @remark For SRS4, the HTTPS url is supported, for example:
  1017. # on_publish https://xxx/api0 https://xxx/api1 https://xxx/apiN
  1018. on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams;
  1019. # when client(encoder) stop publish to vhost/app/stream, call the hook,
  1020. # the request in the POST data string is a object encode by json:
  1021. # {
  1022. # "action": "on_unpublish",
  1023. # "client_id": 1985,
  1024. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  1025. # "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
  1026. # }
  1027. # if valid, the hook must return HTTP code 200(Status OK) and response
  1028. # an int value specifies the error code(0 corresponding to success):
  1029. # 0
  1030. # support multiple api hooks, format:
  1031. # on_unpublish http://xxx/api0 http://xxx/api1 http://xxx/apiN
  1032. # @remark For SRS4, the HTTPS url is supported, for example:
  1033. # on_unpublish https://xxx/api0 https://xxx/api1 https://xxx/apiN
  1034. on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams;
  1035. # when client start to play vhost/app/stream, call the hook,
  1036. # the request in the POST data string is a object encode by json:
  1037. # {
  1038. # "action": "on_play",
  1039. # "client_id": 1985,
  1040. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  1041. # "stream": "livestream", "param":"?token=xxx&salt=yyy",
  1042. # "pageUrl": "http://www.test.com/live.html", "server_id": "vid-werty"
  1043. # }
  1044. # if valid, the hook must return HTTP code 200(Status OK) and response
  1045. # an int value specifies the error code(0 corresponding to success):
  1046. # 0
  1047. # support multiple api hooks, format:
  1048. # on_play http://xxx/api0 http://xxx/api1 http://xxx/apiN
  1049. # @remark For SRS4, the HTTPS url is supported, for example:
  1050. # on_play https://xxx/api0 https://xxx/api1 https://xxx/apiN
  1051. on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
  1052. # when client stop to play vhost/app/stream, call the hook,
  1053. # the request in the POST data string is a object encode by json:
  1054. # {
  1055. # "action": "on_stop",
  1056. # "client_id": 1985,
  1057. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  1058. # "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
  1059. # }
  1060. # if valid, the hook must return HTTP code 200(Status OK) and response
  1061. # an int value specifies the error code(0 corresponding to success):
  1062. # 0
  1063. # support multiple api hooks, format:
  1064. # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN
  1065. # @remark For SRS4, the HTTPS url is supported, for example:
  1066. # on_stop https://xxx/api0 https://xxx/api1 https://xxx/apiN
  1067. on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
  1068. # when srs reap a dvr file, call the hook,
  1069. # the request in the POST data string is a object encode by json:
  1070. # {
  1071. # "action": "on_dvr",
  1072. # "client_id": 1985,
  1073. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  1074. # "stream": "livestream", "param":"?token=xxx&salt=yyy",
  1075. # "cwd": "/usr/local/srs",
  1076. # "file": "./objs/nginx/html/live/livestream.1420254068776.flv", "server_id": "vid-werty"
  1077. # }
  1078. # if valid, the hook must return HTTP code 200(Status OK) and response
  1079. # an int value specifies the error code(0 corresponding to success):
  1080. # 0
  1081. on_dvr http://127.0.0.1:8085/api/v1/dvrs http://localhost:8085/api/v1/dvrs;
  1082. # when srs reap a ts file of hls, call the hook,
  1083. # the request in the POST data string is a object encode by json:
  1084. # {
  1085. # "action": "on_hls",
  1086. # "client_id": 1985,
  1087. # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
  1088. # "stream": "livestream", "param":"?token=xxx&salt=yyy",
  1089. # "duration": 9.36, // in seconds
  1090. # "cwd": "/usr/local/srs",
  1091. # "file": "./objs/nginx/html/live/livestream/2015-04-23/01/476584165.ts",
  1092. # "url": "live/livestream/2015-04-23/01/476584165.ts",
  1093. # "m3u8": "./objs/nginx/html/live/livestream/live.m3u8",
  1094. # "m3u8_url": "live/livestream/live.m3u8",
  1095. # "seq_no": 100, "server_id": "vid-werty"
  1096. # }
  1097. # if valid, the hook must return HTTP code 200(Status OK) and response
  1098. # an int value specifies the error code(0 corresponding to success):
  1099. # 0
  1100. on_hls http://127.0.0.1:8085/api/v1/hls http://localhost:8085/api/v1/hls;
  1101. # when srs reap a ts file of hls, call this hook,
  1102. # used to push file to cdn network, by get the ts file from cdn network.
  1103. # so we use HTTP GET and use the variable following:
  1104. # [server_id], replace with the server_id
  1105. # [app], replace with the app.
  1106. # [stream], replace with the stream.
  1107. # [param], replace with the param.
  1108. # [ts_url], replace with the ts url.
  1109. # ignore any return data of server.
  1110. # @remark random select a url to report, not report all.
  1111. on_hls_notify http://127.0.0.1:8085/api/v1/hls/[server_id]/[app]/[stream]/[ts_url][param];
  1112. }
  1113. }
  1114. # the vhost for exec, fork process when publish stream.
  1115. vhost exec.srs.com {
  1116. # the exec used to fork process when got some event.
  1117. exec {
  1118. # whether enable the exec.
  1119. # default: off.
  1120. enabled off;
  1121. # when publish stream, exec the process with variables:
  1122. # [vhost] the input stream vhost.
  1123. # [port] the input stream port.
  1124. # [app] the input stream app.
  1125. # [stream] the input stream name.
  1126. # [engine] the transcode engine name.
  1127. # other variables for exec only:
  1128. # [url] the rtmp url which trigger the publish.
  1129. # [tcUrl] the client request tcUrl.
  1130. # [swfUrl] the client request swfUrl.
  1131. # [pageUrl] the client request pageUrl.
  1132. # we also support datetime variables.
  1133. # [2006], replace this const to current year.
  1134. # [01], replace this const to current month.
  1135. # [02], replace this const to current date.
  1136. # [15], replace this const to current hour.
  1137. # [04], replace this const to current minute.
  1138. # [05], replace this const to current second.
  1139. # [999], replace this const to current millisecond.
  1140. # [timestamp],replace this const to current UNIX timestamp in ms.
  1141. # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]"
  1142. # @remark empty to ignore this exec.
  1143. publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv;
  1144. }
  1145. }
  1146. # The vhost for MPEG-DASH.
  1147. vhost dash.srs.com {
  1148. dash {
  1149. # Whether DASH is enabled.
  1150. # Transmux RTMP to DASH if on.
  1151. # Default: off
  1152. enabled on;
  1153. # The duration of segment in seconds.
  1154. # Default: 30
  1155. dash_fragment 30;
  1156. # The period to update the MPD in seconds.
  1157. # Default: 150
  1158. dash_update_period 150;
  1159. # The depth of timeshift buffer in seconds.
  1160. # Default: 300
  1161. dash_timeshift 300;
  1162. # The base/home dir/path for dash.
  1163. # All init and segment files will write under this dir.
  1164. dash_path ./objs/nginx/html;
  1165. # The DASH MPD file path.
  1166. # We supports some variables to generate the filename.
  1167. # [vhost], the vhost of stream.
  1168. # [app], the app of stream.
  1169. # [stream], the stream name of stream.
  1170. # Default: [app]/[stream].mpd
  1171. dash_mpd_file [app]/[stream].mpd;
  1172. }
  1173. }
  1174. # the vhost with hls specified.
  1175. vhost hls.srs.com {
  1176. hls {
  1177. # whether the hls is enabled.
  1178. # if off, do not write hls(ts and m3u8) when publish.
  1179. # default: off
  1180. enabled on;
  1181. # the hls fragment in seconds, the duration of a piece of ts.
  1182. # default: 10
  1183. hls_fragment 10;
  1184. # the hls m3u8 target duration ratio,
  1185. # EXT-X-TARGETDURATION = hls_td_ratio * hls_fragment // init
  1186. # EXT-X-TARGETDURATION = max(ts_duration, EXT-X-TARGETDURATION) // for each ts
  1187. # @see https://github.com/ossrs/srs/issues/304#issuecomment-74000081
  1188. # default: 1.5
  1189. hls_td_ratio 1.5;
  1190. # the audio overflow ratio.
  1191. # for pure audio, the duration to reap the segment.
  1192. # for example, the hls_fragment is 10s, hls_aof_ratio is 2.0,
  1193. # the segment will reap to 20s for pure audio.
  1194. # default: 2.0
  1195. hls_aof_ratio 2.0;
  1196. # the hls window in seconds, the number of ts in m3u8.
  1197. # default: 60
  1198. hls_window 60;
  1199. # the error strategy. can be:
  1200. # ignore, disable the hls.
  1201. # disconnect, require encoder republish.
  1202. # continue, ignore failed try to continue output hls.
  1203. # @see https://github.com/ossrs/srs/issues/264
  1204. # default: continue
  1205. hls_on_error continue;
  1206. # the hls output path.
  1207. # the m3u8 file is configured by hls_path/hls_m3u8_file, the default is:
  1208. # ./objs/nginx/html/[app]/[stream].m3u8
  1209. # the ts file is configured by hls_path/hls_ts_file, the default is:
  1210. # ./objs/nginx/html/[app]/[stream]-[seq].ts
  1211. # @remark the hls_path is compatible with srs v1 config.
  1212. # default: ./objs/nginx/html
  1213. hls_path ./objs/nginx/html;
  1214. # the hls m3u8 file name.
  1215. # we supports some variables to generate the filename.
  1216. # [vhost], the vhost of stream.
  1217. # [app], the app of stream.
  1218. # [stream], the stream name of stream.
  1219. # default: [app]/[stream].m3u8
  1220. hls_m3u8_file [app]/[stream].m3u8;
  1221. # the hls ts file name.
  1222. # we supports some variables to generate the filename.
  1223. # [vhost], the vhost of stream.
  1224. # [app], the app of stream.
  1225. # [stream], the stream name of stream.
  1226. # [2006], replace this const to current year.
  1227. # [01], replace this const to current month.
  1228. # [02], replace this const to current date.
  1229. # [15], replace this const to current hour.
  1230. # [04], replace this const to current minute.
  1231. # [05], replace this const to current second.
  1232. # [999], replace this const to current millisecond.
  1233. # [timestamp],replace this const to current UNIX timestamp in ms.
  1234. # [seq], the sequence number of ts.
  1235. # [duration], replace this const to current ts duration.
  1236. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr#custom-path
  1237. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/delivery-hls#hls-config
  1238. # default: [app]/[stream]-[seq].ts
  1239. hls_ts_file [app]/[stream]-[seq].ts;
  1240. # whether use floor for the hls_ts_file path generation.
  1241. # if on, use floor(timestamp/hls_fragment) as the variable [timestamp],
  1242. # and use enhanced algorithm to calc deviation for segment.
  1243. # @remark when floor on, recommend the hls_segment>=2*gop.
  1244. # default: off
  1245. hls_ts_floor off;
  1246. # the hls entry prefix, which is base url of ts url.
  1247. # for example, the prefix is:
  1248. # http://your-server/
  1249. # then, the ts path in m3u8 will be like:
  1250. # http://your-server/live/livestream-0.ts
  1251. # http://your-server/live/livestream-1.ts
  1252. # ...
  1253. # optional, default to empty string.
  1254. hls_entry_prefix http://your-server;
  1255. # the default audio codec of hls.
  1256. # when codec changed, write the PAT/PMT table, but maybe ok util next ts.
  1257. # so user can set the default codec for mp3.
  1258. # the available audio codec:
  1259. # aac, mp3, an
  1260. # default: aac
  1261. hls_acodec aac;
  1262. # the default video codec of hls.
  1263. # when codec changed, write the PAT/PMT table, but maybe ok util next ts.
  1264. # so user can set the default codec for pure audio(without video) to vn.
  1265. # the available video codec:
  1266. # h264, vn
  1267. # default: h264
  1268. hls_vcodec h264;
  1269. # whether cleanup the old expired ts files.
  1270. # default: on
  1271. hls_cleanup on;
  1272. # If there is no incoming packets, dispose HLS in this timeout in seconds,
  1273. # which removes all HLS files including m3u8 and ts files.
  1274. # @remark 0 to disable dispose for publisher.
  1275. # @remark apply for publisher timeout only, while "etc/init.d/srs stop" always dispose hls.
  1276. # default: 0
  1277. hls_dispose 0;
  1278. # the max size to notify hls,
  1279. # to read max bytes from ts of specified cdn network,
  1280. # @remark only used when on_hls_notify is config.
  1281. # default: 64
  1282. hls_nb_notify 64;
  1283. # whether wait keyframe to reap segment,
  1284. # if off, reap segment when duration exceed the fragment,
  1285. # if on, reap segment when duration exceed and got keyframe.
  1286. # default: on
  1287. hls_wait_keyframe on;
  1288. # whether using AES encryption.
  1289. # default: off
  1290. hls_keys on;
  1291. # the number of clear ts which one key can encrypt.
  1292. # default: 5
  1293. hls_fragments_per_key 5;
  1294. # the hls key file name.
  1295. # we supports some variables to generate the filename.
  1296. # [vhost], the vhost of stream.
  1297. # [app], the app of stream.
  1298. # [stream], the stream name of stream.
  1299. # [seq], the sequence number of key corresponding to the ts.
  1300. hls_key_file [app]/[stream]-[seq].key;
  1301. # the key output path.
  1302. # the key file is configed by hls_path/hls_key_file, the default is:
  1303. # ./objs/nginx/html/[app]/[stream]-[seq].key
  1304. hls_key_file_path ./objs/nginx/html;
  1305. # the key root URL, use this can support https.
  1306. # @remark It's optional.
  1307. hls_key_url https://localhost:8080;
  1308. # Special control controls.
  1309. ###########################################
  1310. # Whether calculate the DTS of audio frame directly.
  1311. # If on, guess the specific DTS by AAC samples, please read https://github.com/ossrs/srs/issues/547#issuecomment-294350544
  1312. # If off, directly turn the FLV timestamp to DTS, which might cause corrupt audio stream.
  1313. # @remark Recommend to set to off, unless your audio stream sample-rate and timestamp is not correct.
  1314. # Default: on
  1315. hls_dts_directly on;
  1316. # on_hls, never config in here, should config in http_hooks.
  1317. # for the hls http callback, @see http_hooks.on_hls of vhost hooks.callback.srs.com
  1318. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/delivery-hls#http-callback
  1319. # @see https://ossrs.io/lts/en-us/docs/v4/doc/delivery-hls#http-callback
  1320. # on_hls_notify, never config in here, should config in http_hooks.
  1321. # we support the variables to generate the notify url:
  1322. # [app], replace with the app.
  1323. # [stream], replace with the stream.
  1324. # [param], replace with the param.
  1325. # [ts_url], replace with the ts url.
  1326. # for the hls http callback, @see http_hooks.on_hls_notify of vhost hooks.callback.srs.com
  1327. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/delivery-hls#on-hls-notify
  1328. # @see https://ossrs.io/lts/en-us/docs/v4/doc/delivery-hls#on-hls-notify
  1329. }
  1330. }
  1331. # the vhost with hls disabled.
  1332. vhost no-hls.srs.com {
  1333. hls {
  1334. # whether the hls is enabled.
  1335. # if off, do not write hls(ts and m3u8) when publish.
  1336. # default: off
  1337. enabled off;
  1338. }
  1339. }
  1340. # the vhost with adobe hds
  1341. vhost hds.srs.com {
  1342. hds {
  1343. # whether hds enabled
  1344. # default: off
  1345. enabled on;
  1346. # the hds fragment in seconds.
  1347. # default: 10
  1348. hds_fragment 10;
  1349. # the hds window in seconds, erase the segment when exceed the window.
  1350. # default: 60
  1351. hds_window 60;
  1352. # the path to store the hds files.
  1353. # default: ./objs/nginx/html
  1354. hds_path ./objs/nginx/html;
  1355. }
  1356. }
  1357. # vhost for dvr
  1358. vhost dvr.srs.com {
  1359. # DVR RTMP stream to file,
  1360. # start to record to file when encoder publish,
  1361. # reap flv/mp4 according by specified dvr_plan.
  1362. dvr {
  1363. # whether enabled dvr features
  1364. # default: off
  1365. enabled on;
  1366. # the filter for dvr to apply to.
  1367. # all, dvr all streams of all apps.
  1368. # <app>/<stream>, apply to specified stream of app.
  1369. # for example, to dvr the following two streams:
  1370. # live/stream1 live/stream2
  1371. # @remark Reload is disabled, @see https://github.com/ossrs/srs/issues/2181
  1372. # default: all
  1373. dvr_apply all;
  1374. # the dvr plan. canbe:
  1375. # session reap flv/mp4 when session end(unpublish).
  1376. # segment reap flv/mp4 when flv duration exceed the specified dvr_duration.
  1377. # @remark The plan append is removed in SRS3+, for it's no use.
  1378. # default: session
  1379. dvr_plan session;
  1380. # the dvr output path, *.flv or *.mp4.
  1381. # we supports some variables to generate the filename.
  1382. # [vhost], the vhost of stream.
  1383. # [app], the app of stream.
  1384. # [stream], the stream name of stream.
  1385. # [2006], replace this const to current year.
  1386. # [01], replace this const to current month.
  1387. # [02], replace this const to current date.
  1388. # [15], replace this const to current hour.
  1389. # [04], replace this const to current minute.
  1390. # [05], replace this const to current second.
  1391. # [999], replace this const to current millisecond.
  1392. # [timestamp],replace this const to current UNIX timestamp in ms.
  1393. # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]"
  1394. # for example, for url rtmp://ossrs.net/live/livestream and time 2015-01-03 10:57:30.776
  1395. # 1. No variables, the rule of SRS1.0(auto add [stream].[timestamp].flv as filename):
  1396. # dvr_path ./objs/nginx/html;
  1397. # =>
  1398. # dvr_path ./objs/nginx/html/live/livestream.1420254068776.flv;
  1399. # 2. Use stream and date as dir name, time as filename:
  1400. # dvr_path /data/[vhost]/[app]/[stream]/[2006]/[01]/[02]/[15].[04].[05].[999].flv;
  1401. # =>
  1402. # dvr_path /data/ossrs.net/live/livestream/2015/01/03/10.57.30.776.flv;
  1403. # 3. Use stream and year/month as dir name, date and time as filename:
  1404. # dvr_path /data/[vhost]/[app]/[stream]/[2006]/[01]/[02]-[15].[04].[05].[999].flv;
  1405. # =>
  1406. # dvr_path /data/ossrs.net/live/livestream/2015/01/03-10.57.30.776.flv;
  1407. # 4. Use vhost/app and year/month as dir name, stream/date/time as filename:
  1408. # dvr_path /data/[vhost]/[app]/[2006]/[01]/[stream]-[02]-[15].[04].[05].[999].flv;
  1409. # =>
  1410. # dvr_path /data/ossrs.net/live/2015/01/livestream-03-10.57.30.776.flv;
  1411. # 5. DVR to mp4:
  1412. # dvr_path ./objs/nginx/html/[app]/[stream].[timestamp].mp4;
  1413. # =>
  1414. # dvr_path ./objs/nginx/html/live/livestream.1420254068776.mp4;
  1415. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr#custom-path
  1416. # @see https://ossrs.io/lts/en-us/docs/v4/doc/dvr#custom-path
  1417. # segment,session apply it.
  1418. # default: ./objs/nginx/html/[app]/[stream].[timestamp].flv
  1419. dvr_path ./objs/nginx/html/[app]/[stream].[timestamp].flv;
  1420. # the duration for dvr file, reap if exceed, in seconds.
  1421. # segment apply it.
  1422. # session,append ignore.
  1423. # default: 30
  1424. dvr_duration 30;
  1425. # whether wait keyframe to reap segment,
  1426. # if off, reap segment when duration exceed the dvr_duration,
  1427. # if on, reap segment when duration exceed and got keyframe.
  1428. # segment apply it.
  1429. # session,append ignore.
  1430. # default: on
  1431. dvr_wait_keyframe on;
  1432. # about the stream monotonically increasing:
  1433. # 1. video timestamp is monotonically increasing,
  1434. # 2. audio timestamp is monotonically increasing,
  1435. # 3. video and audio timestamp is interleaved monotonically increasing.
  1436. # it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format
  1437. # however, some encoder cannot provides this feature, please set this to off to ignore time jitter.
  1438. # the time jitter algorithm:
  1439. # 1. full, to ensure stream start at zero, and ensure stream monotonically increasing.
  1440. # 2. zero, only ensure stream start at zero, ignore timestamp jitter.
  1441. # 3. off, disable the time jitter algorithm, like atc.
  1442. # apply for all dvr plan.
  1443. # default: full
  1444. time_jitter full;
  1445. # on_dvr, never config in here, should config in http_hooks.
  1446. # for the dvr http callback, @see http_hooks.on_dvr of vhost hooks.callback.srs.com
  1447. # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr#http-callback
  1448. # @see https://ossrs.io/lts/en-us/docs/v4/doc/dvr#http-callback
  1449. }
  1450. }
  1451. # vhost for ingest
  1452. vhost ingest.srs.com {
  1453. # ingest file/stream/device then push to SRS over RTMP.
  1454. # the name/id used to identify the ingest, must be unique in global.
  1455. # ingest id is used in reload or http api management.
  1456. # @remark vhost can contains multiple ingest
  1457. ingest livestream {
  1458. # whether enabled ingest features
  1459. # default: off
  1460. enabled on;
  1461. # input file/stream/device
  1462. # @remark only support one input.
  1463. input {
  1464. # the type of input.
  1465. # can be file/stream/device, that is,
  1466. # file: ingest file specified by url.
  1467. # stream: ingest stream specified by url.
  1468. # device: not support yet.
  1469. # default: file
  1470. type file;
  1471. # the url of file/stream.
  1472. url ./doc/source.200kbps.768x320.flv;
  1473. }
  1474. # the ffmpeg
  1475. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1476. # the transcode engine, @see all.transcode.srs.com
  1477. # @remark, the output is specified following.
  1478. engine {
  1479. # @see enabled of transcode engine.
  1480. # if disabled or vcodec/acodec not specified, use copy.
  1481. # default: off.
  1482. enabled off;
  1483. # output stream. variables:
  1484. # [vhost] current vhost which start the ingest.
  1485. # [port] system RTMP stream port.
  1486. # we also support datetime variables.
  1487. # [2006], replace this const to current year.
  1488. # [01], replace this const to current month.
  1489. # [02], replace this const to current date.
  1490. # [15], replace this const to current hour.
  1491. # [04], replace this const to current minute.
  1492. # [05], replace this const to current second.
  1493. # [999], replace this const to current millisecond.
  1494. # [timestamp],replace this const to current UNIX timestamp in ms.
  1495. # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]"
  1496. output rtmp://127.0.0.1:[port]/live?vhost=[vhost]/livestream;
  1497. }
  1498. }
  1499. }
  1500. # the vhost for ingest with transcode engine.
  1501. vhost transcode.ingest.srs.com {
  1502. ingest livestream {
  1503. enabled on;
  1504. input {
  1505. type file;
  1506. url ./doc/source.200kbps.768x320.flv;
  1507. }
  1508. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1509. engine {
  1510. enabled off;
  1511. perfile {
  1512. re;
  1513. rtsp_transport tcp;
  1514. }
  1515. iformat flv;
  1516. vfilter {
  1517. i ./doc/ffmpeg-logo.png;
  1518. filter_complex 'overlay=10:10';
  1519. }
  1520. vcodec libx264;
  1521. vbitrate 1500;
  1522. vfps 25;
  1523. vwidth 768;
  1524. vheight 320;
  1525. vthreads 12;
  1526. vprofile main;
  1527. vpreset medium;
  1528. vparams {
  1529. t 100;
  1530. coder 1;
  1531. b_strategy 2;
  1532. bf 3;
  1533. refs 10;
  1534. }
  1535. acodec libfdk_aac;
  1536. abitrate 70;
  1537. asample_rate 44100;
  1538. achannels 2;
  1539. aparams {
  1540. profile:a aac_low;
  1541. }
  1542. oformat flv;
  1543. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream];
  1544. }
  1545. }
  1546. }
  1547. # the main comments for transcode
  1548. vhost example.transcode.srs.com {
  1549. # the streaming transcode configs.
  1550. # @remark vhost can contains multiple transcode
  1551. transcode {
  1552. # whether the transcode enabled.
  1553. # if off, donot transcode.
  1554. # default: off.
  1555. enabled on;
  1556. # the ffmpeg
  1557. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1558. # the transcode engine for matched stream.
  1559. # all matched stream will transcoded to the following stream.
  1560. # the transcode set name(ie. hd) is optional and not used.
  1561. # we will build the parameters to fork ffmpeg:
  1562. # ffmpeg <perfile>
  1563. # -i <iformat>
  1564. # <vfilter>
  1565. # -vcodec <vcodec> -b:v <vbitrate> -r <vfps> -s <vwidth>x<vheight> -profile:v <vprofile> -preset <vpreset>
  1566. # <vparams>
  1567. # -acodec <acodec> -b:a <abitrate> -ar <asample_rate> -ac <achannels>
  1568. # <aparams>
  1569. # -f <oformat>
  1570. # -y <output>
  1571. engine example {
  1572. # whether the engine is enabled
  1573. # default: off.
  1574. enabled on;
  1575. # pre-file options, before "-i"
  1576. perfile {
  1577. re;
  1578. rtsp_transport tcp;
  1579. }
  1580. # input format "-i", can be:
  1581. # off, do not specifies the format, ffmpeg will guess it.
  1582. # flv, for flv or RTMP stream.
  1583. # other format, for example, mp4/aac whatever.
  1584. # default: flv
  1585. iformat flv;
  1586. # ffmpeg filters, between "-i" and "-vcodec"
  1587. # follows the main input.
  1588. vfilter {
  1589. # the logo input file.
  1590. i ./doc/ffmpeg-logo.png;
  1591. # the ffmpeg complex filter.
  1592. # for filters, @see: http://ffmpeg.org/ffmpeg-filters.html
  1593. filter_complex 'overlay=10:10';
  1594. }
  1595. # video encoder name, "ffmpeg -vcodec"
  1596. # can be:
  1597. # libx264: use h.264(libx264) video encoder.
  1598. # png: use png to snapshot thumbnail.
  1599. # copy: donot encoder the video stream, copy it.
  1600. # vn: disable video output.
  1601. vcodec libx264;
  1602. # video bitrate, in kbps, "ffmepg -b:v"
  1603. # @remark 0 to use source video bitrate.
  1604. # default: 0
  1605. vbitrate 1500;
  1606. # video framerate, "ffmepg -r"
  1607. # @remark 0 to use source video fps.
  1608. # default: 0
  1609. vfps 25;
  1610. # video width, must be even numbers, "ffmepg -s"
  1611. # @remark 0 to use source video width.
  1612. # default: 0
  1613. vwidth 768;
  1614. # video height, must be even numbers, "ffmepg -s"
  1615. # @remark 0 to use source video height.
  1616. # default: 0
  1617. vheight 320;
  1618. # the max threads for ffmpeg to used, "ffmepg -thread"
  1619. # default: 1
  1620. vthreads 12;
  1621. # x264 profile, "ffmepg -profile:v"
  1622. # @see x264 -help, can be:
  1623. # high,main,baseline
  1624. vprofile main;
  1625. # x264 preset, "ffmpeg -preset"
  1626. # @see x264 -help, can be:
  1627. # ultrafast,superfast,veryfast,faster,fast
  1628. # medium,slow,slower,veryslow,placebo
  1629. vpreset medium;
  1630. # other x264 or ffmpeg video params, between "-preset" and "-acodec"
  1631. vparams {
  1632. # ffmpeg options, @see: http://ffmpeg.org/ffmpeg.html
  1633. t 100;
  1634. # 264 params, @see: http://ffmpeg.org/ffmpeg-codecs.html#libx264
  1635. coder 1;
  1636. b_strategy 2;
  1637. bf 3;
  1638. refs 10;
  1639. }
  1640. # audio encoder name, "ffmpeg -acodec"
  1641. # can be:
  1642. # libfdk_aac: use aac(libfdk_aac) audio encoder.
  1643. # copy: donot encoder the audio stream, copy it.
  1644. # an: disable audio output.
  1645. acodec libfdk_aac;
  1646. # audio bitrate, in kbps, "ffmpeg -b:a"
  1647. # [16, 72] for libfdk_aac.
  1648. # @remark 0 to use source audio bitrate.
  1649. # default: 0
  1650. abitrate 70;
  1651. # audio sample rate, "ffmpeg -ar"
  1652. # for flv/rtmp, it must be:
  1653. # 44100,22050,11025,5512
  1654. # @remark 0 to use source audio sample rate.
  1655. # default: 0
  1656. asample_rate 44100;
  1657. # audio channel, "ffmpeg -ac"
  1658. # 1 for mono, 2 for stereo.
  1659. # @remark 0 to use source audio channels.
  1660. # default: 0
  1661. achannels 2;
  1662. # other ffmpeg audio params, between "-ac" and "-f"/"-y"
  1663. aparams {
  1664. # audio params, @see: http://ffmpeg.org/ffmpeg-codecs.html#Audio-Encoders
  1665. # @remark SRS supported aac profile for HLS is: aac_low, aac_he, aac_he_v2
  1666. profile:a aac_low;
  1667. bsf:a aac_adtstoasc;
  1668. }
  1669. # output format, "ffmpeg -f" can be:
  1670. # off, do not specifies the format, ffmpeg will guess it.
  1671. # flv, for flv or RTMP stream.
  1672. # image2, for vcodec png to snapshot thumbnail.
  1673. # other format, for example, mp4/aac whatever.
  1674. # default: flv
  1675. oformat flv;
  1676. # output stream, "ffmpeg -y", variables:
  1677. # [vhost] the input stream vhost.
  1678. # [port] the input stream port.
  1679. # [app] the input stream app.
  1680. # [stream] the input stream name.
  1681. # [engine] the transcode engine name.
  1682. # we also support datetime variables.
  1683. # [2006], replace this const to current year.
  1684. # [01], replace this const to current month.
  1685. # [02], replace this const to current date.
  1686. # [15], replace this const to current hour.
  1687. # [04], replace this const to current minute.
  1688. # [05], replace this const to current second.
  1689. # [999], replace this const to current millisecond.
  1690. # [timestamp],replace this const to current UNIX timestamp in ms.
  1691. # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]"
  1692. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1693. }
  1694. }
  1695. }
  1696. # the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction
  1697. vhost mirror.transcode.srs.com {
  1698. transcode {
  1699. enabled on;
  1700. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1701. engine mirror {
  1702. enabled on;
  1703. vfilter {
  1704. vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2';
  1705. }
  1706. vcodec libx264;
  1707. vbitrate 300;
  1708. vfps 20;
  1709. vwidth 768;
  1710. vheight 320;
  1711. vthreads 2;
  1712. vprofile baseline;
  1713. vpreset superfast;
  1714. vparams {
  1715. }
  1716. acodec libfdk_aac;
  1717. abitrate 45;
  1718. asample_rate 44100;
  1719. achannels 2;
  1720. aparams {
  1721. }
  1722. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1723. }
  1724. }
  1725. }
  1726. # the drawtext filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#drawtext-1
  1727. # remark: we remove the libfreetype which always cause build failed, you must add it manual if needed.
  1728. #######################################################################################################
  1729. # the crop filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#crop
  1730. vhost crop.transcode.srs.com {
  1731. transcode {
  1732. enabled on;
  1733. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1734. engine crop {
  1735. enabled on;
  1736. vfilter {
  1737. vf 'crop=in_w-20:in_h-160:10:80';
  1738. }
  1739. vcodec libx264;
  1740. vbitrate 300;
  1741. vfps 20;
  1742. vwidth 768;
  1743. vheight 320;
  1744. vthreads 2;
  1745. vprofile baseline;
  1746. vpreset superfast;
  1747. vparams {
  1748. }
  1749. acodec libfdk_aac;
  1750. abitrate 45;
  1751. asample_rate 44100;
  1752. achannels 2;
  1753. aparams {
  1754. }
  1755. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1756. }
  1757. }
  1758. }
  1759. # the logo filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#overlay
  1760. vhost logo.transcode.srs.com {
  1761. transcode {
  1762. enabled on;
  1763. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1764. engine logo {
  1765. enabled on;
  1766. vfilter {
  1767. i ./doc/ffmpeg-logo.png;
  1768. filter_complex 'overlay=10:10';
  1769. }
  1770. vcodec libx264;
  1771. vbitrate 300;
  1772. vfps 20;
  1773. vwidth 768;
  1774. vheight 320;
  1775. vthreads 2;
  1776. vprofile baseline;
  1777. vpreset superfast;
  1778. vparams {
  1779. }
  1780. acodec libfdk_aac;
  1781. abitrate 45;
  1782. asample_rate 44100;
  1783. achannels 2;
  1784. aparams {
  1785. }
  1786. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1787. }
  1788. }
  1789. }
  1790. # audio transcode only.
  1791. # for example, FMLE publish audio codec in mp3, and do not support HLS output,
  1792. # we can transcode the audio to aac and copy video to the new stream with HLS.
  1793. vhost audio.transcode.srs.com {
  1794. transcode {
  1795. enabled on;
  1796. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1797. engine acodec {
  1798. enabled on;
  1799. vcodec copy;
  1800. acodec libfdk_aac;
  1801. abitrate 45;
  1802. asample_rate 44100;
  1803. achannels 2;
  1804. aparams {
  1805. }
  1806. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1807. }
  1808. }
  1809. }
  1810. # disable video, transcode/copy audio.
  1811. # for example, publish pure audio stream.
  1812. vhost vn.transcode.srs.com {
  1813. transcode {
  1814. enabled on;
  1815. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1816. engine vn {
  1817. enabled on;
  1818. vcodec vn;
  1819. acodec libfdk_aac;
  1820. abitrate 45;
  1821. asample_rate 44100;
  1822. achannels 2;
  1823. aparams {
  1824. }
  1825. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1826. }
  1827. }
  1828. }
  1829. # ffmpeg-copy(forward implements by ffmpeg).
  1830. # copy the video and audio to a new stream.
  1831. vhost copy.transcode.srs.com {
  1832. transcode {
  1833. enabled on;
  1834. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1835. engine copy {
  1836. enabled on;
  1837. vcodec copy;
  1838. acodec copy;
  1839. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1840. }
  1841. }
  1842. }
  1843. # transcode all app and stream of vhost
  1844. # the comments, read example.transcode.srs.com
  1845. vhost all.transcode.srs.com {
  1846. transcode {
  1847. enabled on;
  1848. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1849. engine ffsuper {
  1850. enabled on;
  1851. iformat flv;
  1852. vfilter {
  1853. i ./doc/ffmpeg-logo.png;
  1854. filter_complex 'overlay=10:10';
  1855. }
  1856. vcodec libx264;
  1857. vbitrate 1500;
  1858. vfps 25;
  1859. vwidth 768;
  1860. vheight 320;
  1861. vthreads 12;
  1862. vprofile main;
  1863. vpreset medium;
  1864. vparams {
  1865. t 100;
  1866. coder 1;
  1867. b_strategy 2;
  1868. bf 3;
  1869. refs 10;
  1870. }
  1871. acodec libfdk_aac;
  1872. abitrate 70;
  1873. asample_rate 44100;
  1874. achannels 2;
  1875. aparams {
  1876. profile:a aac_low;
  1877. }
  1878. oformat flv;
  1879. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1880. }
  1881. engine ffhd {
  1882. enabled on;
  1883. vcodec libx264;
  1884. vbitrate 1200;
  1885. vfps 25;
  1886. vwidth 1382;
  1887. vheight 576;
  1888. vthreads 6;
  1889. vprofile main;
  1890. vpreset medium;
  1891. vparams {
  1892. }
  1893. acodec libfdk_aac;
  1894. abitrate 70;
  1895. asample_rate 44100;
  1896. achannels 2;
  1897. aparams {
  1898. }
  1899. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1900. }
  1901. engine ffsd {
  1902. enabled on;
  1903. vcodec libx264;
  1904. vbitrate 800;
  1905. vfps 25;
  1906. vwidth 1152;
  1907. vheight 480;
  1908. vthreads 4;
  1909. vprofile main;
  1910. vpreset fast;
  1911. vparams {
  1912. }
  1913. acodec libfdk_aac;
  1914. abitrate 60;
  1915. asample_rate 44100;
  1916. achannels 2;
  1917. aparams {
  1918. }
  1919. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1920. }
  1921. engine fffast {
  1922. enabled on;
  1923. vcodec libx264;
  1924. vbitrate 300;
  1925. vfps 20;
  1926. vwidth 768;
  1927. vheight 320;
  1928. vthreads 2;
  1929. vprofile baseline;
  1930. vpreset superfast;
  1931. vparams {
  1932. }
  1933. acodec libfdk_aac;
  1934. abitrate 45;
  1935. asample_rate 44100;
  1936. achannels 2;
  1937. aparams {
  1938. }
  1939. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1940. }
  1941. engine vcopy {
  1942. enabled on;
  1943. vcodec copy;
  1944. acodec libfdk_aac;
  1945. abitrate 45;
  1946. asample_rate 44100;
  1947. achannels 2;
  1948. aparams {
  1949. }
  1950. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1951. }
  1952. engine acopy {
  1953. enabled on;
  1954. vcodec libx264;
  1955. vbitrate 300;
  1956. vfps 20;
  1957. vwidth 768;
  1958. vheight 320;
  1959. vthreads 2;
  1960. vprofile baseline;
  1961. vpreset superfast;
  1962. vparams {
  1963. }
  1964. acodec copy;
  1965. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1966. }
  1967. engine copy {
  1968. enabled on;
  1969. vcodec copy;
  1970. acodec copy;
  1971. output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  1972. }
  1973. }
  1974. }
  1975. # transcode all app and stream of app
  1976. vhost app.transcode.srs.com {
  1977. # the streaming transcode configs.
  1978. # if app specified, transcode all streams of app.
  1979. transcode live {
  1980. enabled on;
  1981. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1982. engine {
  1983. enabled off;
  1984. }
  1985. }
  1986. }
  1987. # transcode specified stream.
  1988. vhost stream.transcode.srs.com {
  1989. # the streaming transcode configs.
  1990. # if stream specified, transcode the matched stream.
  1991. transcode live/livestream {
  1992. enabled on;
  1993. ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  1994. engine {
  1995. enabled off;
  1996. }
  1997. }
  1998. }
  1999. #############################################################################################
  2000. # The origin cluster section
  2001. #############################################################################################
  2002. http_api {
  2003. enabled on;
  2004. listen 9090;
  2005. }
  2006. vhost a.origin.cluster.srs.com {
  2007. cluster {
  2008. mode local;
  2009. origin_cluster on;
  2010. coworkers 127.0.0.1:9091;
  2011. }
  2012. }
  2013. http_api {
  2014. enabled on;
  2015. listen 9091;
  2016. }
  2017. vhost b.origin.cluster.srs.com {
  2018. cluster {
  2019. mode local;
  2020. origin_cluster on;
  2021. coworkers 127.0.0.1:9090;
  2022. }
  2023. }
  2024. #############################################################################################
  2025. # To prevent user to use full.conf
  2026. #############################################################################################
  2027. # To identify the full.conf
  2028. # @remark Should never use it directly, it's only a collections of all config items.
  2029. # Default: off
  2030. is_full on;