Opened 6 years ago

Last modified 4 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

Description

Can you add the MJPEG input to MMAL decoder ?

https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/mmaldec.c

Line 376 I can't see the MJPEG format :

switch (avctx->codec_id) {
case AV_CODEC_ID_MPEG2VIDEO:

format_in->encoding = MMAL_ENCODING_MP2V;
break;

case AV_CODEC_ID_MPEG4:

format_in->encoding = MMAL_ENCODING_MP4V;
break;

case AV_CODEC_ID_VC1:

format_in->encoding = MMAL_ENCODING_WVC1;
break;

case AV_CODEC_ID_H264:
default:

format_in->encoding = MMAL_ENCODING_H264;
break;

}

(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:(

Thanks

Change History (3)

comment:1 by Carl Eugen Hoyos, 5 years ago

Keywords: mmal added
Priority: normalwish

comment:2 by nls, 4 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, 4 years ago

I haven't yet checked how to submit ffmpeg patches, but I've added MJPEG support with this patch https://github.com/lgeek/FFmpeg/commit/10a7ccaceb5. 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): https://github.com/lgeek/FFmpeg/commit/4fcb83f2aa2b1d2e

Note: See TracTickets for help on using tickets.