-
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
Conversation
lib/transcoder/video.ex
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like calling struct!/2
as it allows to create a struct that misses some required fields and I am not sure if it supports non-nil default values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed struct!()
usage for both H26x and VPx
lib/transcoder.ex
Outdated
Membrane.Logger.warning(""" | ||
The only input stream format that can be assumed is | ||
`%Membrane.RemoteStream{content_format: Membrane.MPEGAudio}`, while you wanted to assume: | ||
#{inspect(stream_format)} | ||
""") | ||
|
||
builder | ||
|> child(:stream_format_changer, %Membrane.Transcoder.StreamFormatChanger{ | ||
stream_format: stream_format | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to raise here, as the code won't act as the user assumed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/transcoder/audio.ex
Outdated
defp maybe_plug_resampler(builder, input_format, %Opus{}) | ||
when not is_opus_compliant(input_format) do | ||
builder | ||
|> child(:resampler, %Membrane.FFmpeg.SWResample.Converter{ | ||
output_stream_format: %RawAudio{ | ||
sample_format: :s16le, | ||
sample_rate: 48_000, | ||
channels: 1 | ||
} | ||
}) | ||
end | ||
|
||
defp maybe_plug_resampler(builder, input_format, %AAC{}) | ||
when not is_aac_compliant(input_format) do | ||
builder | ||
|> child(:resampler, %Membrane.FFmpeg.SWResample.Converter{ | ||
output_stream_format: %RawAudio{ | ||
sample_format: :s16le, | ||
sample_rate: 44_100, | ||
channels: 1 | ||
} | ||
}) | ||
end | ||
|
||
defp maybe_plug_resampler(builder, input_format, %MPEGAudio{}) | ||
when not is_mp3_compliant(input_format) do | ||
builder | ||
|> child(:resampler, %Membrane.FFmpeg.SWResample.Converter{ | ||
output_stream_format: %RawAudio{sample_rate: 44_100, sample_format: :s32le, channels: 2} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice, but are you sure we don't want to plug resampler if e.g. input format doesn't have :channels
field?
Co-authored-by: Feliks Pobiedziński <[email protected]>
This PR adds support for:
TODO: