欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ffmpeg库srt参数详解

程序员文章站 2022-07-14 20:45:22
...

目录

1.示例:

2.原文: 

3.翻译:

4.参考:


1.示例:

srt://127.0.0.1:10004?pkt_size=1316&mode=listener&latency=20000&pbkeylen=16&passphrase=1234567887654321&oheadbw=25

2.原文: 

ffmpeg库srt参数详解

options contains a list of ’-key val’ options.

This protocol accepts the following options.

‘connect_timeout=milliseconds’

Connection timeout; SRT cannot connect for RTT > 1500 msec (2 handshake exchanges) with the default connect timeout of 3 seconds. This option applies to the caller and rendezvous connection modes. The connect timeout is 10 times the value set for the rendezvous mode (which can be used as a workaround for this connection problem with earlier versions).

‘ffs=bytes’

Flight Flag Size (Window Size), in bytes. FFS is actually an internal parameter and you should set it to not less than ‘recv_buffer_size’ and ‘mss’. The default value is relatively large, therefore unless you set a very large receiver buffer, you do not need to change this option. Default value is 25600.

‘inputbw=bytes/seconds’

Sender nominal input rate, in bytes per seconds. Used along with ‘oheadbw’, when ‘maxbw’ is set to relative (0), to calculate maximum sending rate when recovery packets are sent along with the main media stream: ‘inputbw’ * (100 + ‘oheadbw’) / 100 if ‘inputbw’ is not set while ‘maxbw’ is set to relative (0), the actual input rate is evaluated inside the library. Default value is 0.

‘iptos=tos’

IP Type of Service. Applies to sender only. Default value is 0xB8.

‘ipttl=ttl’

IP Time To Live. Applies to sender only. Default value is 64.

‘latency=microseconds’

Timestamp-based Packet Delivery Delay. Used to absorb bursts of missed packet retransmissions. This flag sets both ‘rcvlatency’ and ‘peerlatency’ to the same value. Note that prior to version 1.3.0 this is the only flag to set the latency, however this is effectively equivalent to setting ‘peerlatency’, when side is sender and ‘rcvlatency’ when side is receiver, and the bidirectional stream sending is not supported.

‘listen_timeout=microseconds’

Set socket listen timeout.

‘maxbw=bytes/seconds’

Maximum sending bandwidth, in bytes per seconds. -1 infinite (CSRTCC limit is 30mbps) 0 relative to input rate (see ‘inputbw’) >0 absolute limit value Default value is 0 (relative)

‘mode=caller|listener|rendezvous’

Connection mode. ‘caller’ opens client connection. ‘listener’ starts server to listen for incoming connections. ‘rendezvous’ use Rendez-Vous connection mode. Default value is caller.

‘mss=bytes’

Maximum Segment Size, in bytes. Used for buffer allocation and rate calculation using a packet counter assuming fully filled packets. The smallest MSS between the peers is used. This is 1500 by default in the overall internet. This is the maximum size of the UDP packet and can be only decreased, unless you have some unusual dedicated network settings. Default value is 1500.

‘nakreport=1|0’

If set to 1, Receiver will send ‘UMSG_LOSSREPORT‘ messages periodically until a lost packet is retransmitted or intentionally dropped. Default value is 1.

‘oheadbw=percents’

Recovery bandwidth overhead above input rate, in percents. See ‘inputbw’. Default value is 25%.

‘passphrase=string’

HaiCrypt Encryption/Decryption Passphrase string, length from 10 to 79 characters. The passphrase is the shared secret between the sender and the receiver. It is used to generate the Key Encrypting Key using PBKDF2 (Password-Based Key Derivation Function). It is used only if ‘pbkeylen’ is non-zero. It is used on the receiver only if the received data is encrypted. The configured passphrase cannot be recovered (write-only).

‘enforced_encryption=1|0’

If true, both connection parties must have the same password set (including empty, that is, with no encryption). If the password doesn’t match or only one side is unencrypted, the connection is rejected. Default is true.

‘kmrefreshrate=packets’

The number of packets to be transmitted after which the encryption key is switched to a new key. Default is -1. -1 means auto (0x1000000 in srt library). The range for this option is integers in the 0 - INT_MAX.

‘kmpreannounce=packets’

The interval between when a new encryption key is sent and when switchover occurs. This value also applies to the subsequent interval between when switchover occurs and when the old encryption key is decommissioned. Default is -1. -1 means auto (0x1000 in srt library). The range for this option is integers in the 0 - INT_MAX.

‘payload_size=bytes’

Sets the maximum declared size of a packet transferred during the single call to the sending function in Live mode. Use 0 if this value isn’t used (which is default in file mode). Default is -1 (automatic), which typically means MPEG-TS; if you are going to use SRT to send any different kind of payload, such as, for example, wrapping a live stream in very small frames, then you can use a bigger maximum frame size, though not greater than 1456 bytes.

