#!!!!此配置文件为范例配置文件,意在告诉读者,各个配置项的具体含义和作用, #!!!!该配置文件在执行cmake时,会拷贝至release/${操作系统类型}/${编译类型}(例如release/linux/Debug) 文件夹。 #!!!!该文件夹(release/${操作系统类型}/${编译类型})同时也是可执行程序生成目标路径,在执行MediaServer进程时,它会默认加载同目录下的config.ini文件作为配置文件, #!!!!你如果修改此范例配置文件(conf/config.ini),并不会被MediaServer进程加载,因为MediaServer进程默认加载的是release/${操作系统类型}/${编译类型}/config.ini。 #!!!!当然,你每次执行cmake,该文件确实会被拷贝至release/${操作系统类型}/${编译类型}/config.ini, #!!!!但是一般建议你直接修改release/${操作系统类型}/${编译类型}/config.ini文件,修改此文件一般不起作用,除非你运行MediaServer时使用-c参数指定到此文件。 #!!!! This is a sample configuration file intended to explain the specific meanings and functions of each item. #!!!! During the `cmake` execution, this file is copied to the `release/${OS type}/${build type}` directory. #!!!! This directory is also the target path where the MediaServer executable runs and looks for `config.ini` by default. #!!!! Modifying this sample file (`conf/config.ini`) will not affect the MediaServer process while it runs. #!!!! Although executing `cmake` overwrites the target config file, it is highly recommended to modify `release/${OS type}/${build type}/config.ini` directly. #!!!! Changes made here will only take effect if you explicitly load this file using the `-c` parameter when starting the MediaServer. [api] # 是否调试http api,启用调试后,会打印每次http请求的内容和回复 # Enable HTTP API debugging. When enabled, it logs the content and responses of each HTTP request. apiDebug=1 # 一些比较敏感的http api在访问时需要提供secret,否则无权限调用 # 如果是通过127.0.0.1访问,那么可以不提供secret # For some sensitive HTTP APIs, a secret must be provided when accessing them, otherwise the call is unauthorized. # If accessed via 127.0.0.1, the secret does not need to be provided. secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc # 截图保存路径根目录,截图通过http api(/index/api/getSnap)生成和获取 # Root directory for saving snapshots generated via the `/index/api/getSnap` API. snapRoot=./www/snap/ # 默认截图图片,在启动FFmpeg截图后但是截图还未生成时,可以返回默认的预设图片 # Default placeholder image returned while FFmpeg is generating the actual snapshot. defaultSnap=./www/logo.png # downloadFile http接口可访问文件的根目录,支持多个目录,不同目录通过分号(;)分隔 # Root directories accessible via the `downloadFile` API. Separate multiple directories with semicolons (;). downloadRoot=./www # 是否采用传统secret硬编码鉴权模式,默认开启,开启后每次http接口请求都需要传递secret # 关闭传统鉴权模式后,需要先调用/index/api/login接口登录,成功后将设置cookie,在cookie有效期内访问所有接口都将放行。 # Whether to enable the legacy secret-based authentication mode (enabled by default). When enabled, every API request requires the secret. # When disabled, users must first call `/index/api/login`. Upon success, a cookie auth token is set, allowing unrestricted access to all APIs while the cookie remains valid. legacyAuth=1 [ffmpeg] # FFmpeg可执行程序路径,支持相对路径/绝对路径 # Path to the FFmpeg executable. Both relative and absolute paths are supported. bin=/usr/bin/ffmpeg # FFmpeg拉流再推流的命令模板,通过该模板可以设置诸如编码等的一些参数 # FFmpeg command template for pulling and re-publishing streams (used to define re-encoding parameters). cmd=%s -re -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s # FFmpeg生成截图的命令,可以通过修改该配置改变截图分辨率或质量 # FFmpeg command template for generating snapshots. Modify this to change resolution or quality. snap=%s -i %s -y -f mjpeg -frames:v 1 -an %s # FFmpeg日志的路径,如果置空则不生成FFmpeg日志 # 可以为相对(相对于本可执行程序目录)或绝对路径 # Path to the FFmpeg log file (relative or absolute). Leave empty to disable logging. log=./ffmpeg/ffmpeg.log # 自动重启的时间(秒), 默认为0, 也就是不自动重启. 主要是为了避免长时间ffmpeg拉流导致的不同步现象 # Automatic restart interval in seconds (0 to disable). Helps prevent A/V desync caused by prolonged FFmpeg stream pulling. restart_sec=0 # 转协议相关开关;如果addStreamProxy api和on_publish hook回复未指定转协议参数,则采用这些配置项 # Protocol conversion default switches. Used if protocol conversions aren't specified via the `addStreamProxy` API or the `on_publish` webhook. [protocol] # 转协议时,是否开启帧级时间戳覆盖 # 0:采用源视频流绝对时间戳,不做任何改变 # 1:采用zlmediakit接收数据时的系统时间戳(有平滑处理) # 2:采用源视频流时间戳相对时间戳(增长量),有做时间戳跳跃和回退矫正 # Frame-level timestamp override mode during protocol conversion: # - 0: Use absolute timestamp from the source (no modification). # - 1: Use ZLMediaKit system timestamp upon data reception (with smoothing). # - 2: Use relative timestamp increments, with correction for jumps and backwards drifts. modify_stamp=2 # 转协议是否开启音频 # Whether to enable audio output during protocol conversion. enable_audio=1 # 添加AAC静音音频,在关闭音频时,此开关无效 # Whether to inject AAC silent audio (ignored if `enable_audio` is 0). add_mute_audio=1 # 无人观看时,是否直接关闭(而不是通过on_none_reader hook返回close) # 此配置置1时,此流如果无人观看,将不触发on_none_reader hook回调, # 而是将直接关闭流 # Whether to immediately close an unwatched stream directly instead of relying on the `on_none_reader` hook returning 'close'. # If enabled (1), an unwatched stream is closed outright without triggering the hook callback. auto_close=0 # 推流断开后可以在超时时间内重新连接上继续推流,这样播放器会接着播放。 # 置0关闭此特性(推流断开会导致立即断开播放器) # 此参数不应大于播放器超时时间;单位毫秒 # Defines a grace period (in milliseconds) allowing a disconnected publisher to reconnect and resume streaming. # During this period, active player connections are maintained rather than dropped. # Set to 0 to disable this feature, which means dropping a publisher will immediately disconnect all its current players. # This value must not exceed the player's configured timeout. continue_push_ms=15000 # 平滑发送定时器间隔,单位毫秒,置0则关闭;开启后影响cpu性能同时增加内存 # 该配置开启后可以解决一些流发送不平滑导致zlmediakit转发也不平滑的问题 # Smooth sending timer interval in milliseconds (0 to disable). Enabling this increases CPU and memory usage. # This solves the issue where unsteady upstream publishing causes ZLMediaKit's forwarding to also be unsteady. paced_sender_ms=0 # 是否开启转换为hls(mpegts) # Whether to enable conversion to HLS (mpegts). enable_hls=1 # 是否开启转换为hls(fmp4) # Whether to enable conversion to HLS (fmp4). enable_hls_fmp4=0 # 是否开启MP4录制 # Whether to enable MP4 recording. enable_mp4=0 # 是否开启转换为rtsp/webrtc # Whether to enable conversion to RTSP/WebRTC. enable_rtsp=1 # 是否开启转换为rtmp/flv # Whether to enable conversion to RTMP/FLV. enable_rtmp=1 # 是否开启转换为http-ts/ws-ts # Whether to enable conversion to HTTP-TS/WS-TS. enable_ts=1 # 是否开启转换为http-fmp4/ws-fmp4 # Whether to enable conversion to HTTP-FMP4/WS-FMP4. enable_fmp4=1 # 是否将mp4录制当做观看者 # Whether to treat MP4 recording tasks as active stream viewers. mp4_as_player=0 # mp4切片大小,单位秒 # Maximum duration of MP4 recording segments in seconds. mp4_max_second=3600 # mp4录制保存路径 # Directory path for saving MP4 recordings. mp4_save_path=./www # hls录制保存路径 # Directory path for saving HLS recordings. hls_save_path=./www ###### 以下是按需转协议的开关,在测试ZLMediaKit的接收推流性能时,请把下面开关置1 ###### 对于不使用的协议,可以将开关设置为 1 以节省资源(虽然首个播放者体验稍差,但依然可以播放)。 ###### 对于希望获得最佳用户体验的协议,请设置为 0(首屏秒开,且无花屏现象)。 ###### On-demand protocol conversion switches. Set these to 1 during stream reception performance testing to save resources. ###### For unused protocols, setting them to 1 saves resources (with a slight startup delay for the first viewer). ###### For the best user experience (instant playback and no visual artifacts (glitches)), set them to 0. # hls协议是否按需生成,如果hls.segNum配置为0(意味着hls录制),那么hls将一直生成(不管此开关) # Whether to generate HLS streams on demand. If `hls.segNum` is configured to 0 (implies HLS recording), HLS streams generate continuously regardless of this switch. hls_demand=0 # rtsp[s]协议是否按需生成 # Whether to generate RTSP[S] streams on demand. rtsp_demand=0 # rtmp[s]、http[s]-flv、ws[s]-flv协议是否按需生成 # Whether to generate RTMP[S], HTTP[S]-FLV, and WS[S]-FLV streams on demand. rtmp_demand=0 # http[s]-ts协议是否按需生成 # Whether to generate HTTP[S]-TS streams on demand. ts_demand=0 # http[s]-fmp4、ws[s]-fmp4协议是否按需生成 # Whether to generate HTTP[S]-FMP4 and WS[S]-FMP4 streams on demand. fmp4_demand=0 [general] # 是否启用虚拟主机 # Whether to enable virtual hosting. enableVhost=0 # 播放器或推流器在断开后会触发hook.on_flow_report事件(使用多少流量事件), # flowThreshold参数控制触发hook.on_flow_report事件阈值,使用流量超过该阈值后才触发,单位KB # When a player or publisher disconnects, it triggers the `hook.on_flow_report` event (an event reporting how much traffic was used). # The `flowThreshold` parameter controls the threshold for triggering the `hook.on_flow_report` event; it is only triggered when the used traffic exceeds this threshold, in KB. flowThreshold=1024 # 播放最多等待时间,单位毫秒 # 播放在播放某个流时,如果该流不存在, # ZLMediaKit会最多让播放器等待maxStreamWaitMS毫秒 # 如果在这个时间内,该流注册成功,那么会立即返回播放器播放成功 # 否则返回播放器未找到该流,该机制的目的是可以先播放再推流 # Maximum playback wait time in milliseconds. # When a requested stream does not exist, ZLMediaKit delays the player for up to `maxStreamWaitMS`. # If the stream is successfully registered within this period, it immediately returns playback success. # Otherwise, it returns 'stream not found'. This mechanism enables 'play before push' workflows. maxStreamWaitMS=15000 # 某个流无人观看时,触发hook.on_stream_none_reader事件的最大等待时间,单位毫秒 # 在配合hook.on_stream_none_reader事件时,可以做到无人观看自动停止拉流或停止接收推流 # The continuous unwatched duration (in ms) required to trigger the `hook.on_stream_none_reader` event. # Combined with the `hook.on_stream_none_reader` event, this enables automatically stopping origin pulls or disconnecting publishers when a stream remains unwatched. streamNoneReaderDelayMS=20000 # 拉流代理时如果断流再重连成功是否删除前一次的媒体流数据,如果删除将重新开始, # 如果不删除将会接着上一次的数据继续写(录制hls/mp4时会继续在前一个文件后面写) # Whether to flush cached media data upon successfully reconnecting after an origin pull proxy disconnection. If flushed, the stream restarts cleanly. # If not flushed, the new data will append directly to the previous data (when recording HLS/MP4, it continues appending to the previous file). resetWhenRePlay=1 # 合并写缓存大小(单位毫秒),合并写指服务器缓存一定的数据后才会一次性写入socket,这样能提高性能,但是会提高延时 # 开启后会同时关闭TCP_NODELAY并开启MSG_MORE # Write coalescing cache duration in ms. The server caches data up to this interval before writing to the socket in bulk, improving performance at the cost of slight latency. # Enabling this disables `TCP_NODELAY` and enables `MSG_MORE`. mergeWriteMS=0 # 服务器唯一id,用于触发hook时区别是哪台服务器 # Unique server ID, used to distinguish which server it is when triggering a hook. mediaServerId=your_server_id # 最多等待未初始化的Track时间,单位毫秒,超时之后会忽略未初始化的Track # Maximum wait time (in ms) for uninitialized Tracks. After the timeout, any uninitialized Tracks will be ignored. wait_track_ready_ms=10000 # 最多等待音频Track收到数据时间,单位毫秒,超时且完全没收到音频数据,忽略音频Track # 加快某些带封装的流metadata说明有音频,但是实际上没有的流ready时间(比如很多厂商的GB28181 PS) # Maximum wait time (in ms) before an audio track receives its first data packet. If it times out and absolutely no audio data has been received, the audio Track is ignored. # This speeds up the ready time for certain packaged streams whose metadata falsely claims to include audio, but actually do not (e.g., GB28181 PS). wait_audio_track_data_ms=1000 # 如果流只有单Track,最多等待若干毫秒,超时后未收到其他Track的数据,则认为是单Track # 如果协议元数据有声明特定track数,那么无此等待时间 # Maximum wait time (in ms) for additional tracks if a stream currently has only one. # If no data from other tracks is received within this timeout, it is considered a single-track stream. # This delay is bypassed if protocol metadata explicitly declares the track count. wait_add_track_ms=3000 # 如果track未就绪,我们先缓存帧数据,但是有最大个数限制,防止内存溢出 # If a track is not ready, we first cache the frame data, but there is a maximum count limit to prevent memory overflow. unready_frame_cache=100 # 是否启用观看人数变化事件广播,置1则启用,置0则关闭 # Whether to enable broadcasting of viewership change events. Set to 1 to enable, set to 0 to disable. broadcast_player_count_changed=0 # 绑定的本地网卡ip # Bound local network interface IP address. listen_ip=:: [hls] # hls写文件的buf大小,调整参数可以提高文件io性能 # Buffer size used when writing HLS segment files. Increasing this value can improve disk I/O performance. fileBufSize=65536 # hls最大切片时间 # Target maximum duration of a single HLS segment. segDur=2 # m3u8索引中,hls保留切片个数(实际保留切片个数+segRetain个) # 如果设置为0,则不删除切片且m3u8文件全量记录切片列表 # Number of HLS segments retained within the m3u8 playlist index (actual chunks kept = this value + `segRetain`). # Set to 0 to retain all segments and record the full segment list in the m3u8 file. segNum=3 # HLS切片延迟个数,大于0将生成hls_delay.m3u8文件,0则不生成 # The segment delay count for HLS. If greater than 0, an `hls_delay.m3u8` variant playlist is generated; if 0, it will not be generated. segDelay=0 # HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数 # Number of outdated HLS segments to keep on disk after removal from the m3u8 playlist. segRetain=5 # 是否广播 hls切片(ts/fmp4)完成通知(on_record_ts) # Whether to broadcast HLS segment (TS/FMP4) completion notifications via `on_record_ts`. broadcastRecordTs=0 # 直播hls文件删除延时,单位秒,issue: #913 # Delay in seconds before deleting expired live HLS segments. Refer to issue: #913. deleteDelaySec=10 # 此选项开启后m3u8文件还是表现为直播,但是切片文件会被全部保留为点播用 # segDur设置为0或segKeep设置为1的情况下,每个切片文件夹下会生成一个vod.m3u8文件用于点播该时间段的录像 # When enabled, the `m3u8` playlist functions as live media, but segment chunks are permanently preserved in storage for Video On Demand (VOD). # If either `segKeep` is 1 or `segDur` is 0, a `vod.m3u8` playlist is also generated in each segment's folder for VOD playback of that specific recorded period. segKeep=0 # 如果设置为1,则第一个切片长度强制设置为1个GOP。当GOP小于segDur,可以提高首屏速度 # If set to 1, the length of the first segment is forcibly set to exactly 1 GOP. # When the GOP is smaller than `segDur`, this can improve the initial startup (instant playback) speed. fastRegister=0 [hook] # 是否启用hook事件,启用后,推拉流都将进行鉴权 # Whether to enable webhook events. When enabled, pushing and pulling streams requires authentication. enable=0 # 播放器或推流器使用流量事件,置空则关闭 # Player or publisher flow traffic event. Leave empty to disable. on_flow_report= # 访问http文件鉴权事件,置空则关闭鉴权 # HTTP file access authentication event. Leave empty to disable. on_http_access= # 播放鉴权事件,置空则关闭鉴权 # Playback authentication event. Leave empty to disable. on_play= # 推流鉴权事件,置空则关闭鉴权 # Publishing authentication event. Leave empty to disable. on_publish= # 录制mp4切片完成事件 # MP4 segment recording completion event. on_record_mp4= # 录制 hls ts(或fmp4) 切片完成事件 # HLS TS (or fmp4) segment recording completion event. on_record_ts= # rtsp播放鉴权事件,此事件中比对rtsp的用户名密码 # RTSP playback authentication event (used to verify RTSP username and password). on_rtsp_auth= # rtsp播放是否开启专属鉴权事件,置空则关闭rtsp鉴权。rtsp播放鉴权还支持url方式鉴权 # 建议开发者统一采用url参数方式鉴权,rtsp用户名密码鉴权一般在设备上用的比较多 # 开启rtsp专属鉴权后,将不再触发on_play鉴权事件 # Whether to enable a dedicated RTSP realm authentication event (leave empty to disable; URL-based auth remains supported). # We recommend standardizing on URL parameters; RTSP username/password auth is mostly for hardware devices. # Enabling this bypasses the standard `on_play` webhook. on_rtsp_realm= # 远程telnet调试鉴权事件 # Remote telnet debugging authentication event. on_shell_login= # 直播流注册或注销事件 # Live stream registration or unregistration event. on_stream_changed= # 过滤on_stream_changed hook的协议类型,可以选择只监听某些感兴趣的协议;置空则不过滤协议 # Filter the protocol types for the `on_stream_changed` hook to listen only to specific protocols. Leave empty to disable filtering. stream_changed_schemas=rtsp/rtmp/fmp4/ts/hls/hls.fmp4 # 无人观看流事件,通过该事件,可以选择是否关闭无人观看的流。配合general.streamNoneReaderDelayMS选项一起使用 # Triggered when a stream has no viewers. Combined with `general.streamNoneReaderDelayMS`, this enables closing unwatched streams. on_stream_none_reader= # 播放时,未找到流事件,通过配合hook.on_stream_none_reader事件可以完成按需拉流 # Triggered when a requested stream is not found. Combined with `hook.on_stream_none_reader`, this enables on-demand origin pulling. on_stream_not_found= # 服务器启动报告,可以用于服务器的崩溃重启事件监听 # Server startup report. Useful for monitoring server crashes and restarts. on_server_started= # 服务器退出报告,当服务器正常退出时触发 # Server exit report, triggered when the server shuts down normally. on_server_exited= # server保活上报 # Server keep-alive reporting event. on_server_keepalive= # 发送rtp(startSendRtp)被动关闭时回调 # Callback triggered when RTP sending (`startSendRtp`) is passively closed. on_send_rtp_stopped= # rtp server 超时未收到数据 # RTP server timeout event due to not receiving data. on_rtp_server_timeout= # hook api最大等待回复时间,单位秒 # Maximum wait time in seconds for Webhook API responses. timeoutSec=10 # keepalive hook触发间隔,单位秒,float类型 # Interval in seconds (float) for triggering the keep-alive webhook. alive_interval=10.0 # hook通知失败重试次数,正整数。为0不重试,1时重试一次,以此类推 # Webhook notification failure retry attempts. Must be a non-negative integer (0 to disable). retry=1 # hook通知失败重试延时,单位秒,float型 # Delay in seconds (float) between webhook retry attempts. retry_delay=3.0 [cluster] # 设置源站拉流url模板, 格式跟printf类似,第一个%s指定app,第二个%s指定stream_id, # 开启集群模式后,on_stream_not_found和on_stream_none_reader hook将无效. # 溯源模式支持以下类型: # rtmp方式: rtmp://127.0.0.1:1935/%s/%s # rtsp方式: rtsp://127.0.0.1:554/%s/%s # hls方式: http://127.0.0.1:80/%s/%s/hls.m3u8 # http-ts方式: http://127.0.0.1:80/%s/%s.live.ts # 支持多个源站,不同源站通过分号(;)分隔 # Origin pull URL template (printf style: first `%s` is app, second `%s` is stream_id). # When cluster mode is enabled, `on_stream_not_found` and `on_stream_none_reader` webhooks are disabled. # Supported origin pull protocols: # RTMP mode: rtmp://127.0.0.1:1935/%s/%s # RTSP mode: rtsp://127.0.0.1:554/%s/%s # HLS mode: http://127.0.0.1:80/%s/%s/hls.m3u8 # HTTP-TS mode: http://127.0.0.1:80/%s/%s.live.ts # Separate multiple origin servers with semicolons (;). origin_url= # 溯源总超时时长,单位秒,float型;假如源站有3个,那么单次溯源超时时间为timeout_sec除以3 # 单次溯源超时时间不要超过general.maxStreamWaitMS配置 # Total origin pull timeout in seconds (float). # The single origin attempt timeout (total timeout divided by the number of origins) should not exceed `general.maxStreamWaitMS`. timeout_sec=15 # 溯源失败尝试次数,-1时永久尝试 # Failure retry attempts for origin pulling (-1 for infinite retries). retry_count=3 [http] # http服务器字符编码集 # HTTP server character encoding. charSet=utf-8 # http链接超时时间 # HTTP connection timeout in seconds. keepAliveSecond=30 # http请求体最大字节数,如果post的body太大,则不适合缓存body在内存 # Maximum number of bytes for the HTTP request body. If the POST body is too large, it is not suitable to cache the body in memory. maxReqSize=40960 # 404网页内容,用户可以自定义404网页 # Custom 404 page content. Users can customize the 404 response page here. #notFound=