开发者-导航 猿导航

mediamtx 配置文件英文转中文

发布时间:

全部配置文件说明 #

###############################################
# 常用参数

# 设置日志基本;取值为“error”、“warn”、“info”、“debug”。
logLevel: info
# 日志输出方式 stdout file syslog
logDestinations: [ stdout ]
# 日志输出文件名
logFile: mediamtx.log

# 读操作超时。
readTimeout: 10s
# 写操作超时。
writeTimeout: 10s
# 读缓冲区的数目。
# 较高的值允许更宽的吞吐量,较低的值允许节省RAM.
readBufferCount: 512
# UDP报文出方向最大负载大小。
# 这可以减少,以避免在具有低UDP MTU的网络上出现碎片。
udpMaxPayloadSize: 1472

# 执行外部认证的HTTP URL。
# 每当用户想要进行身份验证时,服务器就调用这个URL
# POST方法和一个包含:
# {
#   "ip": "ip",
#   "user": "user",
#   "password": "password",
#   "path": "path",
#   "protocol": "rtsp|rtmp|hls|webrtc",
#   "id": "id",
#   "action": "read|publish",
#   "query": "query"
# }
# 如果响应码为20x,则接受身份验证,否则
# 它被丢弃。
externalAuthenticationURL:

# 启用HTTP API。
api: no
# API 侦听器的地址。
apiAddress: 127.0.0.1:9997

# 启用普罗米修斯兼容的度量。
metrics: no
# 度量侦听器的地址。
metricsAddress: 127.0.0.1:9998

# 启用与 pprof 兼容的端点来监视性能。
pprof: no
# pprof 侦听器的地址。
pprofAddress: 127.0.0.1:9999

# 命令,在客户端连接到服务器时运行。
# 预先考虑。/在当前文件夹中运行可执行文件(例如:./ffmpeg )
# 当客户端与服务器断开连接时,使用SIGINT终止此连接。
# 可用的环境变量如下:
# * RTSP_PORT: RTSP server port
runOnConnect:
# 如果命令退出,则重新启动命令。
runOnConnectRestart: no

###############################################
# RTSP parameters

# 关闭 RTSP 协议支持。
rtspDisable: no
# 已启用的 RTSP 传输协议列表。
# UDP 是性能最好的,但是当有 NAT/防火墙的时候就不工作了
# 服务器和客户端,不支持加密。
# udp 组播允许在客户端都在同一局域网时节省带宽。
# TCP 是最通用的,并且支持加密。
# 握手总是通过 TCP 进行的。
protocols: [ udp, multicast, tcp ]
# 对握手和 TCP 流进行 TLS 加密(RTSPS)。
# 取值为 "no", "strict", "optional".
encryption: "no"
# TCP/RTSP 侦听器地址。只有当加密为 ;no ;或 optional ;时才需要这样做。
rtspAddress: :8554
# Address of the TCP/TLS/RTSPS listener. This is needed only when encryption is "strict" or "optional".
# TCP/TLS/RTSPS侦听器地址。只有当加密为 “encryption” 或 “strict” 时才需要这样做。
rtspsAddress: :8322
# Address of the UDP/RTP listener. This is needed only when "udp" is in protocols.
# UDP/RTP 监听地址。只有在协议中使用“udp”时才需要这样做。
rtpAddress: :8000
# Address of the UDP/RTCP listener. This is needed only when "udp" is in protocols.
# UDP/RTCP 侦听器地址。只有在协议中使用“udp”时才需要这样做。
rtcpAddress: :8001
# IP range of all UDP-multicast listeners. This is needed only when "multicast" is in protocols.
# 所有 udp 组播侦听器的 IP 范围。只有在协议中使用“multicast”时才需要这样做。
multicastIPRange: 224.1.0.0/16
# Port of all UDP-multicast/RTP listeners. This is needed only when "multicast" is in protocols.
# 所有 udp 组播/RTP侦听器的端口。只有在协议中使用“组播”时才需要这样做。
multicastRTPPort: 8002
# Port of all UDP-multicast/RTCP listeners. This is needed only when "multicast" is in protocols.
# 所有udp组播/RTCP侦听器的端口。只有在协议中使用“组播”时才需要这样做。
multicastRTCPPort: 8003
# 服务器密钥的路径。只有当加密为“strict”或“optional”时才需要这样做。
# 可以使用以下命令生成:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
serverKey: server.key
# 服务器证书的路径。只有当加密为“strict”或“optional”时才需要这样做。
serverCert: server.crt
# Authentication methods. Available are "basic" and "digest".
# 身份验证方法。可用的有“basic”和“digest”。
# “digest”不提供任何额外的安全性,仅出于兼容性原因而可用。
authMethods: [ basic ]

