[FFmpeg-user] Audio-Video Delay When Fetching From NGINX-RTMP

Stephan Monecke stephanmonecke at gmail.com
Sat Nov 14 18:12:57 EET 2020


Hi together,


so far, no one had an idea what causes this audio-offset. Since this
is a pretty disturbing behavior for us trying to broadcast lectures, I
thought I might politely ask again with a few more details on the
setup if someone here has a clue what's going on.

The two ffmpeg invocations are:

First:
/usr/bin/ffmpeg -i rtsp://url -c copy -an -f flv rtmp://localhost/live

Second:
/usr/bin/ffmpeg \
    -use_wallclock_as_timestamps 1 -fflags +genpts -max_delay 2000000
-thread_queue_size 1024 -i rtmp://localhost/live \
    -use_wallclock_as_timestamps 1 -fflags +genpts -max_delay 2000000
-thread_queue_size 1024  -f pulse -i
alsa_input.pci-0000_00_1f.3.analog-stereo \
    -af aresample=async=1 -codec:a aac -b:a 192k -ar 48000 \
    -c:v copy \
    -map 0:v -map 1:a -max_muxing_queue_size 99999 outfile.mp4

Whereat the configuration of rtmp://localhost/live is:

application live {
      live on;
      sync 10ms;
      record off;
      allow publish 127.0.0.1;
      deny publish all;
      }

This results in an audio-video offset (within outfile.mp4) of nearly 5
s greater compared to using "rtsp://url" directly on the second
invocation.

Since `ffplay -fflags nobuffer -flags low_delay rtmp://localhost/live`
reacts almost instantly I suspect the issue not to be with nginx but
the time-stamp handling of ffmpeg.


Any suggestions are warmly welcomed!


Thanks a lot!

Stephan

Am So., 8. Nov. 2020 um 21:46 Uhr schrieb Stephan Monecke
<stephanmonecke at gmail.com>:
>
> Good evening together,
>
>
> I have another audio-sync question where we're out of ideas.
> We get an rtsp-Stream and mix it together with line-in over pulseaudio.
>
> This looks something like:
>
> ffmpeg \
>   -use_wallclock_as_timestamps 1  -fflags +genpts      \
>   -max_delay 2000000 -thread_queue_size 1024         \
>   -i "rtsp://url"           \
>   -use_wallclock_as_timestamps 1  -fflags +genpts      \
>   -max_delay 2000000 -thread_queue_size 1024         \
>   -itsoffset <offset>  \
>   -f pulse                  \
>   [...]
>
> So far so good. This _kind_ of works when fetching the rtsp stream directly.
>
> As soon as we route the rtsp stream through an nginx-rtmp loopback
> (live mode) beforehand, we get a delay of close to 5 s within the
> output.
> The rtmp-server itself does not cause a noticeable delay, I hence
> assume this to be a timestamp issue but my wisdom ends with the above
> written options.
>
>
> Any ideas anyone?
>
>
> Thanks a lot!
>
>
> Stephan


More information about the ffmpeg-user mailing list