Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


This forum has not been maintained for a long time and will probably get deleted in the near future.
For faster responses to your questions, please use StackOverflow instead and tag your questions with "FFmpeg".
If you need a backup of the posts from this forum, please contact me directly.

RTSP to HLS restream stops with “No more output streams"

Discussions about problems encountered using ffmpeg.
Forum rules
FFmpeg is in a state of perpetual development and we do not currently have the person power to backport fixes to official releases. As such, if you wish to query or report a bug, you must try with the latest development branch revision of FFmpeg to confirm the issue still exists. The latest FFmpeg can be downloaded from here: http://www.ffmpeg.org/download.html

RTSP to HLS restream stops with “No more output streams"

Postby tim1mw » Tue Oct 03, 2017 4:44 pm

I tried putting this on StackOverflow, but got no answer so I'm trying here instead.

I'm trying to do a live restream an RTSP feed from a webcam using ffmpeg, but the stream repeatedly stops with the error:

"No more output streams to write to, finishing."

The problem seems to get worse at higher bitrates (256kbps is mostly reliable) and is pretty random in its occurrence. At 1mbps, sometimes the stream will run for several hours without any trouble, on other occasions the stream will fail repeatedly for several minutes before settling down again. I've got a cron job running which restarts the stream automatically when it fails, but I would prefer to avoid the continued interruptions.

I have seen this problem reported in a handful of other forums, so this is not a unique problem, but not one of those reports had a solution attached to it. My ffmpeg command looks like this:

ffmpeg -loglevel verbose -err_detect ignore_err -bug trunc -r 25 -rtsp_transport tcp -i rtsp://user:password@camera.url/live/ch0 -reset_timestamps 1 -movflags empty_moov+omit_tfhd_offset+frag_keyframe+default_base_moof -bufsize 7168k -stimeout 60000 -hls_flags temp_file+omit_endlist+discont_start -hls_flags temp_file -hls_time 5 -hls_wrap 180 -acodec copy -vcodec copy -muxpreload 15 -muxdelay 15 -start_number 0 streaming.m3u8 > encode.log 2>&1

What gets me is that the error makes no sense, this is a live stream so output is always wanted until I shut off the stream. So having it shut down because output isn't wanted is downright odd. If ffmpeg was complaining because of a problem with input it would make more sense.

I'm running version 3.3.4, which I believe is the latest.

The automatic restart reads the existing m3u8 file to get the hls sequence number and feeds that into ffmpeg using -start_number, this combined with the discont_start flag means that the client manages to keep playing ~50% of the time in the event of an ffmpeg failure, but I would prefer to have a reliable stream instead of having to compensate for the problem with additional code.
tim1mw
 
Posts: 3
Joined: Tue Oct 03, 2017 4:28 pm

Re: RTSP to HLS restream stops with “No more output streams"

Postby tim1mw » Fri Oct 13, 2017 11:33 am

After extensive testing I've established that the error message generated by FFMPEG is very misleading. The error seems to be generated if the data coming in from RTSP is delayed, eg by other activity on the rotuer the camera is connected via. I've got a large buffer and timeout set which should be sufficient for 60 seconds, but I can still deliberately trigger this error with far shorter interruptions, so clearly the buffer and timeout aren't having the desired effect. This might be fixed by setting a QOS policy on the router and by checking that the TCP packets from the camera have a suitably high priority set, it's possible this isn't the case.

However, I would still like to improve the robustness of the input stream if it is briefly interrupted. Is there any way to persuade FFMPEG to tolerate this? Can FFMPG be persuaded to simply stop writing output and wait for input to become available? Or could I get FFMEG to duplicate the last complete frame until it's able to get more data? I can live with the stream stuttering a bit, but I've got to significantly reduce the current behaviour where the stream drops at the slightest hint of a problem.
tim1mw
 
Posts: 3
Joined: Tue Oct 03, 2017 4:28 pm

Re: RTSP to HLS restream stops with “No more output streams"

Postby tim1mw » Tue Oct 17, 2017 10:52 am

After more tests, I've found that the problem actually seems to be that HLS is incapable of coping with a discontinuity in the incoming video stream. If I deliberately cut the network connection between the camera and FFMPEG, FFMPEG will wait for the connection to be re-established for quite a long time. If the interruption was long (>10 seconds) the stream will immediately drop with the "No More Outputs" error the instant that the connection is re-established. If the interruption is short, then RTSP will actually start pulling data from the camera again, but the stream will then drop with the same error a few seconds later. So it seems clear that the gap in the input data is causing the HLS encoder to have a fit and give up once the stream is resumed, but the size of the gap has an impact on whether the drop is instant or not.
tim1mw
 
Posts: 3
Joined: Tue Oct 03, 2017 4:28 pm


Return to ffmpeg

Who is online

Users browsing this forum: Alexa [Bot], Bing [Bot], Yahoo [Bot] and 8 guests