ffmpeg – Preventing Viewing Lag in ffplay When Window is Backgrounded on Ubuntu

I’m using ffplay to stream live video on Ubuntu 22.04 LTS on a laptop that only uses the CPU (no GPU). Here’s the command I’m running:

$ ffplay -f live_flv -fast -fflags nobuffer -flags low_delay \
    -strict experimental -vf "setpts=N/30/TB" -an -noframedrop \
    -i rtmp://localhost:1935/live

I’ve noticed that when the ffplay window is sent to the background, a noticeable lag develops in the stream, and this delay persists even after I bring the window back to the foreground. However, if I leave the window in the foreground from the start, the stream runs smoothly without any latency.

I suspect Ubuntu might be lowering the process priority when the window is in the background. Anyway, is there a way to prevent this delay, ensuring the stream runs smoothly whether the window is in the background or foreground?

Read more here: Source link