###############################################
# RTMP parameters

# 关闭 RTMP协议支持。
rtmpDisable: no
# Address of the RTMP listener. This is needed only when encryption is "no" or "optional".
# RTMP监听器的地址。只有当加密为 no 或 optional ;时才需要这样做。
rtmpAddress: :1935
# 使用TLS (RTMPS)加密连接。
# 取值 "no", "strict", "optional".
rtmpEncryption: "no"
# Address of the RTMPS listener. This is needed only when encryption is "strict" or "optional".
# RTMPS监听器的地址。只有当加密为“strict”或“optional”时才需要这样做。
rtmpsAddress: :1936
# Path to the server key. This is needed only when encryption is "strict" or "optional".
# This can be generated with:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
rtmpServerKey: server.key
# Path to the server certificate. This is needed only when encryption is "strict" or "optional".
rtmpServerCert: server.crt

###############################################
# HLS 参数

# 关闭 HLS 协议支持。
hlsDisable: no
# HLS 监听器的地址。
hlsAddress: :8888
# 在 HLS 服务器上启用 TLS/HTTPS
# 这是低延迟 HLS所需要的。
hlsEncryption: no
# 服务器密钥的路径。只有当加密为yes时才需要这样做。
# 可以使用:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
hlsServerKey: server.key
# 服务器证书的路径。
hlsServerCert: server.crt
# 默认情况下,HLS仅在用户请求时生成。
# 此选项允许始终生成它,避免了请求和生成之间的延迟。
hlsAlwaysRemux: no
# 使用的HLS协议的变体。可用的选项有:
# * mpegts - 使用MPEG-TS段,以获得最大的兼容性。
# * fmp4 - 采用碎片化MP4段,效率更高。
# * lowLatency - 使用低延迟HLS。
hlsVariant: lowLatency
# 要在服务器上保留的HLS段的数量。
# 分段允许在流中查找。
# 它们的数量不会影响延迟。
hlsSegmentCount: 7
# 每个段的最小持续时间。
# 在播放流之前,播放器通常会在缓冲区中放入3个片段。
# 最后的片段持续时间也受到IDR帧之间的间隔的影响。
# 因为服务器为了包含至少一个IDR帧而更改持续时间
# 在每个片段中。
hlsSegmentDuration: 1s
# 每个部件的最小持续时间。
# 在播放流之前,播放器通常会在缓冲区中放入3个部分。
# 在低延迟HLS中使用部件来代替段。
# 部分持续时间受视频/音频样本之间距离的影响
# 并进行调整,以产生具有相似持续时间的片段。
hlsPartDuration: 200ms
# 每个段的最大大小。
# 这可以防止RAM耗尽。
hlsSegmentMaxSize: 50M
# 每个HTTP响应中提供的Access-Control-Allow-Origin头的值。
# 这允许从外部网站播放HLS流。
hlsAllowOrigin: '*'
# 放置在HLS服务器前的代理ip或cidr列表。
# 如果服务器接收到来自其中一个条目的请求,则记录在日志中的IP
# 将从x - forward - for标头中获取。
hlsTrustedProxies: [ ]
# 存放段的目录,而不是将它们保存在RAM中。
# 这会降低性能,因为从磁盘读取的性能低于
# 从RAM读取,但允许节省RAM。
hlsDirectory: ''

###############################################
# WebRTC 参数

