Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8597

Graphics, sound and multimedia • Compute Module 4/5 MJPEG HW Acceleration?

$
0
0
Hello, I am working a project that in the simplest terms is taking a fast to decode format from a camera then doing some operations to the image and serving a MJPEG stream over HTTP.

I am running into an issue that the MJPEG performance seems extremely poor, I found that the CM4 stuggled to decode a MJPEG stream from a camera at anything faster then 1920x1080@8fps When piping the input directly to the output I can confirm the sensor is capable of providing a much faster framerate of 60fps easily.

I decided to pivot to decoding using another format which can "decode" the rg24 frames in the micro seconds (it more just importing the data to a struct) I apply my operations then convert back to MJPEG but the issue is the same on the encoder side of less then 8fps, the MJPEG encoding takes around 150-180ms per frame using ffmpeg mjpeg, my framerate is set to 30fps but I have suspicions that its using software encoding.

Some notes about my setup:
  • I am not using OpenCV, gstreamer or picam
  • I am using libcamera, v4l2 and ffmpeg
  • The input resolution is 1920x1080 and is not being upscaled by ffmpeg
  • The sensor is capable of 1920x1080@60fps and it can do that in the MJPEG format, as well as the rg24 format
  • I have confirmed the timings of the frames coming the from the sensor and it is not the bottleneck.
  • I have confirmed the timings of the decoder and it is not the bottleneck
  • I have confirmed the timings of my operations and it is not the bottleneck
  • I have confirmed the timings of the encoder and it is the bottleneck
My reasons for why I think ffmpeg is software encoding is that it does not report in the logs that it is using a specific /dev/video* and the cpu util spikes.

I have tried looking online and asking AI to get a straight answer of:

Is there a hardware accelerated mjpeg encoder on the compute module 4/5?

I have seen both answers several times on this forum but its more people indirectly answering this question, so I am here to ask it directly.

Does the compute module 4/5 have a hardware accelerated MJPEG encoder?
  • If so what is the specs of it, can it handle 1920x1080@30/60fps and how do I enable it?
  • If not what are other people doing to get good MJPEG performance? I see other people mentioning projects they are using it in and I cant help but feel I am doing something wrong or these people are leaving out crucial information about their pipeline.

Lastly if all else fails does the H264 encoder actually live up to the spec of 1080x1920@30fps? or is there a draw back like it can not convert a raw format like rg24 to h264 fast

Statistics: Posted by sozo_ — Fri Jun 20, 2025 10:15 am



Viewing all articles
Browse latest Browse all 8597

Trending Articles