The canonical way to retrieve an MxPEG stream from the camera is via an HTTP API call like the following:
curl http://<your.camera.ip>/control/faststream.jpg?stream=MxPEG&needlength&fps=6
Replacecurl
with your preferred HTTP agent.
faststream.jpg
These parameters are available for faststream.jpg
(remember, in V2.2.1.4 of the camera software):
Parameter=Default | Values | Explanation |
---|---|---|
help | Help This overview. |
|
stream=full | full MxPEG mxg |
Stream Type Image data in stream: full: full JPEG images MxPEG: MOBOTIX optimized JPEG mxg: MxPEG Clipfile; not server push |
needlength | Need Content-Length Send HTTP content-length for every frame in server push stream. Note: This option is not useful for browsers. |
|
jpheaderupdate=0 | 0..1000 | Frames between tables refreshs Table refresh count. 0: off, 1: every frame, 2: every second frame, ... |
jpheaderrefresh=10 | 0..60 | Seconds between table refreshs Table refresh time. 0: off, 1: every second, 2: every second second, ... |
fps=1 | Escaped string | Frames per Second Frame rate of streamed images: e.g. '3.0' streaming with 3 frames per second. Set to 0 for maximum rate. |
framecount=0 | 0.. | Frame Counter Amount of images delivered before stream stops (0=infinite). |
fip=10.0.0.0 | Escaped string | Factory IP Will only deliver an image if the camera has this factory IP address. |
error=picture | picture empty content current |
Error Handling Sets the error handling options in case no image is available: picture: returns the "No frame available!" image empty: returns nothing content: returns only the content type current: returns the current.jpg image |
html | HTML Page With Stream Output HTML page including stream. |
This table is contained in Chapter 56 ("CGI Parameters of the MOBOTIX camera") of the Reference Manual or in the identical help page http://<your.camera.ip>/help/help?cgi-image#faststream.jpg .
The relevant settings are listed in Section 55.2.19
("Parameters for the mxpegparam
Section") of the Reference
Manual or in the identical help page
http://<your.camera.ip>/help/help?cgi-remotecontrol#mxpegparam :
Control parameters are set by retrieving, e.g.:
http://<your.camera.ip>/control/control?set&quality=80&mxpeg_cyclic=4&mxpeg_minchange=2
The parameters mxpeg_minchange
and
mxpeg_cyclic
are related to the aformentioned update procedure.
mxpeg_minchange
is the threshold (in
percent of change) above which a tile will be included in the next
MxPEG frame.
Setting mxpeg_cyclic
to a value > 0
forces the encoder to include tiles in the MxPEG frame whose
amount of change is below the threshold. It scans through the YUV
image and includes in each unit of time (which is
approx. 1/12.5 s here) mxpeg_cyclic
%
of the unchanged tiles. This means that at a rate of 4 fps
and an mxpeg_cyclic
value of 8 (the default value), an
amount of 12.5/4 * 8% = 25% of the otherwise unchanged tiles will
be transmitted. After one second, all tiles of the complete image
will be included in the transmitted MxPEG frames even if no change
is detected in the image. The same is true for any other frame
rate.
As always, reality is slightly more complicated. The following
tables show the relationship between percentage of MCUs updated
per unit of mxpeg_cyclic
(again, for M10 models):
320x240 (300 MCUs) | ||||||
---|---|---|---|---|---|---|
frames per second (nominal) | seconds per frame (nominal) | % MCUs updated per % cyclic refresh | cyclic needed for full update every second | cyclic needed for full update every frame | frames per second (actual) | seconds per frame (actual) |
0.5 | 2 | 23 | n/a | 4.3 | 0.5 | 2.000 |
1 | 1 | 12 | 8.3 | 8.3 | 1.0 | 1.000 |
2 | 0.5 | 7 | 7.5 | 14.3 | 1.9 | 0.526 |
3 | 0.33 | 5 | 6.5 | 20.0 | 3.1 | 0.323 |
4 | 0.25 | 4 | 5.8 | 25.0 | 4.3 | 0.233 |
6 | 0.17 | 3 | 6.2 | 33.3 | 5.4 | 0.185 |
12 | 0.08 | 2 | 4.6 | 50.0 | 10.8 | 0.093 |
20 | 0.05 | 2 | 2.3 | 50.0 | 21.8 | 0.046 |
640x480 (1200 MCUs) | ||||||
---|---|---|---|---|---|---|
frames per second (nominal) | seconds per frame (nominal) | % MCUs updated per % cyclic refresh | cyclic needed for full update every second | cyclic needed for full update every frame | frames per second (actual) | seconds per frame (actual) |
0.5 | 2 | 23 | n/a | 4.3 | 0.5 | 2.000 |
1 | 1 | 12 | 8.3 | 8.3 | 1.0 | 1.000 |
2 | 0.5 | 7 | 7.5 | 14.3 | 1.9 | 0.526 |
3 | 0.33 | 5 | 6.9 | 20.0 | 2.9 | 0.345 |
4 | 0.25 | 4 | 6.8 | 25.0 | 3.7 | 0.270 |
6 | 0.17 | 3 | 6.0 | 33.3 | 5.6 | 0.179 |
12 | 0.08 | 2 | 4.5 | 50.0 | 11.1 | 0.090 |
For megapixel images, still other values for the % MCU /
mxpeg_cyclic
ratio are in place: it is 9, 5, 3, and 2 for
fps of 0.5, 1, 2 and 4, respectively.
But as a rule of thumb for everyday applications (640x480 or 320x240 resolutions, frame rates above 1 fps) keep in mind:
With the default
mxpeg_cyclic
value of 8, it takes less than a second
until the whole image is restored.
This means that if you want to jump to a certain point in time in the middle of an MxPEG recording, it should be sufficient to go 1 s back in time and keep the tiles coming in. At the specified point in time, the complete image should be available by virtue of cyclic update.
Please note that mxpeg_cyclic
will be
discontinued in future software versions. It will be replaced by a
parameter that is easier to use: You will be able to specify the
time interval within which all tiles are updated cyclically.
With the current MxPEG implementation, there is no way to tell the codec to include a full JPEG frame, say, every second or every 20 frames. Therefore, there's no I-Frame concept known from other codecs. But the way sketched above, jumping back one second and start decoding, may serve as a practical workaround.
Let's close this lengthy section with a brief discussion of
some of the other control
and
faststream.jpg
parameters.
Note: Some parameters may only be set per
camera, i.e., changing them influences every stream that is
retrieved. Examples are size
and quality
. These
settings are changed using control
. Examples for
per-stream settings are fps
and needlength
.
mxpeg_sw2full
(control
parameter) tells the codec which percentage of tiles needs to have
changed in the YUV image before it switches to transmitting full
images without the bitmask.
jpheaderupdate
and
jpheaderrefresh
(faststream.jpg
parameter) tell the codec to regularly include updated tables in
the MxPEG frames. This of course increases the bandwidth/storage
need of the frame.
Note: The Huffman tables are always the same (they don't tend to change with every SW version). The quantization tables depend on the selected JPEG quality. If you change the quality while retrieving a stream, the old tables may not be valid any more. If your application continues to use them there might be visual artifacts.
Finally, needlength
(faststream.jpg
parameter) tells the codec to send
also the content-length
when in stream=MxPEG
mode.
Copyright (c) 2005-2007, MOBOTIX AG. All rights reserved.