[BUG] MJPEGEncoder video always shows as 25 FPS
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- embedded-iot
Research direction
Start with the modified examples/dual_encode.py flow, focusing on MJPEGEncoder, FileOutput, and the configured framerate and FrameDurationLimits. Reproduce the issue at 20, 30, and 40 FPS, then compare the recorded frame counts with the FPS reported by OpenCV and ffmpeg; done means the reported FPS matches the configured and observed rate.
Written by the indexing model from the issue text.
Description
Hello
I'm having issues with recording MJPEG videos: No matter what I set the framerate (and sensor FrameDurationLimits) to, the resulting video is always reported as 25 FPS.
I can reproduce this with a slightly modified version of the dual_encode.py example:
"""
https://github.com/raspberrypi/picamera2/blob/main/examples/dual_encode.py
H264 encoding removed
"""
import time
from picamera2 import Picamera2
from picamera2.encoders import MJPEGEncoder
from picamera2.outputs import FileOutput
FPS = 40 # tried with 20, 30, 40 FPS
picam2 = Picamera2()
config = picam2.create_video_configuration({"size": (1280, 720)}, lores={"size": (640, 360)})
picam2.configure(config)
# Limiting exposure time to be sure we don't interfere with the FrameDuration
picam2.set_controls({"ExposureTime": 2000, "AnalogueGain": 1.0})
# Forcing framerate by setting sensor FrameDurationLimits
t_frame_us = round(1e6/FPS)
picam2.set_controls({"FrameDurationLimits": (t_frame_us, t_frame_us)})
mjpeg_encoder = MJPEGEncoder()
mjpeg_encoder.framerate = FPS
mjpeg_encoder.size = config["lores"]["size"]
mjpeg_encoder.format = config["lores"]["format"]
mjpeg_encoder.bitrate = 5000000
mjpeg_encoder.output = FileOutput("out.mjpeg")
mjpeg_encoder.start()
picam2.start()
start = time.time()
while time.time() - start < 5:
request = picam2.capture_request()
mjpeg_encoder.encode("lores", request)
request.release()
mjpeg_encoder.stop()
picam2.stop()
I tried 20, 30 and 40 FPS so far. I know I'm getting the correct framerate, as I'm recording a blinking LED with known on/off period, and I'm getting the right number of frames with the LED on and off. I'm also not getting any dropped frames.
However, both OpenCV and ffmpeg report a FPS of 25.0 for all of them.
Do I misunderstand how to configure the library for this, or is this a bug somewhere?
HW: Compute Module 4
Sensor: OV9281
picamera2: 0.3.30
libcamera: v0.5.1+100-e53bdf1f
OS (uname -a): Linux cm4 6.12.34+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.34-1+rpt1~bookworm (2025-06-26) aarch64 GNU/Linux
Thank you
Felix
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/picamera2
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
raspberrypi/picamera2#1405 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
raspberrypi/picamera2#1404 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 57/100
raspberrypi/picamera2#1403 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
raspberrypi/picamera2#1392 · 13 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
raspberrypi/picamera2#1389 · 4 comments ·
All issues in raspberrypi/picamera2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100