Weird behaviour of SWResample converter plugin when doing s16le -> f32le resampling


I’ll keep saying this again and again – Membrane Team, kudos to you for all the good work you have been doing!

This post is pretty much a replica of an issue on Github but I figured out Elixir Forum may have a little more visibility.

This snippet is from an Endpoint for a Membrane WebRTC Engine

alias Membrane.RTC.Engine.Endpoint.WebRTC.TrackReceiver
alias Membrane.FFmpeg.SWResample.Converter

def handle_pad_added({_, _, track_id} = pad, ctx, state) do
  structure = [
      |> child(:track_receiver, %TrackReceiver{
        track: state.track,
        initial_target_variant: :high
      |> child(:depayloader, get_depayloader(state.track))
      |> child(:opus_decoder, %Membrane.Opus.Decoder{
        sample_rate: 16_000
      |> child(:resample, %Converter{
        output_stream_format: %RawAudio{channels: 1, sample_format: :f32le, sample_rate: 16_000}
      |> child({:wav_serializer, track_id}, Membrane.WAV.Serializer)
      |> child({:sink, track_id}, %Membrane.File.Sink{
        location: Path.join(state.output_dir_path, "out.wav")

Whenever I’m resampling to s16le or s24le or s32le the resulting out.wav is perfectly fine. But resampling to f32le produces a screeching and squeaking mess. ffmpeg sees nothing wrong with the resulting file and I’m not savvy enough with audio processing to figure out the cause.

Do you have any ideas about why this might be happening?

It seems like a bug of Converter. I’ll investigate it further and let you know on the GitHub issue.


Dominik, thanks!