windows-runtimewindows-store-appsmp3oggwma

Audio compression in Windows Store apps?


I'm looking for a way to compress wav files to some other format - mp3, wma or ogg. Is there any library I could use? Lame would not work in a WinStore app, or would it?


Solution

  • There is transcoding support in the Windows.Media.Transcoding namespace. There is a sample for video but audio should be supported too. Looking at MediaEncodingProfile it seems aac, wma and mp3 are supported.

    *EDIT (usage sample)

    var profile = MediaEncodingProfile.CreateMp3(AudioEncodingQuality.High);
    var transcoder = new MediaTranscoder();
    var folder = ApplicationData.Current.LocalFolder;
    var mp3File = await folder.CreateFileAsync(
        mp3FileName,
        CreationCollisionOption.ReplaceExisting);
    var transcode = await transcoder.PrepareFileTranscodeAsync(wavFile, mp3File, profile);
    await transcode.TranscodeAsync();