-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I'm attempting to convert a .wav file into a .mp3 file using NAudio cross platform in linux. Files work fine in windows but fail in a linux environment.
Nuget Package
Error
System.ArgumentException: Unsupported encoding format ALaw (Parameter 'format')
at NAudio.Lame.LameMP3FileWriter..ctor(Stream outStream, WaveFormat format, LameConfig config)
at NAudio.Lame.LameMP3FileWriter..ctor(Stream outStream, WaveFormat format, LAMEPreset quality, ID3TagData id3)
at Program.
Code
`using NAudio.Lame;
using NAudio.Wave;
try
{
var mp3Stream = new MemoryStream();
var path = Path.GetFullPath(@"./Files/OutputWav.wav");
Console.WriteLine(path);
using (var reader = new WaveFileReader(path))
{
using (var writer = new LameMP3FileWriter(mp3Stream, reader.WaveFormat, LAMEPreset.ABR_16))
{
reader.CopyTo(writer);
}
}
}
catch (Exception e)
{
Console.WriteLine("FAILURES");
Console.WriteLine(e);
return;
}
Console.WriteLine("Success!!!");
`
DockerFile to reproduce
`FROM mcr.microsoft.com/dotnet/sdk:8.0 AS publish
RUN apt-get update
RUN apt-get install -y lame
RUN apt-get install -y libmp3lame-dev
RUN apt-get install -y ffmpeg
FROM publish AS final
WORKDIR /app
COPY /Artifact ./
CMD ["sh", "-c", "tail -f /dev/null"]
#ENTRYPOINT ["dotnet", "AudioTestCheck.dll"]`
If you need the example file I'm using I can provide it.
FYI lame command and ffmpeg commands will make the conversion fine. This seems to just be a problem via code.