Skip to content

Codec selection (Auto / H.264 / HEVC) and automatic decoder fallback #59

Open

Description

@ehbstudentadam

Summary

It would be useful if the Punktfunk web client allowed users to select their preferred video codec (H.264 or HEVC/H.265), with an Auto mode that chooses a codec the browser can actually decode.

Ideally, the client would also handle decoder initialization failures by retrying with a compatible option instead of displaying a black screen.

Why this would help

I encountered persistent black screens while streaming from Punktfunk to a Chromium-based browser on Linux.

My setup:

  • Host: Punktfunk 0.45.0 on Kubuntu 26.04.1
  • Host GPU: AMD RX 6600, headless KDE Wayland
  • Client: Helium (Chromium-based), CachyOS Linux
  • Client GPU: NVIDIA RTX 3080 Laptop GPU
  • Browser client: Docker image from October 26, 2026

What happened

Initially, Punktfunk selected H.264:

punktfunk-web: session live, codec 1 at 1920x1080

The browser attempted to configure WebCodecs with:

{
  codec: "avc1.42E01F",
  codedWidth: 1920,
  codedHeight: 1080,
  optimizeForLatency: true,
  hardwareAcceleration: "prefer-hardware"
}

However, the browser reported:

prefer-hardware: false
prefer-software: true
no-preference: true

This resulted in:

OperationError: Unsupported configuration.
Check isConfigSupported() prior to calling configure().

Temporarily forcing prefer-software made the H.264 stream work.

I subsequently enabled the experimental NVIDIA VA-API hardware-decoding path in Chromium. Hardware H.264 support became available, but I still encountered black screens and a kUnsupportedConfig error when Chromium attempted to select its VA-API decoder.

Later, Punktfunk streamed HEVC:

punktfunk-web: session live, codec 2 at 1728x1600
codec: hev1.1.6.L153.B0
hardwareAcceleration: prefer-hardware

That stream worked successfully with NVIDIA hardware decoding.

Since I also changed Chromium's hardware-decoding configuration during testing, I cannot confirm that switching the codec alone would have solved the original problem. However, the experience shows why codec selection and decoder compatibility handling would be valuable.

Suggested improvements

  1. Manual codec selector

    • Auto (recommended)
    • H.264
    • HEVC / H.265
    • Additional codecs if supported in the future
  2. Automatic compatibility detection

    • Check browser decoding support using VideoDecoder.isConfigSupported() for the actual configuration.
    • Consider both host encoding capabilities and browser decoding capabilities.
    • Prefer hardware decoding when it is supported and working.
    • Fall back to another supported codec or software decoding when necessary.
  3. Recovery from runtime decoder failures

    • isConfigSupported() can report support even when actual decoder initialization fails.
    • Handle initialization and decoding errors gracefully.
    • Retry a compatible configuration where possible, or show an actionable error rather than leaving the screen black.
  4. Display the active stream codec

    • Show which codec is actually being streamed.
    • Ideally indicate whether hardware or software decoding is active, when reliably detectable.

Expected result

Users should be able to select a codec appropriate for their browser and GPU, or let Punktfunk choose automatically.

The goal is reliable, low-latency streaming without requiring users to modify browser launch flags, inspect WebCodecs errors, or manually override decoder configuration in Developer Tools.

Thank you for considering this improvement!

Activity

  1. enricobuehler commented on Oct 30, 2026

    @enricobuehler
    Member

    Thanks for the detailed report; it pointed at two real gaps.

    Already there when you tested: Settings → Video codec (Automatic / HEVC / AV1 / H.264) has been in the page since v0.2.0. And v0.3.1 (2026-10-27, the day after your image) added the fallback from prefer-hardware to no-preference when configure() refuses, which covers the Unsupported configuration you hit on H.264.

    What was still missing, merged in #67:

    • When isConfigSupported() says yes to hardware but configure() then fails (your VA-API kUnsupportedConfig), the rebuild tried hardware first again, twice a second, for good: a black screen. It now moves past the acceleration that failed, through no-preference to prefer-software.
    • A configure() that throws synchronously escaped the error path. It no longer does.
    • When a codec can't be decoded under any acceleration, the page drops it from its offer and reconnects, so the host picks the next codec it has (HEVC in your case) instead of the stream ending. A one-line notice says so.
    • The stats overlay's decoder line now reads WebCodecs, hardware or WebCodecs, software when the page knows which it got.

    This is on main and in the next edge image, and will be in the next release.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions