Add multivariant output support to Membrane.Transcoder#21
Conversation
406c796 to
0eb8420
Compare
There was a problem hiding this comment.
I don't think we want to have this commited
There was a problem hiding this comment.
I think we need to update existing examples as well
| end | ||
|
|
||
| defp child_name(nil, base), do: base | ||
| defp child_name(suffix, base), do: :"#{suffix}_#{base}" |
There was a problem hiding this comment.
I am slightly worried about creating atoms dynamically since they are not garbage collected. How about making child's name a String?
There was a problem hiding this comment.
ChildSpec allows only atoms or tuples as names, I went with tuple {suffix, base}.
|
|
||
| defp maybe_plug_encoder_and_parser(builder, %VP8{}) do | ||
| defp maybe_plug_encoder_and_parser(builder, %VP8{}, suffix) do | ||
| cpu_quota = :erlang.system_info(:cpu_quota) |
There was a problem hiding this comment.
(I know it's unrelates but it brought my attention :D)
What :cpu_quota would return in contenerized environments (e.g. with docker)?
The problem is that if :cpu_quota doesn't reflect some cgroup limits, then we might end up in a situation that we will try to use all the cores available in the machine, and we will be given only fraction of it, which ends up in thrashing
There was a problem hiding this comment.
I used :logical_processors_online to handle this case.
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>
5a6305d to
3b00a93
Compare
3b00a93 to
b29e223
Compare
- use strings as children names - update examples
b29e223 to
be2620a
Compare
| tmp = fn -> Path.join(System.tmp_dir!(), "mv_#{:erlang.unique_integer([:positive])}") end | ||
| h264_tmp = tmp.() | ||
| vp8_tmp = tmp.() |
There was a problem hiding this comment.
Please use %{tmp_dir: tmp_dir} context
Summary
Membrane.Transcodernow exposesavailability: :on_requestoutput pads, each accepting independentoutput_stream_format,transcoding_policy, andnative_accelerationoptions viavia_out. Single-output backward-compatible usage is unchanged.Membrane.Tee.Parallelbetween 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.examples/multivariant_output.exsdemonstrates a single H264 input transcoded simultaneously to H264, H265, and VP8 outputs.Usage
Test plan
mix test --exclude vk— 54 tests, 0 failureselixir examples/multivariant_output.exsto verify the example produces three non-empty output files🤖 Generated with Claude Code