@@ -61,38 +61,33 @@ iex(3)> File.write!("test.jpg", jpeg)
61
61
62
62
## Membrane Sink Usage
63
63
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
66
65
67
66
``` elixir
68
67
defmodule Your .Module .Pipeline do
69
68
use Membrane .Pipeline
70
69
70
+ alias Membrane .{File , H264 }
71
+
71
72
@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 })
83
79
]
84
80
85
- spec = %ParentSpec {
86
- children: children,
87
- links: links
88
- }
89
-
90
- {{:ok , spec: spec}, %{}}
81
+ {[spec: spec], %{}}
91
82
end
92
83
84
+ @impl true
85
+ def handle_element_end_of_stream (:sink , _ctx , state) do
86
+ {[terminate: :normal ], state}
87
+ end
93
88
end
94
89
```
95
90
96
91
# Copyright and License
97
92
98
- Copyright 2021 , Binary Noggin
93
+ Copyright 2023 , Binary Noggin
0 commit comments