# 关闭对WebRTC协议的支持。
webrtcDisable: no
# WebRTC监听器地址。
webrtcAddress: :8889
# 在WebRTC服务器上启用TLS/HTTPS。
webrtcEncryption: no
# 服务器密钥的路径。
# 可以使用以下命令生成:
# openssl genrsa -out server.key 2048
# openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
webrtcServerKey: server.key
# 服务器证书的路径。
webrtcServerCert: server.crt
# 每个HTTP响应中提供的Access-Control-Allow-Origin头的值。
# 这允许从外部网站播放WebRTC流。
webrtcAllowOrigin: '*'
# 放置在WebRTC服务器前的代理ip地址或cidr列表。
# 如果服务器接收到来自其中一个条目的请求,则记录在日志中的IP
# 将从x-forward-for标头中获取。
webrtcTrustedProxies: [ ]
# ICE服务器列表。
webrtcICEServers2:
  # URL可以指向STUN、TURN或TURNS服务器。
  # STUN服务器用于获取服务器和客户端的公网IP地址。他们是
  # 当服务器和客户端位于不同的局域网时需要。
  # 当服务器与服务器之间有直接连接时,需要使用TURN/TURNS服务器
  # 客户是不可能的。所有的流量都要经过它们。
  - url: stun:stun.l.google.com:19302
    # 如果user是“auth_secret”,那么身份验证是基于秘密的。
    # 密码字段中必须插入密码。
    username: ''
    password: ''
# 用作主机的公网IP地址列表。
# 这通常用于1:1 D-NAT后的服务器。
webrtcICEHostNAT1To1IPs: [ ]
# ICE UDP侦听器地址,格式为host:port。
# 如果填充,ICE流量将通过单个UDP端口,
# 允许在容器内或NAT后部署服务器。
webrtcICEUDPMuxAddress:
# ICE TCP监听器地址,格式为host:port。
# 如果填充,ICE流量将通过单个TCP端口,
# 允许在容器内或NAT后部署服务器。
# 设置此参数强制使用TCP协议,而不是TCP协议
# 这是WebRTC的最佳选择。
webrtcICETCPMuxAddress:

###############################################
# Path 参数

