Repository navigation
MJPEG over RTSP (RTP/JPEG, RFC 2435) — discussion #119
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Description
Goal: play a camera whose RTSP stream is MJPEG instead of H.264/H.265 (SDP m=video … RTP/AVP 26, a=rtpmap:26 JPEG/90000). To be discussed before implementation.
Is it possible? Yes
- Transport side. RTP/JPEG (RFC 2435) is a simple payload: every packet carries an 8-byte JPEG header (fragment offset, type, Q, width/8, height/8), optional restart-marker and quantization-table headers (Q ≥ 128), then a piece of the scan data. A frame ends with the RTP marker bit. The receiver rebuilds a complete JPEG (SOI, DQT from the tables in the stream or from Q via the standard tables, SOF0 from type/size, DHT standard tables, DRI if present, SOS, the data, EOI). No SPS/PPS, every frame is a key frame.
- Decoding side. The AG-216 has a hardware MJPEG decoder:
OMX.allwinner.video.decoder.mjpeg(video/jpeg) in its codec list. Elsewhere a fallback isBitmapFactory/ImageDecoder(software, fine for small sizes and low fps, CPU-heavy for 1080p25).
Fit with what exists
- Single view and multi-view:
RtspSessionalready passes RTP packets per channel; aJpegAssemblernext toNalAssemblerwould produce whole frames;MediaCodecManagerwould be created forvideo/jpeg(or a Bitmap path draws to the Surface). - Multi-view planner (Multi-view: adaptive decoding — full rate or key frames per cell, learnt device capacity #85): MJPEG has no "key frames only" mode — every frame is independent, so the cheap mode would be decode every N-th frame (frame skipping is trivial). Load per frame is higher than H.264 P-frames.
- Bandwidth: MJPEG 1080p is roughly 5–15× the bitrate of H.264 at similar quality; on Wi‑Fi this matters, on the lab Ethernet not.
- Audio is unaffected.
udp://slots (feat: receive plain RTP from Majestic outgoing over UDP, unicast and multicast (#68) #72) could take PT 26 the same way.
Questions to decide
- Which cameras / why? Which devices only (or preferably) give MJPEG over RTSP — old IP cameras, USB-to-RTSP bridges, encoders without H.264, a substream? Is there one we can put on the bench? (OpenIPC/Majestic serves MJPEG over HTTP at
/mjpeg,multipart/x-mixed-replace, checked on.133/.126; whether its RTSP can carry MJPEG needs checking.) - HTTP MJPEG too? Should a slot also accept
http://<cam>/mjpeg(multipart)? It is even simpler (whole JPEGs, no RTP) and works with every OpenIPC camera today. - Decoder: MediaCodec
video/jpegfirst (hardware where present), software fallback — or software only to start? - Multi-view budget: how should MJPEG cells count in the Multi-view: adaptive decoding — full rate or key frames per cell, learnt device capacity #85 planner (frame skipping instead of key frames)?
- Scope of the first step: single view only, or multi-view from the start?
Rough plan once agreed
- RFC 2435 depacketizer + JPEG header reconstruction, unit tests with captured RTP (Q < 128 and Q ≥ 128 with in-band tables, restart markers).
- SDP: accept PT 26 /
JPEG/90000. - Decode via MediaCodec
video/jpeg, fallback to Bitmap; device check on AG-216. - Multi-view + planner integration.
- (Optional) HTTP MJPEG slots.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Activity
compot-dev commentedon Oct 13, 2026
Decisions (2026-10-13):
rtsp://<.133>/stream=2— Majestic serves RTSP MJPEG there.Status: on hold together with #121.
Bench check of
.133 /stream=2: SDPm=video 0 RTP/AVP 26,a=rtpmap:26 JPEG/90000,a=framerate:5, plus Opus audio (PT 98). A 6 s capture over TCP: 3084 RTP packets, 29 frames (≈5 fps), ≈5 Mbit/s; every packet: JPEG type 0 (RFC 2435: YUV 4:2:2), Q = 255 (quantization tables in-band, so the Q ≥ 128 path with a quantization-table header is required), 1280×720, no restart markers. Capture kept on the lab host for unit-test fixtures.test: MJPEG is a supported video track now; VP8 stands for an unsuppo…
Merge pull request #131 from OpenIPC/feat/mjpeg-rtsp
compot-dev commentedon Oct 13, 2026
Done for the single view in #131 (RTP/JPEG per RFC 2435, checked with
.133 /stream=2:Connected • TCP • MJPEG • Opus • 5.1 Mbps). Hardware decoding and multi-view continue in #132; HTTP MJPEG is #121 (on hold).feat: MJPEG over RTSP (RTP/JPEG, RFC 2435) in the single view (#119)
test: MJPEG is a supported video track now; VP8 stands for an unsuppo…
Merge pull request #131 from OpenIPC/feat/mjpeg-rtsp