Page 1 of 1
FosCam FL9820W HD Stream Corruption
Posted: Sun Mar 09, 2014 8:29 pm
by raydude
I'm running wireless. It connects in 802.11G mode. I put it on its own wireless router.
When I stream RTSP to ffplay it works flawlessly. But when I enable it in Zone minder 1.26.5 I get enless motion detection because the stream is smeared like the MPeg4 stream was broken.
I'm going to try an ethernet connection next to see if it really is bandwidth, but I don't think it is.
Any hints, clues or ideas would be greatly appreciated.
Update: it has the same problem with ethernet.
Re: FosCam FL9820W HD Stream Corruption
Posted: Mon Mar 10, 2014 9:17 pm
by mabene
there was a great thread about this issue recently:
http://www.zoneminder.com/forums/viewto ... 30&t=21911
To summarize: Problem is caused by defaulting to UDP transport and losing frames due to insuficient buffering.
Possible Workarounds:
* wait for 1.27.0, use libvlc instead of ffmpeg
* patch zoneminder to request TCP instead of UDP - this is what I did, works flawlessly for me
* depending on your ffmpeg version, appending ?tcp to the src URL might work; not all versions of ffmpeg support this.
Re: FosCam FL9820W HD Stream Corruption
Posted: Tue Mar 11, 2014 2:45 am
by raydude
Unfortunately the sun set while I was trying this out and this cam is not so good in the dark without its IRLEDs. I'll test it in the morning.
I think the ?tcp will work for me, ffplay understands it...
Thanks much for this!
mabene wrote:there was a great thread about this issue recently:
http://www.zoneminder.com/forums/viewto ... 30&t=21911
To summarize: Problem is caused by defaulting to UDP transport and losing frames due to insuficient buffering.
Possible Workarounds:
* wait for 1.27.0, use libvlc instead of ffmpeg
* patch zoneminder to request TCP instead of UDP - this is what I did, works flawlessly for me
* depending on your ffmpeg version, appending ?tcp to the src URL might work; not all versions of ffmpeg support this.
Re: FosCam FL9820W HD Stream Corruption
Posted: Tue Mar 11, 2014 8:56 pm
by raydude
?tcp did not work for me.
However adding the two lines of code before the av_open_input_file has been running for a few minutes with no tearing.
Thanks again for your help. And thanks to dvarapala the guy who figured out the fix.
Here's the change shown in place from file: src/zm_ffmpeg_camera.cpp
Code: Select all
int FfmpegCamera::PrimeCapture()
{
Info( "Priming capture from %s", mPath.c_str() );
// Open the input, not necessarily a file
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0)
if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=$
#else
AVDictionary *opts = 0;
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, NULL ) !=0 )
#endif
Fatal( "Unable to open input %s due to: %s", mPath.c_str(), strerror(er$
Edit: this didn't actually work. I'm still working on the issue. Long story short: don't keep muliple copies of Zoneminder in /usr/src and forget which one you're working on.
PS: anyone know why ZM won't log anymore?
Re: FosCam FL9820W HD Stream Corruption
Posted: Wed Mar 12, 2014 7:50 am
by mabene
raydude wrote:Edit: this didn't actually work. I'm still working on the issue. Long story short: don't keep muliple copies of Zoneminder in /usr/src and forget which one you're working on.
In the code quo quoted, you're missing a final step: you must actually use the option you jjust created:
code below is from 1.27.0 zm_ffmpeg_camera.cpp
Code: Select all
int FfmpegCamera::PrimeCapture()
{
Info( "Priming capture from %s", mPath.c_str() );
AVDictionary *opts = 0;
av_dict_set(&opts, "rtsp_transport", "tcp", 0);
// Open the input, not necessarily a file
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0)
if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, &opts ) !=0 )
#else
if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, &opts ) !=0 )
#endif
notice the change of NULL to &opts as the final argument of the open clls.
Hope this helps.