1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Config: Support overwrote by environment variables. (#3200)

Co-authored-by: pengfei.ma <pengfei.ma@ctechm.com>
This commit is contained in:
mapengfei53 2022-10-09 21:11:33 +08:00 committed by GitHub
parent f1be2ebd3b
commit dd563d45ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 5 deletions

View file

@ -342,9 +342,9 @@ srt_server {
vhost srt.vhost.srs.com {
srt {
# Overwrite by env SRS_SRT_ENABLED for all vhosts.
# Overwrite by env SRS_VHOST_SRT_ENABLED for all vhosts.
enabled on;
# Overwrite by env SRS_SRT_TO_RTMP for all vhosts.
# Overwrite by env SRS_VHOST_SRT_TO_RTMP for all vhosts.
srt_to_rtmp on;
}
}
@ -1643,6 +1643,7 @@ vhost hls.srs.com {
hls {
# whether the hls is enabled.
# if off, do not write hls(ts and m3u8) when publish.
# Overwrite by env SRS_VHOST_HLS_ENABLED for all vhosts.
# default: off
enabled on;
@ -1655,6 +1656,7 @@ vhost hls.srs.com {
# as a "fake" connection, do HTTP callback when start playing the HLS streaming. You're able to do querying and
# authentication.
# Note that it will make NGINX edge cache always missed, so never enable HLS streaming if use NGINX edges.
# Overwrite by env SRS_VHOST_HLS_HLS_CTX for all vhosts.
# Default: on
hls_ctx on;
# For HLS pseudo streaming, whether enable the session for each TS segment.
@ -1662,6 +1664,7 @@ vhost hls.srs.com {
# note that it also consumes resource, because each ts file should be served by SRS, all NGINX cache will be
# missed because we add session id to each ts file.
# Note that it will make NGINX edge cache always missed, so never enable HLS streaming if use NGINX edges.
# Overwrite by env SRS_VHOST_HLS_HLS_TS_CTX for all vhosts.
# Default: on
hls_ts_ctx on;
@ -1672,15 +1675,18 @@ vhost hls.srs.com {
# EXT-X-TARGETDURATION = hls_td_ratio * hls_fragment // init
# EXT-X-TARGETDURATION = max(ts_duration, EXT-X-TARGETDURATION) // for each ts
# @see https://github.com/ossrs/srs/issues/304#issuecomment-74000081
# Overwrite by env SRS_VHOST_HLS_HLS_TD_RATIO for all vhosts.
# default: 1.5
hls_td_ratio 1.5;
# the audio overflow ratio.
# for pure audio, the duration to reap the segment.
# for example, the hls_fragment is 10s, hls_aof_ratio is 2.0,
# the segment will reap to 20s for pure audio.
# Overwrite by env SRS_VHOST_HLS_HLS_AOF_RATIO for all vhosts.
# default: 2.0
hls_aof_ratio 2.0;
# the hls window in seconds, the number of ts in m3u8.
# Overwrite by env SRS_VHOST_HLS_HLS_WINDOW for all vhosts.
# default: 60
hls_window 60;
# the error strategy. can be:
@ -1688,6 +1694,7 @@ vhost hls.srs.com {
# disconnect, require encoder republish.
# continue, ignore failed try to continue output hls.
# @see https://github.com/ossrs/srs/issues/264
# Overwrite by env SRS_VHOST_HLS_HLS_ON_ERROR for all vhosts.
# default: continue
hls_on_error continue;
# the hls output path.
@ -1696,6 +1703,7 @@ vhost hls.srs.com {
# the ts file is configured by hls_path/hls_ts_file, the default is:
# ./objs/nginx/html/[app]/[stream]-[seq].ts
# @remark the hls_path is compatible with srs v1 config.
# Overwrite by env SRS_VHOST_HLS_HLS_PATH for all vhosts.
# default: ./objs/nginx/html
hls_path ./objs/nginx/html;
# the hls m3u8 file name.
@ -1703,6 +1711,7 @@ vhost hls.srs.com {
# [vhost], the vhost of stream.
# [app], the app of stream.
# [stream], the stream name of stream.
# Overwrite by env SRS_VHOST_HLS_HLS_M3U8_FILE for all vhosts.
# default: [app]/[stream].m3u8
hls_m3u8_file [app]/[stream].m3u8;
# the hls ts file name.
@ -1722,12 +1731,14 @@ vhost hls.srs.com {
# [duration], replace this const to current ts duration.
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr#custom-path
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/delivery-hls#hls-config
# Overwrite by env SRS_VHOST_HLS_HLS_TS_FILE for all vhosts.
# default: [app]/[stream]-[seq].ts
hls_ts_file [app]/[stream]-[seq].ts;
# whether use floor for the hls_ts_file path generation.
# if on, use floor(timestamp/hls_fragment) as the variable [timestamp],
# and use enhanced algorithm to calc deviation for segment.
# @remark when floor on, recommend the hls_segment>=2*gop.
# Overwrite by env SRS_VHOST_HLS_HLS_TS_FLOOR for all vhosts.
# default: off
hls_ts_floor off;
# the hls entry prefix, which is base url of ts url.
@ -1737,6 +1748,7 @@ vhost hls.srs.com {
# http://your-server/live/livestream-0.ts
# http://your-server/live/livestream-1.ts
# ...
# Overwrite by env SRS_VHOST_HLS_HLS_ENTRY_PREFIX for all vhosts.
# optional, default to empty string.
hls_entry_prefix http://your-server;
# the default audio codec of hls.
@ -1744,6 +1756,7 @@ vhost hls.srs.com {
# so user can set the default codec for mp3.
# the available audio codec:
# aac, mp3, an
# Overwrite by env SRS_VHOST_HLS_HLS_ACODEC for all vhosts.
# default: aac
hls_acodec aac;
# the default video codec of hls.
@ -1751,32 +1764,39 @@ vhost hls.srs.com {
# so user can set the default codec for pure audio(without video) to vn.
# the available video codec:
# h264, vn
# Overwrite by env SRS_VHOST_HLS_HLS_VCODEC for all vhosts.
# default: h264
hls_vcodec h264;
# whether cleanup the old expired ts files.
# Overwrite by env SRS_VHOST_HLS_HLS_CLEANUP for all vhosts.
# default: on
hls_cleanup on;
# If there is no incoming packets, dispose HLS in this timeout in seconds,
# which removes all HLS files including m3u8 and ts files.
# @remark 0 to disable dispose for publisher.
# @remark apply for publisher timeout only, while "etc/init.d/srs stop" always dispose hls.
# Overwrite by env SRS_VHOST_HLS_HLS_DISPOSE for all vhosts.
# default: 0
hls_dispose 0;
# the max size to notify hls,
# to read max bytes from ts of specified cdn network,
# @remark only used when on_hls_notify is config.
# Overwrite by env SRS_VHOST_HLS_HLS_NB_NOTIFY for all vhosts.
# default: 64
hls_nb_notify 64;
# whether wait keyframe to reap segment,
# if off, reap segment when duration exceed the fragment,
# if on, reap segment when duration exceed and got keyframe.
# Overwrite by env SRS_VHOST_HLS_HLS_WAIT_KEYFRAME for all vhosts.
# default: on
hls_wait_keyframe on;
# whether using AES encryption.
# Overwrite by env SRS_VHOST_HLS_HLS_KEYS for all vhosts.
# default: off
hls_keys on;
# the number of clear ts which one key can encrypt.
# Overwrite by env SRS_VHOST_HLS_HLS_FRAGMENTS_PER_KEY for all vhosts.
# default: 5
hls_fragments_per_key 5;
# the hls key file name.
@ -1785,13 +1805,16 @@ vhost hls.srs.com {
# [app], the app of stream.
# [stream], the stream name of stream.
# [seq], the sequence number of key corresponding to the ts.
# Overwrite by env SRS_VHOST_HLS_HLS_KEY_FILE for all vhosts.
hls_key_file [app]/[stream]-[seq].key;
# the key output path.
# the key file is configed by hls_path/hls_key_file, the default is:
# ./objs/nginx/html/[app]/[stream]-[seq].key
# Overwrite by env SRS_VHOST_HLS_HLS_KEY_FILE_PATH for all vhosts.
hls_key_file_path ./objs/nginx/html;
# the key root URL, use this can support https.
# @remark It's optional.
# Overwrite by env SRS_VHOST_HLS_HLS_KEY_URL for all vhosts.
hls_key_url https://localhost:8080;
# Special control controls.
@ -1800,6 +1823,7 @@ vhost hls.srs.com {
# If on, guess the specific DTS by AAC samples, please read https://github.com/ossrs/srs/issues/547#issuecomment-294350544
# If off, directly turn the FLV timestamp to DTS, which might cause corrupt audio stream.
# @remark Recommend to set to off, unless your audio stream sample-rate and timestamp is not correct.
# Overwrite by env SRS_VHOST_HLS_HLS_DTS_DIRECTLY for all vhosts.
# Default: on
hls_dts_directly on;
@ -1833,15 +1857,19 @@ vhost no-hls.srs.com {
vhost hds.srs.com {
hds {
# whether hds enabled
# Overwrite by env SRS_VHOST_HDS_ENABLED for all vhosts.
# default: off
enabled on;
# the hds fragment in seconds.
# Overwrite by env SRS_VHOST_HDS_FRAGMENT for all vhosts.
# default: 10
hds_fragment 10;
# the hds window in seconds, erase the segment when exceed the window.
# Overwrite by env SRS_VHOST_HDS_HDS_WINDOW for all vhosts.
# default: 60
hds_window 60;
# the path to store the hds files.
# Overwrite by env SRS_VHOST_HDS_HDS_PATH for all vhosts.
# default: ./objs/nginx/html
hds_path ./objs/nginx/html;
}
@ -1854,6 +1882,7 @@ vhost dvr.srs.com {
# reap flv/mp4 according by specified dvr_plan.
dvr {
# whether enabled dvr features
# Overwrite by env SRS_VHOST_DVR_ENABLED for all vhosts.
# default: off
enabled on;
# the filter for dvr to apply to.
@ -1868,6 +1897,7 @@ vhost dvr.srs.com {
# session reap flv/mp4 when session end(unpublish).
# segment reap flv/mp4 when flv duration exceed the specified dvr_duration.
# @remark The plan append is removed in SRS3+, for it's no use.
# Overwrite by env SRS_VHOST_DVR_DVR_PLAN for all vhosts.
# default: session
dvr_plan session;
# the dvr output path, *.flv or *.mp4.
@ -1908,11 +1938,13 @@ vhost dvr.srs.com {
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/dvr#custom-path
# @see https://ossrs.io/lts/en-us/docs/v4/doc/dvr#custom-path
# segment,session apply it.
# Overwrite by env SRS_VHOST_DVR_DVR_PATH for all vhosts.
# default: ./objs/nginx/html/[app]/[stream].[timestamp].flv
dvr_path ./objs/nginx/html/[app]/[stream].[timestamp].flv;
# the duration for dvr file, reap if exceed, in seconds.
# segment apply it.
# session,append ignore.
# Overwrite by env SRS_VHOST_DVR_DVR_DURATION for all vhosts.
# default: 30
dvr_duration 30;
# whether wait keyframe to reap segment,
@ -1920,6 +1952,7 @@ vhost dvr.srs.com {
# if on, reap segment when duration exceed and got keyframe.
# segment apply it.
# session,append ignore.
# Overwrite by env SRS_VHOST_DVR_DVR_WAIT_KEYFRAME for all vhosts.
# default: on
dvr_wait_keyframe on;
# about the stream monotonically increasing:
@ -1933,6 +1966,7 @@ vhost dvr.srs.com {
# 2. zero, only ensure stream start at zero, ignore timestamp jitter.
# 3. off, disable the time jitter algorithm, like atc.
# apply for all dvr plan.
# Overwrite by env SRS_VHOST_DVR_TIME_JITTER for all vhosts.
# default: full
time_jitter full;