How to avoid FPS drop while streaming to YouTube from FFmpeg?

I am trying to live stream video on YouTube using FFmpeg and having FPS drops. I am also seeing the following message in FFmpeg logs
Thread message queue blocking; consider raising the thread_queue_size option (current value: 8)

1 Like

Hey Annie,

In order to avoid FPS drop while streaming to Youtube from FFmpeg, there can be multiple reasons for FPS drops while live streaming, but the warning message you are receiving is an indicator that your computer cannot keep up with encoding in real-time.

  • thread_queue_size refers to the buffer size for packets waiting to be encoded. If you exceed the packet buffer size (which means that your buffer is getting full and the encoder cannot reach the pace), FFmpeg will start to drop packets to keep up in real time.

  • Increasing buffer size will allow your computer to process the packets without dropping frames for a short time. Still, eventually, it will run out of memory, and the warning message will start appearing again.

  • Ensure that the encoding parameters you are using for your video stream are adequate. Your machine may be more burdened by higher encoding settings, which can cause FPS dips. To strike the ideal balance between video quality and performance, you can experiment with modifying factors like bitrate, preset, profile, and tuning options.

  • Consider using hardware acceleration to encode the video if your machine is capable of doing so. Various hardware encoders supported by FFmpeg, such as NVIDIA NVENC and AMD VCE, can offload the encoding operation from the CPU, enhancing performance and minimizing FPS drops. In your FFmpeg command, you can specify the hardware encoder by using the -c:v option.

The best option here is to decrease the Framerate at which you live streaming.
Let me know if this helps!

I purchased an old PC last Friday in order to stream video and audio to YouTube, however, the output of FPS isn’t very high. A camera with a resolution of 1920 x 1080 at 15 frames per second and PCM sound are the inputs. I use copy instead of libx264 since I want to stream in full HD on YouTube.

ffmpeg -rtsp_transport tcp -i “rtsp://user:pass@ip:554/cam/realmonitor?channel=1&subtype=0” -tune zerolatency -vcodec libx264 -pix_fmt yuv420p -c:v copy -r 15 -bf 2 -g 30 -c:a aac -ar 44100 -b:a 128k -ac 1 -preset ultrafast -bufsize 2M -movflags +faststart -strict experimental -f flv rtmp:// -threads 2

Intel Core 2 Duo e7500 with 4GB of RAM is what I use. 1 to 5 per cent of Windows 7 computers use processors. Why does the broadcast only occasionally have 10–13FPS?

Hey Lvan!

The values fps=4.9 & speed=1.01x show that FFmpeg is not laggy or dropping frames. Your camera isn’t transmitting at 15 frames per second. Most often as a result of dim lighting.

-tune zerolatency -vcodec libx264 -pix fmt yuv420p -r 15 -bf 2 -g 30are being ignored owing to -c:v copy. Unless your version of FFmpeg is very old, you don’t require -strict experimental. Because of -c:v copy, trailing options like -threads 2 are typically ignored. Option placement is important. For a live stream, -movflags +faststart are not required.

I hope now your query is resolved.