[FFmpeg-devel] MJPEG bug

Michael Niedermayer michaelni at gmx.at
Mon Oct 3 08:15:12 CEST 2011

On Sun, Oct 02, 2011 at 08:40:20PM -0700, Aaron Miller wrote:
> Hello all,
> I am currently working on fixing an apparent bug in FFmpeg's Motion-JPEG
> (mjpeg) codec. I have determined that the codec is looking for JPEG markers
> (0xFF <marker byte>) in the marker payloads.  Occasionally, the two bytes
> 0xFF 0xD8 will happen to occur inside the quantization table for some
> frames, and FFmpeg will treat this as the end of the frame and the start of
> the next one, since it is interpreted as the SOI (start of image) marker.
> 0xFF bytes in marker payloads are not escaped, and so this codec needs some
> way to skip over marker payloads when looking for markers.  The error
> message that results from this is:
>    [mjpeg @ 0x13f4a60] No JPEG data found in image
> I have been trying to implement this by modifying three functions in
> mjpegdec.c (ff_mjpeg_decode_frame, ff_mjpeg_find_marker, and find_marker) to
> handle the marker payloads correctly, but it seems that other code needs to
> be fixed too.  For one problem frame, the buffer in the avpkt structure
> which is passed to ff_mjpeg_decode_frame is just 139 bytes in size, since
> apparently some other code is looking for JPEG markers and truncating or not
> reading the full buffer.  Where might this code be? Where is the avpkt
> produced from the file data?

please provide a sample mjpeg or url of one that fails

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111003/2f9dcb93/attachment.asc>

More information about the ffmpeg-devel mailing list