I am using ffmpeg and mpv, to stream audio/video between two hosts. One of the hosts is sending stream with ffmpeg:
ffmpeg -f pulse \
-thread_queue_size 0 \
-i audioInput \
-f video4linux2 \
-thread_queue_size 0 \
-standard PAL \
-i videoInput \
-vcodec mpeg4 \
-r 10 \
-s 176x144 \
-maxrate 256K \
-acodec pcm_s16le \
-ar 8000 \
-b:a 32k \
-af aresample=async=1000 \
-f rtsp \
-rtsp_transport tcp \
url
and second host is receiving with mpv:
mpv url --rtsp-transport=tcp \
--profile=low-latency \
--demuxer-lavf-o=rtsp_flags=listen \
--no-cache \
--autosync=30 \
--no-demuxer-thread \
--demuxer-lavf-analyzeduration=0 \
--demuxer-lavf-probesize=32
I have tried a lot of options and combinations to reduce latency as much as possible. Above commands works nice, the latency on startup is < 1s. Unfortunately, sometimes, delay appears during streaming and it can even increase in time. My goal is to ensure, that delay will be more or less constant (close to 1s), and if some delay will appear, delayed frames will be dropped (even if it will affect audio or video quality).
How to force ffmpeg/mpv to drop frames, which are delayed e.g. more than 1s?