问题
I am trying to convert a
PCM S16 LE (araw)
Mono, Sample rate 22050, Bit pr. sample 16
to
PCM mulaw (PCM MU-LAW)
Mono, Sample rate 8000hz, Bit pr. sample is 8.
WaveFormat.CreateMuLawFormat(8000,1)
or even a more generic WaveFormat.CreateCustomFormat
where I have specified the same WaveFormatEncoding
as the source stream is throwing the same exception.
AcmNotPossible calling acmStreamOpen
Am I missing something here?
Any leads will be greatly appreciated.
回答1:
The ACM mu-law encoder expects its input to be 16 bit. If you're working with mu or a-law, the sample rate is likely to be low as well. The following two lines of code will create a zero-length stream of PCM 16 bit and pass it into a WaveFormatConversionStream to convert it to a-law. It should not throw a "conversion not possible" error unless for some reason you don't have the G.711 encoder installed on your machine.
var s = new RawSourceWaveStream(new MemoryStream(), new WaveFormat(8000,16,1));
var c = new WaveFormatConversionStream(WaveFormat.CreateALawFormat(8000,1), s);
来源:https://stackoverflow.com/questions/13628145/acmnotpossible-calling-acmstreamopen-naudio