Skip to content

Commit 14e2b36

Browse files
gBillalConnorRigby
authored andcommitted
Update README
1 parent 111c95d commit 14e2b36

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

README.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,38 +61,33 @@ iex(3)> File.write!("test.jpg", jpeg)
6161

6262
## Membrane Sink Usage
6363

64-
Pleas See [the membrane guide](https://membraneframework.org/guide/v0.5/pipeline.html#content)
65-
before using this.
64+
In this example we'll read an H264 encoded frame and save it as a JPEG image
6665

6766
```elixir
6867
defmodule Your.Module.Pipeline do
6968
use Membrane.Pipeline
7069

70+
alias Membrane.{File, H264}
71+
7172
@impl true
72-
def handle_init(location) do
73-
children = %{
74-
source: %SomeMembraneSourceModule{location: location},
75-
decoder: Membrane.Element.FFmpeg.H264.Decoder,
76-
jpeg_converter: %Turbojpeg.Sink{filename: "/tmp/frame.jpeg", quality: 100},
77-
}
78-
79-
links = [
80-
link(:source)
81-
|> to(:decoder)
82-
|> to(:jpeg_converter)
73+
def handle_init(_ctx, _opts) do
74+
children = [
75+
child(:source, %File.Source{location: "input.h264"})
76+
|> child(:parser, H264.Parser)
77+
|> child(:decoder, H264.FFmpeg.Decoder)
78+
|> child(:sink, %Turbojpeg.Sink{filename: "/tmp/frame.jpeg", quality: 100})
8379
]
8480

85-
spec = %ParentSpec{
86-
children: children,
87-
links: links
88-
}
89-
90-
{{:ok, spec: spec}, %{}}
81+
{[spec: spec], %{}}
9182
end
9283

84+
@impl true
85+
def handle_element_end_of_stream(:sink, _ctx, state) do
86+
{[terminate: :normal], state}
87+
end
9388
end
9489
```
9590

9691
# Copyright and License
9792

98-
Copyright 2021, Binary Noggin
93+
Copyright 2023, Binary Noggin

0 commit comments

Comments
 (0)