Nginx Stalls between RTMP Streams
nginx-forum at nginx.us
Wed Jan 14 18:12:44 UTC 2015
Hey NGINX folks,
I'm experiencing some troubles using NGINX as a RTMP media server. I wish to
present a continuous video as a live stream (with up to 60 second latency).
However, due to some hardware constraints, I am unable to stream directly
from the device. Instead, I can save out X amount of seconds from the
device's buffer as an MP4. My solution has been to save X seconds of video
from the device then stream that X seconds, rise and repeat. This has been
working mostly well, except for stalls (~20 seconds) in the stream between
I have searched far and wide for a solution to this however most of the
people experiencing this problem have the collection of videos before
starting the stream and can simply concatenate them.
My running theory is that when a stream finishes, it does an unpublish event
in NGINX followed by a timeout period. This prevents the NGINX server from
receiving the next publish until the timeout period has expired. I have
tried adjusting nginx.config values related to timeouts, respawns, restarts,
and publish, but to no avail.
-> capture X seconds of video to "output.mp4" (this takes less than 300ms)
-> stream the MP4 with FFMPEG (takes ~X seconds using -re)
ffmpeg -re -i "output.mp4" -vcodec libx264 -preset veryfast -maxrate 2000k
-bufsize 4000k -g 60 -acodec libmp3lame -b:a 128k -ac 2 -ar 44100 -f flv
I am using JWPlayer client side to watch the video stream, however I
experience similar issues using VLC.
I have been trying to figure this out for a few days and I would appreciate
any insight an expert to video streaming and NGINX can give. Thank you!
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,256108,256108#msg-256108
More information about the nginx