Lior Ohana
Lior Ohana

Reputation: 3527

FFMpeg crashes on decoding MJpeg

I'm working with FFMpeg for decoding Mjpeg streams. Recently I've bumped into access violation exceptions from FFMpeg, after investigating, I found that due to network packet drops, I'm passing to the FFMpeg a frame that might have "gaps" in it. The FFMpeg probably crash since it jumps to a marker payload which doesn't exist in the frame's memory.

Any idea where I can find a mjpeg structure validator? Is there any way to configure FFMpeg to perform such validations by itself?

Thanks.

Upvotes: 1

Views: 1026

Answers (2)

enthusiasticgeek
enthusiasticgeek

Reputation: 2736

I would be inclined to use Gstreamer here instead of ffmpeg and set "max-errors" property in jpegdec plugin to -1.

gst-launch -v souphttpsrc location="http://[ip]:[port]/[dir]/xxx.cgi" do-timestamp=true is_live=true ! multipartdemux ! jpegdec max-errors=-1 ! ffmpegcolorspace ! autovideosink.

This takes care of the corrupt jpeg frames and continues the stream.

Upvotes: 1

Lior Ohana
Lior Ohana

Reputation: 3527

Didn't really found an answer to the question. Apparently, ffmpeg doesn't handle corrupted frames very well. Decided to try a different 3rd party decoder instead of ffmpeg. For now, at least for Jpeg, it works faster and much more robust.

Upvotes: 0

Related Questions