Hi, On Thu, Oct 17, 2024 at 8:38 AM Cynthia via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote: > From d7863bab8e1028b6cfb3ce848e216e86ff00eca0 Mon Sep 17 00:00:00 2001 > From: cynthia2006 <cynthia2...@proton.me> > Date: Tue, 28 May 2024 22:03:50 +0530 > Subject: [PATCH] lavc/mjpegdec: add option for ignorning malformed APPx > segments > X-Unsent: 1 > To: ffmpeg-devel@ffmpeg.org > > A few cameras, namely Logitech C270 or similar produce MJPEG frames containing > malformed APP0 chunks, and as a result of which, FFmpeg spams stdout with > > "[mjpeg @ 0xcoffeebabe] unable to decode APP fields: Invalid data found when > processing input" > > The issue is explained in full-detail here: > https://stackoverflow.com/q/55439184. > TL;DR The second APP0 chunk is the culprit here. > > Issue is mitigated if those segments are ignored. This patch adds a MJPEG > decoder private > option `-allow_malformed_app` which if enabled, ignores those malformed APP0 > segments.
I took a different approach where, instead of adding a new option, I just silently ignore APPx stubs. I'll send my patches in a while. > Signed-off-by: cynthia2006 <cynthia2...@proton.me> > --- > libavcodec/mjpegdec.c | 5 +++++ > libavcodec/mjpegdec.h | 1 + > 2 files changed, 6 insertions(+) > > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c > index 1481a7f285..b1e26044c0 100644 > --- a/libavcodec/mjpegdec.c > +++ b/libavcodec/mjpegdec.c > @@ -1863,6 +1863,9 @@ static int mjpeg_decode_app(MJpegDecodeContext *s) > av_log(s->avctx, AV_LOG_WARNING, "skipping APPx (len=%"PRId32") > for bayer-encoded image\n", len); > skip_bits(&s->gb, len); > return 0; > + } else if (s->allow_malformed_app) { > + skip_bits(&s->gb, len); len is in bytes, so this call to skip_bits() is not correct. I know it's the same as in the existing code above, but that should be fixed as well. > + return 0; > } else > return AVERROR_INVALIDDATA; > } _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".