Skip to content

Commit

Permalink
Add init section
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgiuliani committed Oct 9, 2024
1 parent 55aa6bf commit 1252a3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 13 additions & 16 deletions examples/rtmp.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ defmodule Pipeline do
def handle_init(_ctx, _opts) do
File.rm_rf("tmp")

{:ok, packager_pid} =
Agent.start_link(fn ->
HLS.Packager.new(
storage: HLS.Storage.File.new(),
manifest_uri: URI.new!("file://tmp/stream.m3u8"),
resume_finished_tracks: true,
restore_pending_segments: false
)
end)
{:ok, packager} =
HLS.Packager.start_link(
storage: HLS.Storage.File.new(),
manifest_uri: URI.new!("file://tmp/stream.m3u8"),

This comment has been minimized.

Copy link
@grant-zukowski-xumo

grant-zukowski-xumo Nov 6, 2024

If I'm using this as an example, is this where I put in my source URL?

I assume this example is using HLS as ingress and RTMP as egress, correct?

This comment has been minimized.

Copy link
@philipgiuliani

philipgiuliani Nov 6, 2024

Author Member

Hi! Sorry this example was just for the HLS Sink (RTMP -> HLS). We'll respond in your ticket for more information.

resume_finished_tracks: true,
restore_pending_segments: false
)

structure = [
# Source
Expand All @@ -34,7 +32,7 @@ defmodule Pipeline do

# Sink
child(:sink, %Membrane.HLS.SinkBin{
packager_pid: packager_pid,
packager: packager,
target_segment_duration: Membrane.Time.seconds(7),
}),

Expand All @@ -49,9 +47,8 @@ defmodule Pipeline do
options: [
encoding: :AAC,
segment_duration: Membrane.Time.seconds(6),
build_stream: fn uri, %Membrane.CMAF.Track{} = format ->
build_stream: fn %Membrane.CMAF.Track{} = format ->
%HLS.AlternativeRendition{
uri: uri,
name: "Audio (EN)",
type: :audio,
group_id: "program_audio",
Expand Down Expand Up @@ -86,9 +83,9 @@ defmodule Pipeline do
options: [
encoding: :H264,
segment_duration: Membrane.Time.seconds(6),
build_stream: fn uri, %Membrane.CMAF.Track{} = format ->
build_stream: fn %Membrane.CMAF.Track{} = format ->
%HLS.VariantStream{
uri: uri,
uri: nil,
bandwidth: 3951200,
resolution: format.resolution,
codecs: Membrane.HLS.serialize_codecs(format.codecs),
Expand Down Expand Up @@ -120,9 +117,9 @@ defmodule Pipeline do
options: [
encoding: :H264,
segment_duration: Membrane.Time.seconds(6),
build_stream: fn uri, %Membrane.CMAF.Track{} = format ->
build_stream: fn %Membrane.CMAF.Track{} = format ->
%HLS.VariantStream{
uri: uri,
uri: nil,
bandwidth: 1_200_000,
resolution: format.resolution,
codecs: Membrane.HLS.serialize_codecs(format.codecs),
Expand Down
2 changes: 2 additions & 0 deletions lib/membrane/hls/cmaf_sink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ defmodule Membrane.HLS.CMAFSink do
)
end

Packager.put_init_section(state.opts.packager, track_id, format.header)

{[], state}
end

Expand Down

0 comments on commit 1252a3a

Please sign in to comment.