‘pkt_size=bytes’

Alias for ‘payload_size’.

‘peerlatency=microseconds’

The latency value (as described in ‘rcvlatency’) that is set by the sender side as a minimum value for the receiver.

‘pbkeylen=bytes’

Sender encryption key length, in bytes. Only can be set to 0, 16, 24 and 32. Enable sender encryption if not 0. Not required on receiver (set to 0), key size obtained from sender in HaiCrypt handshake. Default value is 0.

‘rcvlatency=microseconds’

The time that should elapse since the moment when the packet was sent and the moment when it’s delivered to the receiver application in the receiving function. This time should be a buffer time large enough to cover the time spent for sending, unexpectedly extended RTT time, and the time needed to retransmit the lost UDP packet. The effective latency value will be the maximum of this options’ value and the value of ‘peerlatency’ set by the peer side. Before version 1.3.0 this option is only available as ‘latency’.

‘recv_buffer_size=bytes’

Set UDP receive buffer size, expressed in bytes.

‘send_buffer_size=bytes’

Set UDP send buffer size, expressed in bytes.

‘timeout=microseconds’

Set raise error timeouts for read, write and connect operations. Note that the SRT library has internal timeouts which can be controlled separately, the value set here is only a cap on those.

‘tlpktdrop=1|0’

Too-late Packet Drop. When enabled on receiver, it skips missing packets that have not been delivered in time and delivers the following packets to the application when their time-to-play has come. It also sends a fake ACK to the sender. When enabled on sender and enabled on the receiving peer, the sender drops the older packets that have no chance of being delivered in time. It was automatically enabled in the sender if the receiver supports it.

‘sndbuf=bytes’

Set send buffer size, expressed in bytes.

‘rcvbuf=bytes’

Set receive buffer size, expressed in bytes.

Receive buffer must not be greater than ‘ffs’.

‘lossmaxttl=packets’

The value up to which the Reorder Tolerance may grow. When Reorder Tolerance is > 0, then packet loss report is delayed until that number of packets come in. Reorder Tolerance increases every time a "belated" packet has come, but it wasn’t due to retransmission (that is, when UDP packets tend to come out of order), with the difference between the latest sequence and this packet’s sequence, and not more than the value of this option. By default it’s 0, which means that this mechanism is turned off, and the loss report is always sent immediately upon experiencing a "gap" in sequences.

‘minversion’

The minimum SRT version that is required from the peer. A connection to a peer that does not satisfy the minimum version requirement will be rejected.

The version format in hex is 0xXXYYZZ for x.y.z in human readable form.

‘streamid=string’

A string limited to 512 characters that can be set on the socket prior to connecting. This stream ID will be able to be retrieved by the listener side from the socket that is returned from srt_accept and was connected by a socket with that set stream ID. SRT does not enforce any special interpretation of the contents of this string. This option doesn’t make sense in Rendezvous connection; the result might be that simply one side will override the value from the other side and it’s the matter of luck which one would win

‘smoother=live|file’

The type of Smoother used for the transmission for that socket, which is responsible for the transmission and congestion control. The Smoother type must be exactly the same on both connecting parties, otherwise the connection is rejected.

‘messageapi=1|0’

When set, this socket uses the Message API, otherwise it uses Buffer API. Note that in live mode (see ‘transtype’) there’s only message API available. In File mode you can chose to use one of two modes:

Stream API (default, when this option is false). In this mode you may send as many data as you wish with one sending instruction, or even use dedicated functions that read directly from a file. The internal facility will take care of any speed and congestion control. When receiving, you can also receive as many data as desired, the data not extracted will be waiting for the next call. There is no boundary between data portions in the Stream mode.

Message API. In this mode your single sending instruction passes exactly one piece of data that has boundaries (a message). Contrary to Live mode, this message may span across multiple UDP packets and the only size limitation is that it shall fit as a whole in the sending buffer. The receiver shall use as large buffer as necessary to receive the message, otherwise the message will not be given up. When the message is not complete (not all packets received or there was a packet loss) it will not be given up.

‘transtype=live|file’

Sets the transmission type for the socket, in particular, setting this option sets multiple other parameters to their default values as required for a particular transmission type.

live: Set options as for live transmission. In this mode, you should send by one sending instruction only so many data that fit in one UDP packet, and limited to the value defined first in ‘payload_size’ (1316 is default in this mode). There is no speed control in this mode, only the bandwidth control, if configured, in order to not exceed the bandwidth with the overhead transmission (retransmitted and control packets).

file: Set options as for non-live transmission. See ‘messageapi’ for further explanations

