Welcome! Log In Create A New Profile

Advanced

Nginx Stalls between RTMP Streams

January 14, 2015 01:12PM
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 calls.

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.

Pseudocode:
while true
-> capture X seconds of video to "output.mp4" (this takes less than 300ms)
-> stream the MP4 with FFMPEG (takes ~X seconds using -re)

FFMPEG call:
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 rtmp:/MYSERVER/live/output

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!
Subject Author Posted

Nginx Stalls between RTMP Streams

churchmf January 14, 2015 01:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 99
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready