Page 1 of 2

Question about Content-Auth in mjpeg

Posted: Mon Oct 16, 2006 1:05 pm
by svadu
Hi All,

Currently, I am unable to read mjpeg from my cam (see post http://www.zoneminder.com/forums/viewtopic.php?t=7028 ). I checked the header of the stream (via wget) and this is what I get:

--myboundary
Content-Type: image/jpeg
Content-Length: 017354
Content-Auth: 0F45323BCA07027
0xFF 0xD8 0xFF (and other jpeg stuff)

Question to those who is more familiar with the source code: will this header be successfully parsed? The reason I am asking is because I don't see handling of Content-Auth header in the code (and I am not familiar with the sources well enough to draw conclusions). Also this post http://www.lavrsen.dk/twiki/bin/view/Mo ... tAuthPatch has cought my attention (hence the reason I amn posting here).

Posted: Mon Oct 16, 2006 6:57 pm
by zoneminder
ZM should ignore headers that it is not interested in so the presence of Content-Auth should not be an issue.

Posted: Mon Oct 16, 2006 9:59 pm
by svadu
Well I though this was a problem because if I enable debug level=4 I get the following deubg output:

Code: Select all

'HTTP/1.0 200 OK
Cache-Control: no-cache
Content-type: multipart/x-mixed-replace;boundary=--myboundary

']
10/16/06 19:55:16.097391 zmc_m1[19787].DB3-zm_remote_camera.cpp/320 [Got status '200' (OK), http version 1.0]
10/16/06 19:55:16.097694 zmc_m1[19787].DB3-zm_remote_camera.cpp/343 [Got content type 'multipart/x-mixed-replace'
]
10/16/06 19:55:16.097818 zmc_m1[19787].DB3-zm_remote_camera.cpp/347 [Got content boundary '--myboundary']
10/16/06 19:55:16.098015 zmc_m1[19787].DB3-zm_remote_camera.cpp/440 [Unable to extract subheader from stream, retrying]
10/16/06 19:55:16.105681 zmc_m1[19787].DB3-zm_remote_camera.cpp/225 [Expecting 1448 bytes]
10/16/06 19:55:16.105877 zmc_m1[19787].DB3-zm_remote_camera.cpp/250 [Read 1448 bytes]
10/16/06 19:55:16.106618 zmc_m1[19787].DB3-zm_remote_camera.cpp/440 [Unable to extract subheader from stream, retrying] 
I thought it can't parse the header... Strange thing is that WalkGuard plays the stream with no problem... I tried to play the stream with Firefox but instead of getting picture I am getting a string which path to the mjpeg resource (and if I check content type it still shows that it's jpeg) and Firefox contuniously receives the stream (just not displaying it).

Any ideas?

Posted: Mon Oct 16, 2006 10:43 pm
by zoneminder
The unable to parse subheader message is normal, which is why it is just debug. It just means that it has not received enough data to capture and decode the http headers for the image yet, and needs to get more data.

However if that is all you get then something is amiss... Maybe try ZM without regular expressions and see if that makes a difference.

Posted: Mon Oct 16, 2006 11:32 pm
by svadu
I tried both http 1.1 with and without regular expressions and http 1.0 with and without regular expressions. All I am getting is black box with 0 fps.

I have these 'Unable to extract subheader from stream, retrying' for 5 minutes without any other messages (untill I interrupted it myself). It looked like this (in the loop for 5 minutes):

Code: Select all

10/16/06 19:55:16.098015 zmc_m1[19787].DB3-zm_remote_camera.cpp/440 [Unable to extract subheader from stream, retrying]
10/16/06 19:55:16.105681 zmc_m1[19787].DB3-zm_remote_camera.cpp/225 [Expecting 1448 bytes]
10/16/06 19:55:16.105877 zmc_m1[19787].DB3-zm_remote_camera.cpp/250 [Read 1448 bytes] 
Sometimes I am getting this message: "Not a JPEG file: starts with 0x43 0x6f"

I could upload a dump of the stream (got it with wget) if someone can have a 'quick' look... (if it can help)...

Posted: Tue Oct 17, 2006 11:03 am
by zoneminder
Please do.

Posted: Tue Oct 17, 2006 12:23 pm
by svadu
Ok the grabbed video.cgi i slocated at: http://emaps-online.com/temp/video.cgi

And the debug output is located at: http://emaps-online.com/temp/debug1%20-%20broken

Please, let me know if you need more data

Thanks!

Sergei

Posted: Tue Oct 17, 2006 4:16 pm
by zoneminder
I _think_ the problem here is that the cam is not leaving a blank line after the headers but before the image. ZM uses this to detect the end of the subheaders, hence the debug, so it thinks the headers never end.

