Skip to content

MJPEG over RTSP (RTP/JPEG, RFC 2435) — discussion #119

Closed

Description

@compot-dev

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 is BitmapFactory / ImageDecoder (software, fine for small sizes and low fps, CPU-heavy for 1080p25).

Fit with what exists

Questions to decide

  1. 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.)
  2. 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.
  3. Decoder: MediaCodec video/jpeg first (hardware where present), software fallback — or software only to start?
  4. 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)?
  5. Scope of the first step: single view only, or multi-view from the start?

Rough plan once agreed

  1. RFC 2435 depacketizer + JPEG header reconstruction, unit tests with captured RTP (Q < 128 and Q ≥ 128 with in-band tables, restart markers).
  2. SDP: accept PT 26 / JPEG/90000.
  3. Decode via MediaCodec video/jpeg, fallback to Bitmap; device check on AG-216.
  4. Multi-view + planner integration.
  5. (Optional) HTTP MJPEG slots.

Activity

  1. compot-dev commented on Oct 13, 2026

    @compot-dev
    CollaboratorAuthor

    Decisions (2026-10-13):

    1. Cameras will vary. Bench source: rtsp://<.133>/stream=2 — Majestic serves RTSP MJPEG there.
    2. HTTP MJPEG: wanted, as a separate item → HTTP MJPEG slots (multipart/x-mixed-replace), e.g. http://<camera>/mjpeg #121.
    3. Bandwidth and the missing key-frame mode are understood; few such cameras, but compatibility is needed.
    4. Single view first, multi-view later.

    Status: on hold together with #121.

    Bench check of .133 /stream=2: SDP m=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.

  2. added
    holdOn hold: waiting for a decision
    todayTasks for today
    in progressBeing worked on right now (open PR)
    and removed
    holdOn hold: waiting for a decision
    on Oct 13, 2026
  3. compot-dev commented on Oct 13, 2026

    @compot-dev
    CollaboratorAuthor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions