[FFmpeg-devel] MJPEG bug

Aaron Miller amiller at atlasdigital.tv
Mon Oct 3 05:40:20 CEST 2011


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?

Thank you,

Aaron Miller


More information about the ffmpeg-devel mailing list