Skip to content

capture(wayland): fix black screen and pts timing on gst-launch#9

Open
domenkozar wants to merge 1 commit into
omarroth:mainfrom
domenkozar:go-gst-capture
Open

capture(wayland): fix black screen and pts timing on gst-launch#9
domenkozar wants to merge 1 commit into
omarroth:mainfrom
domenkozar:go-gst-capture

Conversation

@domenkozar

@domenkozar domenkozar commented Jun 24, 2026

Copy link
Copy Markdown

Keep the gst-launch CLI for the Wayland portal path, but fold in two fixes found while prototyping a go-gst version:

  • vapostproc ! video/x-raw,format=I420 imports the portal's DMA-BUF via VA-API (plain videoconvert fails to negotiate DMA-BUF on many drivers) and forces 4:2:0. RGB screens otherwise make x264enc emit "High 4:4:4 Predictive", which most receiver decoders reject (black screen).
  • videorate drop-only=true skip-to-first=true ! framerate caps re-stamps buffers onto a regular fps timeline; the portal can deliver pts=0, which confuses encoder/muxer timing.

No new dependencies — the build stays pure Go (no CGO); GStreamer is still only invoked as the gst-launch-1.0 external binary.

Verified end-to-end: mirrors a Wayland desktop to a non-Apple AirPlay 2 receiver (Hisense), yuv420p, no crash.

@domenkozar domenkozar marked this pull request as draft June 24, 2026 15:29
@domenkozar domenkozar marked this pull request as ready for review June 24, 2026 16:28
@domenkozar

Copy link
Copy Markdown
Author

@omarroth this is ready for review when you have a moment.

It swaps the gst-launch subprocess for the go-gst library and fixes the black-screen issues on modern Wayland/Mesa (DMA-BUF import via vapostproc, 4:2:0 I420, PTS re-stamp). It also fixes two in-process cgo crashes that the CLI path never hit: a missing gst.Init() (segfault in gst_parse_launch) and an appsink SetCallbacks use-after-free (now a blocking PullSample loop).

Verified end-to-end mirroring a niri desktop to a non-Apple AirPlay 2 receiver (Hisense), yuv420p, no crash. Happy to adjust anything.

Keep the gst-launch CLI for the Wayland portal path, but fold in two fixes:

  - vapostproc ! video/x-raw,format=I420 imports the portal's DMA-BUF via
    VA-API (plain videoconvert fails to negotiate DMA-BUF on many drivers)
    and forces 4:2:0 — RGB screens otherwise make x264enc emit "High 4:4:4
    Predictive", which most receiver decoders reject (black screen).

  - videorate drop-only=true skip-to-first=true ! framerate caps re-stamps
    buffers onto a regular fps timeline; the portal can deliver pts=0, which
    confuses encoder/muxer timing.

Verified end-to-end: mirrors a Wayland desktop to a non-Apple AirPlay 2
receiver (Hisense), yuv420p, no crash.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@domenkozar domenkozar changed the title capture(wayland): use the go-gst library instead of gst-launch capture(wayland): fix black screen and pts timing on gst-launch Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant