Audio compression in Windows Store apps?
-
14-07-2021 - |
質問
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?
解決
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();
所属していません StackOverflow