@impl true
def handle_init(_ctx, _path) do
structure = [
child(:video_source, %Membrane.File.Source{
location: @input_file
})
|> child(:demuxer, Membrane.MP4.Demuxer.ISOM),
# Mux
child(:muxer, Membrane.MP4.Muxer.ISOM)
|> child(:sink, %Membrane.File.Sink{location: @out_file})
]
{[spec: structure], %{}}
end
@impl true
def handle_child_notification({:new_tracks, tracks}, :demuxer, _ctx, state) do
spec =
tracks
|> Enum.map(fn
{track_id, %Membrane.H264{}} ->
get_child(:demuxer)
|> via_out(Pad.ref(:output, track_id))
|> do_video()
{track_id, %Membrane.AAC{}} ->
get_child(:demuxer)
|> via_out(Pad.ref(:output, track_id))
|> do_audio()
end)
{[spec: spec], state}
end
@impl true
def handle_init(_ctx, _path) do
structure = [
child(:video_source, %Membrane.File.Source{
location: @input_file
})
|> child(:demuxer, Membrane.MP4.Demuxer.ISOM),
# Mux
child(:muxer, Membrane.MP4.Muxer.ISOM)
|> child(:sink, %Membrane.File.Sink{location: @out_file})
]
{[spec: structure], %{}}
end
@impl true
def handle_child_notification({:new_tracks, tracks}, :demuxer, _ctx, state) do
spec =
tracks
|> Enum.map(fn
{track_id, %Membrane.H264{}} ->
get_child(:demuxer)
|> via_out(Pad.ref(:output, track_id))
|> do_video()
{track_id, %Membrane.AAC{}} ->
get_child(:demuxer)
|> via_out(Pad.ref(:output, track_id))
|> do_audio()
end)
{[spec: spec], state}
end