Skip to content

Add multivariant output support to Membrane.Transcoder#21

Open
khamilowicz wants to merge 1 commit into
masterfrom
multivariant-output
Open

Add multivariant output support to Membrane.Transcoder#21
khamilowicz wants to merge 1 commit into
masterfrom
multivariant-output

Conversation

@khamilowicz
Copy link
Copy Markdown
Contributor

@khamilowicz khamilowicz commented May 21, 2026

Summary

  • On-request output padsMembrane.Transcoder now exposes availability: :on_request output pads, each accepting independent output_stream_format, transcoding_policy, and native_acceleration options via via_out. Single-output backward-compatible usage is unchanged.
  • Fan-out via Tee — multi-output mode inserts a Membrane.Tee.Parallel between the connector and per-output transcoding chains, created atomically with all outputs in one spec to avoid the race where the Tee could receive data before any output is connected.
  • Exampleexamples/multivariant_output.exs demonstrates a single H264 input transcoded simultaneously to H264, H265, and VP8 outputs.
  • Tests — 5 new integration tests cover multivariant video and audio scenarios. Content correctness is verified by asserting each multivariant output is byte-identical to the equivalent single-output pipeline run.

Usage

# Multiple outputs
child(:transcoder, Membrane.Transcoder),
get_child(:transcoder)
|> via_out(Pad.ref(:output, 0), options: [output_stream_format: H264])
|> child(:hd_sink, Membrane.File.Sink),
get_child(:transcoder)
|> via_out(Pad.ref(:output, 1), options: [output_stream_format: VP8])
|> child(:vp8_sink, Membrane.File.Sink)

Test plan

  • mix test --exclude vk — 54 tests, 0 failures
  • Single-output backward-compatible usage unchanged (existing test suite covers this)
  • Multivariant output produces byte-identical results to equivalent single-output pipelines
  • Run elixir examples/multivariant_output.exs to verify the example produces three non-empty output files

🤖 Generated with Claude Code

@khamilowicz khamilowicz requested a review from varsill May 21, 2026 12:25
@khamilowicz khamilowicz force-pushed the multivariant-output branch 2 times, most recently from 4b429b5 to 406c796 Compare May 21, 2026 12:42
The output pad is now availability: :on_request, allowing a single
transcoder bin to produce multiple independent output streams each
with their own output_stream_format, transcoding_policy, and
native_acceleration options.

Single-output backward-compatible usage is unchanged — implicit
via_out links inherit bin-level options and use the same internal
child names, so existing tests and code require no modification.

Multi-output pipelines use a Membrane.Tee.Parallel (new dep) placed
between the connector and per-output transcoding chains within a
single atomic spec, avoiding the race where the Tee could receive
data before any output is connected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@khamilowicz khamilowicz force-pushed the multivariant-output branch from 406c796 to 0eb8420 Compare May 22, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant