Opened 5 years ago

Last modified 3 years ago

#7355 new enhancement

No MJPEG input with MMAL decoder

Reported by: Serveurperso Owned by:
Priority: wish Component: avcodec
Version: git-master Keywords: mmal
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Can you add the MJPEG input to MMAL decoder ?

Line 376 I can't see the MJPEG format :

switch (avctx->codec_id) {

format_in->encoding = MMAL_ENCODING_MP2V;


format_in->encoding = MMAL_ENCODING_MP4V;


format_in->encoding = MMAL_ENCODING_WVC1;

case AV_CODEC_ID_H264:

format_in->encoding = MMAL_ENCODING_H264;


(From 6by9 on rpi-firmware)

"The Pi supports hardware accelerated MJPEG via IL or MMAL, but FFMPEG doesn't.
Having said that, the MMAL decoder would probably only need a half-dozen lines of code added to support it, mainly setting up format_in->encoding in ffmmal_init_decoder, and a FFMMAL_DEC definition at the end of the file. (libavcodec/mmaldec.c).
I'm not sure how well FFMPEG differentiates between MJPEG and JPEG, so there may be minor issues. A couple of ffmpeg-dev list posts recently have been about adding some MJPEG codecs and were discussing it."

I'm free to make any testing for you on my ready Raspberry PI + MJPEG capture hardware. I run 24/7 with FFMpeg git-master and raw YUYV but there is few USB2 bandwitch problem:(


Change History (3)

comment:1 by Carl Eugen Hoyos, 4 years ago

Keywords: mmal added
Priority: normalwish

comment:2 by nls, 3 years ago

With the rise of ultra cheap (real) full HD/4k MJPEG USB capture devices in recent months, this request has gained real significance. It would be very useful to be able to use ffmpeg with them on Raspbery Pi SBCs. I know the OMX interface has long been deprecated but if it's not a big work, it might well worth implementing this addition. Currently gstreamer is the only tool capable of doing it, but it's pretty wonky and cryptic to use, and not exactly stable.

comment:3 by lgeek, 3 years ago

I haven't yet checked how to submit ffmpeg patches, but I've added MJPEG support with this patch For decoding directly from a v4l2 device I've also had to implement this, otherwise it only works when ffmpeg is launched for the first time after a reboot (it looks like the first frame read on subsequent executions is invalid, which the current logic in mmaldec doesn't like):

Note: See TracTickets for help on using tickets.