Low FPS With JPG Streaming IP Camera

Support and queries relating to all previous versions of ZoneMinder
Locked
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Low FPS With JPG Streaming IP Camera

Post by Hex »

Hey, guys,

Not sure if I used the right terminology in the title, but the problem comes when using my IP camera with ZM.

The camera outputs a direct <IP>/image.jpg, but when viewed in ZM the FPS is much slower than when viewed directly in the camera's webserver.

There is no consistent way to measure the difference in FPS that I can think of, but in 320x240 I get about 15-25 fps (eye-measuring here!) and in ZM I get 5 fps.

ZM is running on an AMD64+ with 1GB RAM (Ubuntu) and only this camera attached (no other CPU consuming processes). Any ideas why I get such slow FPS?
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

First help us out a bit here, whats the camera :?:
Whats your settings for the cam in ZM :?:

My guess would be that your using jpeg snapshot mode of the cam so ZM has to request each image from the camera.
Ideally you want to do a mjpeg server push if the cam is;
  • 1: Capable of it.
    2: It outputs a compliant mjpeg standard.
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Post by Hex »

Thank you from replying cordel - I see you are the guru on the forum, so I really appreciate it.
First help us out a bit here, whats the camera?
That would be interesting for me as well - bought it from a Chinese website as IP-400, but then discovered it on the net as LTI-510.
My guess would be that your using jpeg snapshot mode of the cam so ZM has to request each image from the camera.
You are absolutely right. The camera is listed as MJPEG capable, but I am using the direct path to a jpg file, so ZM has to request each image from the camera. I am already searching through the forum for info on that, but can you throw in a couple of links or explain what url I should be ideally looking for?
Whats your settings for the cam in ZM?
Source type - Remote
Function - Modect
MaxFPS - 10 (actually getting 5 fps in 320x240 and 2 fps in 640x480)
Alarm Max Fps - 30 (again, 5 fps in 320x240 and 2 fps in 640x480)
Remote hostname - 192.168.2.20 (click here for port forwarded url)
Remote host port - 80
Remote host path - /image.jpg
Remote image colors - 24bit
Width&Height - 640x480
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Usually you are looking for a cgi script in the cam. If you going to be around for a bit I might be able to help you out. I would start with firefox and view the cam directly. On the streaming image right click and select properties, it will show you the source path to the cgi hopefully.
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Post by Hex »

Thanks :)

You should be able to view the camera yourself from the link I've provided. Here it is again.

The direct link from the image is:
<IP>/image.jpg?cachebust=1579693&a=0
The value of cachebust changes, but the javascript used for that is available in one of the page sources on the camera's webserver.


When I click "Snapshot" I get:
<IP>/image.jpg (which is what I am currently using in ZM)

And I also experimented and found out that:
<IP>/cgi-bin/
Outputs some sort of stream that I can keep downloading infinitely (but I have to hit F5 a couple of times for the stream to start downloading, otherwise I see an image). Firefox interprets it as "application/octet-stream". I suppose this is the stream we are looking for, but how to use it? When entering /cgi-bin/ in the Path settings, the fps remain the same.

Maybe it's worth mentioning that I am using Firefox. Camera doesn't use ActiveX (tried it in IE too).
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

The script in the camera does not appear to do mjpeg, it fetches an image just like ZM for the most part.

Code: Select all

<SCRIPT>var isopen = 1174975860;
var timerval=60;
function loadnextimage()
{
isopen++;
tmpimage.src="image.jpg?cachebust="+isopen+"&a=0";
}
function setuptimer()
{
setTimeout("loadnextimage()", timerval);
}
var isopen=Math.round(1000000+(Math.random() * 1000000)); tmpimage = new Image(); var first = 1;
function doimage()
{ document.images.webcam.src=tmpimage.src;
setuptimer();
}
function firstimage()
{ if (first == 1)
{
first=0; isopen++; tmpimage.onload=doimage; tmpimage.onerror=doimage; tmpimage.src="image.jpg?cachebust="+isopen+"&a=0";
}
}
document.write('<A><IMG></A>');
</SCRIPT>
So unless there is a setting in the admin panel to switch from jpeg to mjpeg, my guess would be that this cam is not capable of a mjpeg server push, meaning it don't do mjpeg.
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Post by Hex »

That's the script I was referring to, yes. But it still doesn't explain why I get higher fps in the cam's webserver than I do in ZM, which is strange.

Did you take a look at the stream it outputs when using:
<IP>/cgi-bin/

Try hitting F5 three-four times to see what I mean:
http://r02.no-ip.org:8090/cgi-bin/

Haven't found an admin panel so far, it's controlled through a win app, which searches for all available cams on the network and then sends settings to them. Professional!

Thank you for being so helpful, cordel!
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

That's interesting it asks to save a bin file and that bin resembles a badly formatted mjpeg stream.

Code: Select all

Connection: Keep-alive
Content-Length: 06813
Content-Type: image/jpeg
Server: uicam2.2          username=001abkx&userpwd=0012778267        alarm=11111111 status=00000000
Cache-control: no-cache
Unfortunately that will not work with ZM as a mjpeg stream because it's not mjpeg standards compliant.
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Post by Hex »

I see that it uses uicam as an http server. Maybe it's worth digging something there. If I find something I will post.

Thanks again for the excellent support. It's good that you placed GGL ads on the forum :)
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Post by Hex »

Ok, using ffmpeg I've been able to determine that the camera's stream is mjpegb (yuvj422p). Two questions:

1. What is the mjpeg stream format used by ZoneMinder?
2. Will it work if I have ffmpeg convert the stream for Zoneminder to read? Any ideas how to implement this?

Thank you again (and I believe I am saying that to cordel again, lol).
mikepont
Posts: 6
Joined: Mon Apr 07, 2008 9:28 am
Location: Brisbane Australia

Chinese IP-400

Post by mikepont »

Hi,

Just wondered if Hex had any luck with getting this camera going with MJPEG.

I see this camera advertised out of Hong Kong for $60
http://www.dealextreme.com/details.dx/sku.15974

A guy in Russia has reviewed it and written some Perl scripts to fix the unstandard stream format here http://kuklin.ru/ip400cam/tools/

I wonder if these could be used to somehow make this cam compatible with ZM?

Regards,
Hex
Posts: 14
Joined: Sat Jan 31, 2009 4:16 pm

Post by Hex »

I've found that using ffmpeg with the latest version of ZoneMinder is a somewhat better choice than using static jpegs - at 640x480 I get 4 fps at night and 8 fps during the day. In Windows this camera is capable of a little more fps, so I believe there's room for improvement.

Concerning the scripts, which I was also aware of, there are two - one outputs a succession of static jpegs (consecutively numbered), while the other outputs a standard mjpeg stream. If someone reading this thread knows how to make ZoneMinder read static jpegs or an mjpeg stream from stdin or a file, it'd be of great help.

I've also tried to contact the author of the scripts, but he didn't reply.
86turbodsl
Posts: 2
Joined: Thu Jan 28, 2010 5:46 pm

Post by 86turbodsl »

Hello, I think I just bought one of these cameras from an ebay seller. What do you think is the likelyhood of a firmware update to commonize the mjpeg ouptut? Seems that lots of chinese factories are making these, I can't imagine they are using any custom http server software.

<edit>
I got my cam. It actually works quite well with zoneminder. I typically don't capture 30fps, so just setting it to capture IP/image.jpg works nicely and does a decent job on alarm events. Not bad for only $60. Nice form factor too. I think I'll pickup a few more for around the house.
Locked