nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

Audio-Video Delay When Fetching From NGINX-RTMP live-Mode

Open suuuehgi opened this issue 4 years ago • 2 comments

We have a problem with our stream routing for online-lectures. 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 RTMP loopback (live mode) beforehand,

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

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         \
  -itsoffset <offset>                                \
  -f pulse                                           \
  [...]

we get a delay of close to 5 s within the output (audio-video offset) what causes trouble.

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;
      }

What causes the delay and how to get rid of it?

I assume this to be a timestamp issue but my wisdom ends with the above written options. Any ideas?

Thanks a ton for any help!

suuuehgi avatar Nov 17 '20 19:11 suuuehgi

curious if you ever solved this?

lylepratt avatar Nov 03 '22 01:11 lylepratt

curious if you ever solved this?

No. In the end I worked around it by mixing audio and video ahead of the loop-back device.

The problem just appeared when routing only the video through the loop-back.

If you'd like to know anything specific, I have to look it up.

suuuehgi avatar Nov 04 '22 21:11 suuuehgi