<p>I found a solution on the nginx side by setting the wait_key and wait_video options to on in the nginx.conf file.</p>
<p><a href="https://github.com/dreamsxin/nginx-rtmp-wiki/blob/master/Directives.md#wait_key" rel="nofollow noreferrer">https://github.com/dreamsxin/nginx-rtmp-wiki/blob/master/Directives.md#wait_key</a></p>

CC BY-SA 4.0
2023-08-17T02:15:46.070Z
2023-08-17T02:15:46.070Z
michaeljdennis
<p>I am using the nginx-rtmp-module for accepting RTMP streams and then publishing them locally for transcoding with FFmpeg.</p>
<p>After a recording is made, there is an observable freeze in the video for the first ~1-2 seconds, but the audio plays without issue. After that initial pause, the video will start playing without issue.</p>
<p>This issue only appears when the FFmpeg process starts after the RTMP stream has already been published locally. If the FFmpeg process is started before the RTMP stream has been received by the nginx-rtmp-module, I do not observe the freeze.</p>
<p>I would like to know what is causing this issue and if it can be avoided. Any assistance would be greatly appreciated. Thank you.</p>
<p><strong>Flow:</strong></p>
<p>[Internet] --------&gt;[RTMP stream]--------&gt;[Server running nginx-rtmp-module]--------&gt;[FFmpeg attached to locally publish RTMP stream (rtmp://localhost/live/stream-key)]</p>
<p><strong>Tools used:</strong></p>
<p><a href="https://github.com/arut/nginx-rtmp-module" rel="nofollow noreferrer">https://github.com/arut/nginx-rtmp-module</a></p>
<p>FFmpeg version 5.1.3-1</p>
<p><strong>Example command:</strong></p>
<pre><code>ffmpeg -loglevel info -hide_banner -y \
-i rtmp://localhost/live/stream-key \
-c:v libx264 -s 640x360 -b:v 600k -profile:v main -preset veryfast \
-c:a copy \
output.mp4
</code></pre>

<ffmpeg><rtmp>
Video delay when transcoding from an nginx-rtmp-module RTMP stream
michaeljdennis
# Video delay when transcoding from an nginx-rtmp-module RTMP stream

(Asked by: username_0 on 2023-08-04)

I am using the nginx-rtmp-module for accepting RTMP streams and then publishing them locally for transcoding with FFmpeg.
After a recording is made, there is an observable freeze in the video for the first ~1-2 seconds, but the audio plays without issue. After that initial pause, the video will start playing without issue.
This issue only appears when the FFmpeg process starts after the RTMP stream has already been published locally. If the FFmpeg process is started before the RTMP stream has been received by the nginx-rtmp-module, I do not observe the freeze.
I would like to know what is causing this issue and if it can be avoided. Any assistance would be greatly appreciated. Thank you.
Flow:
[Internet] -------->[RTMP stream]-------->[Server running nginx-rtmp-module]-------->[FFmpeg attached to locally publish RTMP stream (rtmp://localhost/live/stream-key)]
Tools used:
https://github.com/arut/nginx-rtmp-module
FFmpeg version 5.1.3-1
Example command:
ffmpeg -loglevel info -hide_banner -y \
-i rtmp://localhost/live/stream-key \
-c:v libx264 -s 640x360 -b:v 600k -profile:v main -preset veryfast \
-c:a copy \
output.mp4

**Tags:** ffmpeg, rtmp


---

## 1 answers

### Answer by username_0 on 2023-08-17. Score: 0 | Accepted answer

I found a solution on the nginx side by setting the wait\_key and wait\_video options to on in the nginx.conf file.

<https://github.com/dreamsxin/nginx-rtmp-wiki/blob/master/Directives.md#wait_key>


---

