RTSP stream reaching EOF
Posted: Thu Mar 06, 2014 5:46 pm
Hello,
I wish to report a bug.
One of the my cameras i use (a Qihan IP-101) supports only streaming video over RTSP. To get that up and running in ZoneMinder i use the "ffmpeg" source-type.
A few times a day the image go red, and it does not come back until i either restart zoneminder, or deactivate+active the monitor.
It seems random as to when the image fails. Sometimes its ok for a day, sometimes it go red after a few seconds. "Normally" though, the image is ok for a few hours.
The log spams
I changed zm_ffmpeg_camera.cpp:219 to:
And the error in the logs is now:
Currently im trying to get the capture daemon to quit itself by changing:
into:
I'm still waiting for the first EOF to see if the code-change has the effect i hope it will have.
Im reporting this before i have any results, because i still think ZoneMinder should handle errors from FFMPEG better than it does now; which is basically to not handle errors at all.
Im also not sure if the correct way to handle the error is to kill the capture daemon; maybe it would be better to just re-open the stream. Im thinking that whatever is the fastest way to get the video back is the best way so i miss as little video as possible.
Oh, and also; a few ppl on the net seems to have similair issues. They seem to fix this by adding "?tcp" to the url to force a TCP-connection. Unfortunately i cannot get a tcp-stream running no matter what i try. Maybe my camera does not do TCP.
I wish to report a bug.
One of the my cameras i use (a Qihan IP-101) supports only streaming video over RTSP. To get that up and running in ZoneMinder i use the "ffmpeg" source-type.
A few times a day the image go red, and it does not come back until i either restart zoneminder, or deactivate+active the monitor.
It seems random as to when the image fails. Sometimes its ok for a day, sometimes it go red after a few seconds. "Normally" though, the image is ok for a few hours.
The log spams
I am using ZoneMinder 1.26.5, and ffmpeg:Unable to read packet from stream 0: error -541478725.
Code: Select all
ffmpeg -version
ffmpeg version 2.0.2
built on Oct 27 2013 11:01:22 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Code: Select all
Error( "Unable to read packet from stream %d: error %d. avErrorString: %s", packet.stream_index, avResult, av_err2str(avResult) );
Some googling suggests that there is no point in trying to read more frames; however this is what ZoneMinder does.ERR [Unable to read packet from stream 0: error -541478725. avErrorString: End of file]
Currently im trying to get the capture daemon to quit itself by changing:
Code: Select all
int avResult = av_read_frame( mFormatContext, &packet );
if ( avResult < 0 )
{
Error( "Unable to read packet from stream %d: error %d.", packet.stream_index, avResult );
return( -1 );
}
Code: Select all
int avResult = av_read_frame( mFormatContext, &packet );
if ( avResult < 0 )
{
if (avResult == AVERROR_EOF || (mFormatContext->pb && mFormatContext->pb->eof_reached))
{
Fatal("Current stream reached EOF.");
}
Error( "Unable to read packet from stream %d: error %d. avErrorString: %s", packet.stream_index, avResult, av_err2str(avResult) );
return( -1 );
}
Im reporting this before i have any results, because i still think ZoneMinder should handle errors from FFMPEG better than it does now; which is basically to not handle errors at all.
Im also not sure if the correct way to handle the error is to kill the capture daemon; maybe it would be better to just re-open the stream. Im thinking that whatever is the fastest way to get the video back is the best way so i miss as little video as possible.
Oh, and also; a few ppl on the net seems to have similair issues. They seem to fix this by adding "?tcp" to the url to force a TCP-connection. Unfortunately i cannot get a tcp-stream running no matter what i try. Maybe my camera does not do TCP.