How to configure the streaming parameters of ffmpeg to shorten the streaming interval

To shorten the streaming interval, you can use the following commands in ffmpeg to set streaming parameters:

  1. Set the frame rate when streaming: -r parameter, which can be set to 30, 60, etc., that is, how many frames of video are sent per second.

  2. Set the push stream bit rate: -b:v parameter, which can be set to a higher value, such as 2000K, to increase the video transmission rate.

  3. Use a lower resolution: -s parameter, you can set the resolution to a lower value, such as 640x360, etc., to reduce video size and transmission time.

For example, a simple streaming command is:

ffmpeg -re -i input.mp4 -c:v h264 -preset ultrafast -b:v 2000k -minrate 1500k -maxrate 2500k -bufsize 3000k -f flv rtmp://server/live/stream

其中,
-rtsp_transport tcp 指定传输方式为tcp
-re 表示实时流传输(如果需要)
-i 表示输入文件
-c:v 表示使用 H.264 编码器
-preset ultrafast 表示使用尽可能快的编码器设置
-b:v 表示视频比特率,
-minrate -maxrate 和 -bufsize 表示视频传输速率和缓冲区大小,
-f flv 表示输出流格式,
rtmp://server/live/stream 表示推送到 RTMP 流媒体服务器。

Among them, parameters such as -r, -b:v and -s can be adjusted to optimize the video transmission rate, thereby shortening the streaming interval.

When using udp for transmission, you can also adjust the performance of streaming by setting the cache size. The following options are available:

-max_delay

-bufsize : Set the buffer size in bits. The default value is 2000000 bits.

-rtbufsize : Set the real-time buffer size in bits. The default value is 2000000 bits.

Example:
performance optimization, if the packet loss is serious, the buffer can be enlarged

ffmpeg -i input.mp4 -codec:v copy -codec:a aac -f flv -max_delay 5000 -bufsize 500000 -rtbufsize 500000 rtmp://server/live/stream

Guess you like

Origin blog.csdn.net/qq_45206551/article/details/131413114