Question about Content-Auth in mjpeg

Support and queries relating to all previous versions of ZoneMinder
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

Ah right:

Code: Select all

10/18/06 15:49:49.137645 zmdc[27853].INF ['zmc -m 1' started at 06/10/18 15:49:49]
10/18/06 15:49:49.180849 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:49:49, pid = 27853]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:49:49.465609 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:49:49.467578 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:49:49.472731 zmdc[27855].INF ['zmc -m 1' started at 06/10/18 15:49:49]
10/18/06 15:49:49.489099 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:49:49, pid = 27855]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:49:49.752049 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:49:54.053440 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:49:54.058727 zmdc[27858].INF ['zmc -m 1' started at 06/10/18 15:49:54]
10/18/06 15:49:54.063330 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:49:54, pid = 27858]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:49:54.337711 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:50:04.038427 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:50:04.044380 zmdc[27860].INF ['zmc -m 1' started at 06/10/18 15:50:04]
10/18/06 15:50:04.091155 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:50:04, pid = 27860]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:50:04.321081 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:50:24.022436 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:50:24.027750 zmdc[27862].INF ['zmc -m 1' started at 06/10/18 15:50:24]
10/18/06 15:50:24.047103 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:50:24, pid = 27862]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:50:24.304929 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:51:04.006431 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:51:04.011705 zmdc[27867].INF ['zmc -m 1' started at 06/10/18 15:51:04]
10/18/06 15:51:04.018046 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:51:04, pid = 27867]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:51:04.289468 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:52:04.090431 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:52:04.096961 zmdc[27872].INF ['zmc -m 1' started at 06/10/18 15:52:04]
10/18/06 15:52:04.134832 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:52:04, pid = 27872]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:52:04.375503 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:53:04.076432 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:53:04.081781 zmdc[27877].INF ['zmc -m 1' started at 06/10/18 15:53:04]
10/18/06 15:53:04.126093 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:53:04, pid = 27877]
Not a JPEG file: starts with 0x43 0x6f
10/18/06 15:53:04.359001 zmdc[27368].ERR ['zmc -m 1' exited abnormally, exit status 1]
10/18/06 15:54:04.077433 zmdc[27368].INF [Starting pending process, zmc -m 1]
10/18/06 15:54:04.082351 zmdc[27368].INF ['zmc -m 1' starting at 06/10/18 15:54:04, pid = 27882]
10/18/06 15:54:04.086281 zmdc[27882].INF ['zmc -m 1' started at 06/10/18 15:54:04]
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

Looks like 0x43 0x6f is 'Co' it occurs in the following cases:

* Content-Type
* Content-Length
* Content-Auth
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

I think your modified regexp is changing the header match from "boundary to double line endings" to "boundary to two lines terminated with line endings" so it is stopping after the second header line.

Consequently your next header is being included in the image content. One out and out hack you could do to get round this is on the buffer.Consume( subheader_len ) line below. If your extra headers are a fixed length always then just add that length, including any line end chars, to the subheader_len consumed, e.g. buffer.Consume( subheader_len + 37 )

That _might_ work.
Phil
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

Ok, I see the probem now, the old regexpr was counting on presense of empty line as the end of subheader. The new regexpr is only getting 2 lines of subheader...
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

It looks like a bug in the jpeg subheaders of the camera, they miss obligatory extra \r\n...

http://www.axis.com/techsup/cam_servers ... tp_api.htm
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

Ok, I've came up with a good regexp:

Code: Select all

^((?:\r?\n){0,2}?(?:--)?%s\r?\n.+?\r?\n(?:Content.+?\r?\n){0,3}(?:\r?\n)?)
It's based on fact that there must be upto 3 headers that all start with 'Content' and it also tries to make the last empty line optional (workaroudn for non-compliant E-tech). This works very well for my E-Tech Wi-Fi camera (I am getting a mjpeg stream with it right now), unfortunately since I don't have a camera compliant with mjpeg stream so I can't test the empty line at the end of the header.

If somebody could test it - that would be great! Another potential problem is that the 'Content' is case sensitive, I hope all cameras follow the case sensitivity as it's specified in the standard, if not then the RegExpr shoudl be changed from DAT_ALL (or whatever it is) to case insensitive.
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

I still have strange thing happening - exactly once a minute the 3rd line (and once in the logs I found that both 2nd and 3rd are skipped) of the header get's skipped and and I am getting 'not a jpeg file' complaining about Content-Auth getting in jpeg binary content...
Is there anything in thr system that might be happening every minute?
I dont see how this can be happening unless camera puts another 'suprise' in the stream every minute...
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Can you just 'wget' the stream and see if it occurs in there?
Phil
svadu
Posts: 25
Joined: Sun Oct 15, 2006 7:39 pm

Post by svadu »

I'll try to do that at day time. I am more declinign to opinion that the problem is in somethign else because I have situation close to ideal at night time and almost no stable streaming during the day (however my camera is within 10 meters from the router...).
Locked