I'm not quite sure of the best way to address this. I _may_ be able to suggest a patch to ZM to handle this camera but it would be a bespoke fix as it might break other cams.

Posted: Tue Oct 17, 2006 4:38 pm
by svadu
Well I tried another which supposed to work with both:

Old code:

Code: Select all

snprintf( subheader_pattern, sizeof(subheader_pattern), "^((?:\r?\n){0,2}?(?:--)?%s\r?\n.+?\r?\n\r?\n)", content_boundary );
New code:

Code: Select all

snprintf( subheader_pattern, sizeof(subheader_pattern), "^((?:\r?\n){0,2}?(?:--)?%s\r?\n.+?\r?\n.+?\r?\n)", content_boundary );
Then I was getting only few messages then a subheader was read. I was still getting black box and 0 fps...

Imho there is something in JPEG itself that zm can not interpret but the active-x and WalkGuard can.

Regards,
Sergei

Posted: Tue Oct 17, 2006 4:43 pm
by svadu
This is what I was getting with the fix:

Code: Select all

'HTTP/1.0 200 OK^M
Cache-Control: no-cache^M
Content-type: multipart/x-mixed-replace;boundary=--myboundary^M
^M
']
10/16/06 22:11:59.374581 zmc_m1[23788].DB3-zm_remote_camera.cpp/320 [Got status '200' (OK), http version 1.0]
10/16/06 22:11:59.374883 zmc_m1[23788].DB3-zm_remote_camera.cpp/343 [Got content type 'multipart/x-mixed-replace'
]
10/16/06 22:11:59.375006 zmc_m1[23788].DB3-zm_remote_camera.cpp/347 [Got content boundary '--myboundary']
10/16/06 22:11:59.375200 zmc_m1[23788].DB3-zm_remote_camera.cpp/441 [Unable to extract subheader from stream, retrying]
10/16/06 22:11:59.386758 zmc_m1[23788].DB3-zm_remote_camera.cpp/225 [Expecting 1448 bytes]
10/16/06 22:11:59.386966 zmc_m1[23788].DB3-zm_remote_camera.cpp/250 [Read 1448 bytes]
10/16/06 22:11:59.387154 zmc_m1[23788].DB4-zm_remote_camera.cpp/418 [Captured subheader (64 bytes):'--myboundary^M
Content-Type: image/jpeg^M
Content-Length: 003185^M
']
10/16/06 22:11:59.387377 zmc_m1[23788].DB3-zm_remote_camera.cpp/425 [Got subcontent length '3185']
10/16/06 22:11:59.387535 zmc_m1[23788].DB3-zm_remote_camera.cpp/433 [Got subcontent type 'image/jpeg']
10/16/06 22:11:59.432728 zmc_m1[23788].DB3-zm_remote_camera.cpp/225 [Expecting 1448 bytes]
10/16/06 22:11:59.432922 zmc_m1[23788].DB3-zm_remote_camera.cpp/250 [Read 1448 bytes]
10/16/06 22:11:59.467979 zmc_m1[23788].DB3-zm_remote_camera.cpp/225 [Expecting 386 bytes]
10/16/06 22:11:59.468174 zmc_m1[23788].DB3-zm_remote_camera.cpp/250 [Read 386 bytes]
10/16/06 22:11:59.468664 zmc_m1[23788].DB3-zm_remote_camera.cpp/480 [Got end of image by length, content-length = 3185]
10/16/06 22:11:59.468786 zmc_m1[23788].DB3-zm_remote_camera.cpp/537 [Returning 3185 (3232) bytes of captured content]
That looked normal at least to me.

Posted: Wed Oct 18, 2006 9:15 am
by zoneminder
Yes, that looks ok. If there is a problem with the jpeg then it should be reported. Can you view stills with ZM or dump an image using zmu? I assume your cgi settings are correct?

Posted: Wed Oct 18, 2006 10:38 am
by svadu
I can view still only if I view from a still image (/still.jpg). If I set to view mjpeg I also get black box on stills. If I can view stills when I set to grab still images and not mjpeg I assume my cgi-bin is correct (becaus they all use the same path I think).

How can we report the jpeg problem?

Posted: Wed Oct 18, 2006 11:08 am
by zoneminder
Can you post a little more debug after the bit you posted above, perhaps at level 5 if not set already.

Posted: Wed Oct 18, 2006 1:08 pm
by svadu
OK, here is more complete debug (level 5):

http://emaps-online.com/temp/zm_complete_debug.log

I do not see any complains about the Jpegs.

Posted: Wed Oct 18, 2006 1:17 pm
by zoneminder
Thanks. That doesn't look quite right. I suspect zmdc.log will have complaints about jpegs in it possibly? If so can you post it here.