Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MJPEG Stream Information

I am receiving a MJPEG Stream from my camera. When I look at the video data with an hex editor it seems that it doesn't contain any streaming information. I just see one raw JPEG after another, but no information about the framerate etc. .

Is the lack of any meta information normal for MJPEG or is it just related to the camera I am using? If there a no information about the stream, how can a player know how fast to play the video?

like image 556
Toby Avatar asked May 17 '12 08:05

Toby


People also ask

What is an MJPEG stream?

Motion JPEG or MJPEG is basically a stream of JPEG images transmitted over https protocol. Nowadays it is commonly being used for many multimedia applications, especially in digital cameras, IP cameras, and webcams.

What is MJPEG used for?

Motion JPEG (M-JPEG or MJPEG) is a video compression format in which each video frame or interlaced field of a digital video sequence is compressed separately as a JPEG image.

Is MJPEG the same as mp4?

Unlike M-JPEG, MPEG4 is a licensed standard. DVRs, IP cameras and other surveillance products must pay a license fee for each channel of video that uses MPEG4 technology. In terms of compression, MPEG4 supports low bandwidth applications that require decent quality images.


2 Answers

The lack of metadata is normal. IP Cameras typically send MJPEG as just that, one JPEG image after another as a stream. This is the most basic valid MJPEG file. If you were to take a bunch of jpegs, cat them together into a large, giant file, and feed it to ffmpeg, it would see it as a valid mjpeg format file. Some cameras will add an additional header to contain audio data, but it is not needed to be considered valid motion jpeg.

Many cameras will include a header like X-Framerate, in the HTTP header when the stream is initially sent, or you can set it as part of the camera configuration. However, when a camera sends only jpegs, there is no way to tell from the stream itself what the framerate is.

like image 181
Arcane Avatar answered Oct 18 '22 09:10

Arcane


Is the lack of any meta information normal for MJPEG or is it just related to the camera I am using? If there a no information about the stream, how can a player know how fast to play the video?

To add to already answered, IP camera is a live video source and frames are typically presented as soon as they arrive from camera. Rare IP camera attaches extra per frame information other than fame size (some don't do even this! they send data and separators only). Still some do attach time stamps and extra data like motion detection state.

Most of the IP cameras don't do constant frame rate. That is, frame rate might vary, esp. lower down in low light conditions. It is the responsibility of the receiving side to attach per frame time stamps when multiplexing the data into container format. Time stamp might be recovered from metadata (which rarely exists) or - more frequently - receiver stamps a frame with local receive time.

This is the way for the player to play back video sequence in proper rate. Live feed is typically presented on "show received frame as soon as possible" basis.

like image 44
Roman R. Avatar answered Oct 18 '22 07:10

Roman R.