[opus] Looking for Freelancer - 16/44.1 PCM <-> 48 Khz Opus

Logan Stromberg loganstromberg at gmail.com
Thu Mar 4 20:03:04 UTC 2021


Simplest solution, if you just have a bunch of files that need converting:
http://ffmpeg.org/
ffmpeg -i "wave file.wav" -ar 48000 -c:a libopus -b:a 112K "opus file.opus"
ffmpeg -i "opus file.opus" -ar 44100 -c:a pcm_s16le "wave file.wav"

Slightly less simple solution, if you need to do this programmatically in
C#. You can use OggOpusDecoder and RiffWaveEncoder to do this conversion in
reverse.
https://www.nuget.org/packages/Durandal.AI/
IRealTimeProvider realTime = DefaultRealTimeProvider.Singleton;
CancellationToken cancelToken = CancellationToken.None;
IAudioGraph graph = new BasicAudioGraph();
AudioSampleFormat desiredOutputFormat = AudioSampleFormat.Stereo(48000);

// you can replace these streams with any programmatic data input/output
that you need
using (FileStream inputWaveStream = new FileStream("input file.wav",
FileMode.Open, FileAccess.Read))
using (NonRealTimeStream inputNrtWrapper = new
NonRealTimeStreamWrapper(inputWaveStream, false))
using (FileStream outputOpusStream = new FileStream("output file.opus",
FileMode.Create, FileAccess.Write))
using (NonRealTimeStream outputNrtWrapper = new
NonRealTimeStreamWrapper(outputOpusStream, false))
using (AudioDecoder waveDecoder = new RiffWaveDecoder(graph))
using (AudioEncoder opusEncoder = new OggOpusEncoder(graph,
desiredOutputFormat, NullLogger.Singleton, complexity: 10, bitrateKbps: 96))
{
    AudioInitializationResult ir = await
waveDecoder.Initialize(inputNrtWrapper, false, realTime,
cancelToken).ConfigureAwait(false);
    if (ir != AudioInitializationResult.Success)
        throw new Exception("Failed audio initialization: " +
ir.ToString());

    ir = await opusEncoder.Initialize(outputNrtWrapper, false, realTime,
cancelToken).ConfigureAwait(false);
    if (ir != AudioInitializationResult.Success)
        throw new Exception("Failed audio initialization: " +
ir.ToString());

    // do automatic channel mixing and resampling to get formats to agree
    using (AudioConformer conformer = new AudioConformer(graph,
waveDecoder.OutputFormat, opusEncoder.InputFormat, resamplerQuality: 10))
    {
        waveDecoder.ConnectOutput(conformer);
        conformer.ConnectOutput(opusEncoder);
        await waveDecoder.ReadFully(realTime,
cancelToken).ConfigureAwait(false); // Drive the full wave input through
the audio graph
        await opusEncoder.Finish(realTime,
cancelToken).ConfigureAwait(false); // Flush the decoder and close its
stream
    }
}


>
> Dear Opus Experts,
>
> We are looking for a freelancer to help us convert between 16 and 44.1 Khz
> PCM into Opus 48 Khz and vice versa. The app is done in C# (but C++ via DLL
> is possible) on a Windows machine (we could use Media Foundation afak).
>
> Best,
>
> Max
>
> HOLOMEETING
> Maximilian Doelle
> +442070812688
> @MDoelle
> Kazendi Ltd is a limited company registered in England and Wales. Company
> registration No. 09234614. Registered Offices: Lytchett House, 13 Freeland
> Park, Wareham Road, Poole, Dorset, BH16 6FA
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/opus/attachments/20210304/cf7e47eb/attachment.html>


More information about the opus mailing list