‘linger=seconds’

The number of seconds that the socket waits for unsent data when closing. Default is -1. -1 means auto (off with 0 seconds in live mode, on with 180 seconds in file mode). The range for this option is integers in the 0 - INT_MAX.

For more information see: https://github.com/Haivision/srt.

3.翻译:

options包含“键值”选项列表。该协议接受以下选项。

“ connect_timeout =毫秒”连接超时;

对于RTT> 1500毫秒(两次握手交换),SRT无法连接,默认连接超时为3秒。此选项适用于呼叫者和集合点连接模式。连接超时是为会合模式设置的值的10倍(可以将其用作早期版本中此连接问题的解决方法)。

“ ffs = bytes”飞行标志大小(窗口大小),以字节为单位。

FFS实际上是一个内部参数,您应该将其设置为不小于“ recv_buffer_size”和“ mss”。默认值相对较大,因此,除非您设置非常大的接收器缓冲区,否则无需更改此选项。默认值为25600。

“ inputbw = bytes / seconds”发件人名义输入速率,以每秒字节数为单位。当“ maxbw”设置为相对(0)时,与“ oheadbw”一起使用,以计算与主媒体流一起发送恢复数据包时的最大发送速率:“ inputbw” *(100 +'oheadbw')/ 100当“ maxbw”设置为相对值(0)时,未设置“ inputbw”,则在库中评估实际输入速率。默认值为0。

“ iptos = tos” IP服务类型。仅适用于发件人。默认值为0xB8。

“ ipttl = ttl” IP生存时间。仅适用于发件人。默认值为64。

“ latency = microseconds”基于时间戳的数据包传递延迟。

用于吸收丢失的数据包重发的突发。此标志将“ rcvlatency”和“ peerlatency”设置为相同的值。请注意,在版本1.3.0之前,这是唯一设置延迟的标志,但是,这实际上等效于当side是发送方时设置“ peerlatency”,当side是接收方时设置“ rcvlatency”,并且不支持双向流发送。

‘listen_timeout = microseconds’设置套接字监听超时。

“ maxbw = bytes / seconds”最大发送带宽,以每秒字节数为单位。

-1无限(CSRTCC限制为30mbps)相对于输入速率为0(请参见“ inputbw”)> 0绝对限制值默认值为0(相对)

“ mode = caller | listener | rendezvous”连接模式。 “呼叫者”打开客户端连接。 “侦听器”启动服务器以侦听传入的连接。 “ rendezvous”使用Rendez-Vous连接模式。默认值为呼叫者。

“ mss = bytes”最大段大小,以字节为单位。

用于使用假定完全填充的数据包的数据包计数器进行缓冲区分配和速率计算。使用对等体之间最小的MSS。在整个Internet中,默认值为1500。这是UDP数据包的最大大小,只能减小,除非您有一些异常的专用网络设置。默认值为1500。

'nakreport = 1 | 0'如果设置为1,Receiver将定期发送'UMSG_LOSSREPORT'消息,直到丢失的数据包被重新发送或有意丢弃为止。默认值为1。

‘oheadbw = percents’输入速率之上的恢复带宽开销,以百分比为单位。参见“ inputbw”。默认值为25%。

“ passphrase = string” HaiCrypt加密/解密密码短语字符串,长度从10到79个字符。密码短语是发送者和接收者之间的共享秘密。它用于使用PBKDF2(基于密码的**派生功能)来生成**加***。仅在“ pbkeylen”不为零时使用。仅当接收到的数据被加密时,才在接收器上使用它。无法恢复已配置的密码短语(仅写)。

“ enforced_encryption = 1 | 0”如果为true,则两个连接方都必须设置相同的密码(包括空密码,即不加密)。如果密码不匹配或仅一侧未加密,则连接被拒绝。默认为true。

‘kmrefreshrate = packets’在加***切换到新**之后要传输的数据包数量。默认值为-1。 -1表示自动(srt库中为0x1000000)。此选项的范围是0-INT_MAX中的整数。

‘kmpreannounce = packets’发送新加***到发生切换之间的时间间隔。此值也适用于切换发生和停用旧加***之间的后续时间间隔。默认值为-1。 -1表示自动(srt库中为0x1000)。此选项的范围是0-INT_MAX中的整数。

“ payload_size = bytes”设置在实时模式下单次调用发送功能期间传输的数据包的最大声明大小。如果未使用此值,则使用0(在文件模式下为默认值)。默认值为-1(自动),通常表示MPEG-TS;如果要使用SRT发送任何不同类型的有效负载,例如将实时流包装在非常小的帧中,则可以使用更大的最大帧大小,尽管不超过1456字节。

“ pkt_size = bytes”是“ payload_size”的别名。

