-
Notifications
You must be signed in to change notification settings - Fork 0
Support more codecs #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
be0396d
de4ad63
b9b9475
b2426d8
c62520f
c18ad64
92efa2c
9b3fc48
d2eca35
da42ffa
26e4f8d
991718d
c7907ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| defmodule Membrane.Transcoder.StreamFormatChanger do | ||
| @moduledoc false | ||
| use Membrane.Filter | ||
|
|
||
| def_input_pad :input, accepted_format: %Membrane.RemoteStream{} | ||
| def_output_pad :output, accepted_format: _any | ||
|
|
||
| def_options stream_format: [ | ||
| spec: Membrane.StreamFormat.t(), | ||
| description: """ | ||
| Stream format that will be sent on `handle_playing`. | ||
| """ | ||
| ] | ||
|
|
||
| @impl true | ||
| def handle_init(_ctx, opts) do | ||
| {[], %{stream_format: opts.stream_format}} | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_playing(_ctx, state) do | ||
| {[stream_format: {:output, state.stream_format}], state} | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_buffer(:input, buffer, _ctx, state) do | ||
| {[buffer: {:output, buffer}], state} | ||
| end | ||
|
|
||
| @impl true | ||
| def handle_stream_format(:input, _stream_format, _ctx, state) do | ||
| {[], state} | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,14 @@ defmodule Membrane.Transcoder.Video do | |
|
|
||
| import Membrane.ChildrenSpec | ||
| require Membrane.Logger | ||
| alias Membrane.{ChildrenSpec, H264, H265, RawVideo, RemoteStream, VP8} | ||
| alias Membrane.{ChildrenSpec, H264, H265, RawVideo, RemoteStream, VP8, VP9} | ||
|
|
||
| @type video_stream_format :: VP8.t() | H264.t() | H265.t() | RawVideo.t() | ||
| @type video_stream_format :: VP8.t() | VP9.t() | H264.t() | H265.t() | RawVideo.t() | ||
|
|
||
| defguard is_video_format(format) | ||
| when is_struct(format) and | ||
| (format.__struct__ in [VP8, H264, H265, RawVideo] or | ||
| (format.__struct__ == RemoteStream and format.content_format == VP8 and | ||
| (format.__struct__ in [VP8, VP9, H264, H265, RawVideo] or | ||
| (format.__struct__ == RemoteStream and format.content_format in [VP8, VP9] and | ||
| format.type == :packetized)) | ||
|
|
||
| @spec plug_video_transcoding( | ||
|
|
@@ -79,15 +79,18 @@ defmodule Membrane.Transcoder.Video do | |
| |> child(:h265_decoder, %H265.FFmpeg.Decoder{}) | ||
| end | ||
|
|
||
| defp maybe_plug_parser_and_decoder(builder, %VP8{}) do | ||
| builder |> child(:vp8_decoder, %VP8.Decoder{}) | ||
| defp maybe_plug_parser_and_decoder(builder, %vpx{}) when vpx in [VP8, VP9] do | ||
| decoder_module = Module.concat(vpx, Decoder) | ||
| builder |> child(:vp8_decoder, decoder_module) | ||
| end | ||
|
|
||
| defp maybe_plug_parser_and_decoder(builder, %RemoteStream{ | ||
| content_format: VP8, | ||
| content_format: vpx, | ||
| type: :packetized | ||
| }) do | ||
| builder |> child(:vp8_decoder, %VP8.Decoder{}) | ||
| }) | ||
| when vpx in [VP8, VP9] do | ||
| decoder_module = Module.concat(vpx, Decoder) | ||
| builder |> child(:vp8_decoder, decoder_module) | ||
| end | ||
|
|
||
| defp maybe_plug_parser_and_decoder(builder, %RawVideo{}) do | ||
|
|
@@ -112,15 +115,16 @@ defmodule Membrane.Transcoder.Video do | |
| }) | ||
| end | ||
|
|
||
| defp maybe_plug_encoder_and_parser(builder, %VP8{}) do | ||
| defp maybe_plug_encoder_and_parser(builder, %vpx{}) when vpx in [VP8, VP9] do | ||
| cpu_quota = :erlang.system_info(:cpu_quota) | ||
|
|
||
| number_of_threads = | ||
| if cpu_quota != :unknown, | ||
| do: cpu_quota, | ||
| else: :erlang.system_info(:logical_processors_available) | ||
|
|
||
| builder |> child(:vp8_encoder, %VP8.Encoder{g_threads: number_of_threads, cpu_used: 15}) | ||
| encoder = Module.concat(vpx, Encoder) |> struct!(g_threads: number_of_threads, cpu_used: 15) | ||
|
||
| builder |> child(:vp8_encoder, encoder) | ||
| end | ||
|
|
||
| defp maybe_plug_encoder_and_parser(builder, %RawVideo{}) do | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.