# 这些设置依赖于路径,映射键是路径的名称。
# 可以通过使用波浪作为前缀来使用正则表达式。
# For example, "~^(test1|test2)$" will match both "test1" and "test2".
# 例如,~^(test1|test2)$ 将匹配所有以 test1 和 test2 结尾的路径。
# For example, "~^prefix" will match all paths that start with "prefix".
# 例如,~^prefix 将匹配所有以 prefix 开头的路径。
# 路径 “all” 下的设置应用于与其他条目不匹配的所有路径
paths:
  all:
    # 流的源头。这可以是:
    # * publisher -> 流由RTSP或RTMP客户端发布
    # * rtsp://existing-url -> 流是从另一个RTSP服务器/摄像机拉出来的
    # * rtsps://existing-url -> 流是从另一个带有RTSP的RTSP服务器/摄像机拉出来的
    # * rtmp://existing-url -> 流是从另一个RTMP服务器/摄像机拉出来的
    # * rtmps://existing-url -> 流通过RTMP从另一个RTMP服务器/摄像机拉出
    # * http://existing-url/stream.m3u8 -> 流是从另一个HLS服务器拉出的
    # * https://existing-url/stream.m3u8 -> 流通过HTTPS从另一个HLS服务器拉出
    # * udp://ip:port -> 流是从UDP提取的,通过监听指定的IP和端口
    # * redirect -> 流由另一个路径或服务器提供
    # * rpiCamera -> 该流由树莓派相机提供
    source: publisher

    ###############################################
    # 一般路径参数

    # 如果源是 URL,并且源证书是自签名的
    # 或者无效,您可以提供指纹证书以便
    # 无论如何都要验证它。可以通过运行:
    # openssl s_client -connect source_ip:source_port </dev/null 2>/dev/null | sed -n '/BEGIN/,/END/p' > server.crt
    # openssl x509 -in server.crt -noout -fingerprint -sha256 | cut -d "=" -f2 | tr -d ':'
    sourceFingerprint:
    # 按需拉流(无人观看时断开连接)yes
    sourceOnDemand: no
    # 如果 sourceOnDemand 为 “yes”,等待 10 秒后开始拉流
    sourceOnDemandStartTimeout: 10s
    # 如果 sourceOnDemand 为“ yes ;无人观看 10 秒后关闭连接
    sourceOnDemandCloseAfter: 10s

    ###############################################
    # 认证路径参数

    # 发布时需要用户名。
    # sha256 哈希值可以插入 ;sha256: 前缀。
    publishUser:
    # 发布时需要密码。
    # sha256哈希值可以插入 sha256 前缀。
    publishPass:
    # 允许发布的ip或网络(x.x.x.x/24)。
    publishIPs: [ ]

    # 需要用户名才能读取
    # sha256 哈希值可以插入 sha256 前缀。
    readUser:
    # 需要密码才能读取。
    # sha256 哈希值可以插入 sha256 前缀。
    readPass:
    # 允许读取的ip或网络(x.x.x.x/24)。
    readIPs: [ ]

    ###############################################
    # 发布者路径参数(当源为发布者时)

    # 不要允许其他客户端断开当前发布者的连接并在其位置上发布。
    disablePublisherOverride: no
    # 如果没有人发布,将读者重定向到此路径。
    # 它可以是一个相对路径(例如/otherstream)或一个绝对的RTSP URL。
    fallback:

    ###############################################
    # RTSP路径参数(当源为RTSP或RTSP URL时)

    # 用于拉取流的协议。取值为“自动”、“udp”、“multicast”、“tcp”。
    sourceProtocol: automatic
    # 支持不提供服务器端口或使用随机服务器端口的源。这是一个安全问题
    # 并且必须仅在与需要它的源交互时使用。
    sourceAnyPortEnable: no
    # 要发送到源的范围标头,以便从指定的偏移量开始流。
    # 可用值:
    # * clock: 可用值:
    # * npt: Normal Play Time 正常播放时间
    # * smpte: 相对于记录开始的 SMPTE 时间戳
    rtspRangeType:
    # 可用值:
    # * clock: UTC ISO 8601组合日期和时间字符串,例如20230812T120000Z
    # * npt: duration such as "300ms", "1.5m" or "2h45m", valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h"
    # * smpte: duration such as "300ms", "1.5m" or "2h45m", valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h"
    rtspRangeStart:

    ###############################################
    # 重定向路径参数(当源为  redire 时)

    # 客户端将被重定向到的RTSP URL。
    sourceRedirect:

    ###############################################
    # 相机路径参数(当源为“rpiCamera ”时)

    # 相机ID
    rpiCameraCamID: 0
    # 框架宽度
    rpiCameraWidth: 1920
    # 框架高度
    rpiCameraHeight: 1080
    # 水平翻转
    rpiCameraHFlip: false
    # 垂直翻转
    rpiCameraVFlip: false
    # 亮度[- 1,1]
    rpiCameraBrightness: 0
    # 对比[0,16]
    rpiCameraContrast: 1
    # 饱和度[0,16]
    rpiCameraSaturation: 1
    # 锐度[0,16]
    rpiCameraSharpness: 1
    # 曝光模式.
    # values: normal, short, long, custom
    rpiCameraExposure: normal
    # 自动白平衡模式。
    # values: auto, incandescent, tungsten, fluorescent, indoor, daylight, cloudy, custom
    rpiCameraAWB: auto
    # 降噪工作模式。
    # values: off, cdn_off, cdn_fast, cdn_hq
    rpiCameraDenoise: "off"
    # 固定快门速度,以微秒为单位。
    rpiCameraShutter: 0
    # AEC/AGC算法的计量模式。
    # values: centre, spot, matrix, custom
    rpiCameraMetering: centre
    # 固定增益
    rpiCameraGain: 0
    # 图像的EV补偿[- 10,10]
    rpiCameraEV: 0
    # 感兴趣的区域,格式为x,y,宽度,高度
    rpiCameraROI:
    # 调整文件
    rpiCameraTuningFile:
    # 传感器模式,格式为[width]:[height]:[bit-depth]:[packing]
    # 位深度和填充是可选的。
    rpiCameraMode:
    # 每秒帧数
    rpiCameraFPS: 30
    # IDR帧之间的间隔
    rpiCameraIDRPeriod: 60
    # 比特率
    rpiCameraBitrate: 1000000
    # H264概要
    rpiCameraProfile: main
    # H264水平
    rpiCameraLevel: '4.1'
    # 自动对焦模式
    # values: auto, manual, continuous
    # 取值范围:自动、手动、连续
    rpiCameraAfMode: auto
    # 自动对焦范围
    # values: normal, macro, full
    rpiCameraAfRange: normal
    # 自动对焦速度
    # values: normal, fast
    rpiCameraAfSpeed: normal
    # 镜头位置(仅适用于手动自动对焦),将设置对焦到特定距离
    # calculated by the following formula: d = 1 / value
    # Examples: 0 moves the lens to infinity.
    #           0.5 moves the lens to focus on objects 2m away.
    #           2 moves the lens to focus on objects 50cm away.
    rpiCameraLensPosition: 0.0
    # 指定自动对焦窗口,以x、y、宽度、高度的坐标形式表示
    # 以占整个图像的比例给出。
    rpiCameraAfWindow:
    # 启用在每一帧上打印文本。
    rpiCameraTextOverlayEnable: false
    # 印在每一帧上的文字。
    # Format是strftime()函数之一。
    rpiCameraTextOverlay: '%Y-%m-%d %H:%M:%S - MediaMTX'

    ###############################################
    # 外部命令路径参数

    # 初始化此路径时运行的命令。
    # 这可以用于发布流并使其始终打开。
    # 预先考虑。/在当前文件夹中运行可执行文件(例如:./ffmpeg)
    # 当程序关闭时,它以SIGINT终止。
    # 可用的环境变量如下:
    # * MTX_PATH: 路径名
    # * RTSP_PORT: RTSP服务器端口
    # * G1, G2, ...: 正则表达式组,如果路径名是
    #   正则表达式。
    runOnInit:
    # 如果命令退出,则重新启动命令。
    runOnInitRestart: no

    # 命令,在请求此路径时运行。
    # 这可以用于按需发布流。
    # 预先考虑。/在当前文件夹中运行可执行文件(例如:./ffmpeg)
    # 当路径不再被请求时,它以SIGINT终止。
    # 可用的环境变量如下:
    # * MTX_PATH: path name
    # * RTSP_PORT: RTSP server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnDemand:
    # 如果命令退出,则重新启动命令。
    runOnDemandRestart: no
    # reader 将被搁置,直到 runOnDemand命令开始发布
    # 或者等到这段时间过去了。
    runOnDemandStartTimeout: 10s
    # 当不存在时,命令将关闭
    # 读者连接,这段时间已经过去了。
    runOnDemandCloseAfter: 10s

    # 命令,在流准备好读取时运行
    # 由客户端发布或从服务器/摄像机提取。
    # 预先考虑。/在当前文件夹中运行可执行文件(例如:./ffmpeg)
    # 当流不再准备好时,它以SIGINT终止。
    # 可用的环境变量如下:
    # * MTX_PATH: path name
    # * RTSP_PORT: RTSP server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnReady:
    # Restart the command if it exits.
    runOnReadyRestart: no

    # 命令,当客户端开始读取时运行。
    # 预先考虑。/在当前文件夹中运行可执行文件(例如:./ffmpeg)
    # 当客户端停止读取时,此操作以SIGINT终止。
    # 可用的环境变量如下:
    # * MTX_PATH: path name
    # * RTSP_PORT: RTSP server port
    # * G1, G2, ...: regular expression groups, if path name is
    #   a regular expression.
    runOnRead:
    # 如果命令退出,则重新启动命令。
    runOnReadRestart: no