“ peerlatency = microseconds”由发送方设置为接收方最小值的延迟值(如“ rcvlatency”中所述)。

“ pbkeylen = bytes”发件人加***的长度,以字节为单位。只能设置为0、16、24和32。如果不设置为0,则启用发送者加密。在接收者上不需要(设置为0),**大小是通过HaiCrypt握手从发送者获得的。预设值为0。

‘rcvlatency = microseconds’
从发送数据包到将数据包发送到接收功能中的接收器应用程序之间经过的时间。此时间应该是足够大的缓冲时间,以涵盖发送所花费的时间,意外延长的RTT时间以及重传丢失的UDP数据包所需的时间。有效延迟值是此选项值和对端设置的“ peerlatency”的最大值。在1.3.0版之前,此选项仅可作为“延迟”使用。

‘recv_buffer_size = bytes’
设置UDP接收缓冲区的大小,以字节为单位。

“ send_buffer_size =字节”
设置UDP发送缓冲区大小,以字节为单位。

“超时=微秒”
设置读取,写入和连接操作的引发错误超时。请注意,SRT库具有内部超时,可以单独控制这些超时,此处设置的值只是这些超时的上限。

‘tlpktdrop = 1 | 0’
丢包率过高。在接收器上启用后,它将跳过尚未及时传送的丢失数据包,并在播放时间到后将以下数据包传送到应用程序。它还会向发送方发送伪造的ACK。在发送方上启用并在接收对等方上启用后,发送方将丢弃无法及时传递的较旧数据包。如果接收者支持,它将在发送者中自动启用。

‘sndbuf = bytes’
设置发送缓冲区大小,以字节为单位。

‘rcvbuf = bytes’
设置接收缓冲区大小,以字节为单位。

接收缓冲区不得大于“ ffs”。

‘lossmaxttl = packets’
重新订购公差可能增加到的值。当Reorder Tolerance> 0时,丢包报告会延迟到该数量的数据包进入时。每当有“延迟的”数据包进入时,Reorder Tolerance都会增加,但这不是由于重传(也就是说,当UDP数据包趋向于顺序不正确),其最新序列与该数据包的序列之间的差异不得超过此选项的值。默认情况下,该值为0,表示此机制已关闭,并且丢失报告总是在顺序出现“间隙”后立即发送。

“ minversion”
对等方要求的最低SRT版本。不满足最低版本要求的与对等方的连接将被拒绝。

对于x.y.z,十六进制的版本格式为0xXXYYZZ,且易于阅读。

‘streamid = string’
连接之前可以在套接字上设置的字符串,长度限制为512个字符。侦听器方将能够从srt_accept返回的套接字中检索此流ID,该套接字由具有该已设置流ID的套接字连接。 SRT对此字符串的内容不执行任何特殊解释。此选项在“聚会”连接中没有意义;结果可能是,仅仅一侧将覆盖另一侧的值,而幸运的是,一方将获胜

‘smoother = live |文件’
用于该套接字的传输的“平滑器”类型,负责传输和拥塞控制。两端连接器上的“平滑器”类型必须完全相同,否则连接将被拒绝。

‘messageapi = 1 | 0’
设置后,此套接字使用Message API,否则使用Buffer API。请注意,在实时模式(请参阅“转换类型”)中,只有消息API可用。在文件模式下,您可以选择使用以下两种模式之一:

流API(默认,当此选项为false时)。在这种模式下,您可以通过一条发送指令发送任意数量的数据,甚至可以使用直接从文件读取的专用功能。内部设施将负责任何速度和拥塞控制。接收时,您还可以接收任意数量的数据,未提取的数据将等待下一个呼叫。在流模式下,数据部分之间没有边界。

消息API。在这种模式下,您的一条发送指令仅传递一条带有边界的数据(一条消息)。与实时模式相反,此消息可能跨越多个UDP数据包,唯一的大小限制是它应整体适合发送缓冲区。接收者应使用必要的大缓冲区来接收消息,否则消息不会被放弃。当消息不完整时(不是接收到所有数据包或没有数据包丢失),将不会放弃该消息。

“ transtype = live |文件”
设置套接字的传输类型,尤其是,设置此选项会将多个其他参数设置为特定传输类型所需的默认值。

实时:设置实时传输的选项。在此模式下,您应仅通过一条发送指令发送适合一个UDP数据包且限制在val中的数据。

 ‘linger = seconds’
关闭时套接字等待未发送数据的秒数。 默认值为-1。 -1表示自动(实时模式下为0秒,文件模式下为180秒)。 此选项的范围是0-INT_MAX中的整数。

4.参考:

https://ffmpeg.org/documentation.html

 https://github.com/Haivision/srt.

相关标签: 音视频传输协议