I'm trying to convert a wav file to an m4a file using the Transcoding classes. But every time I'm trying to get the PrepareTranscodeResult
from my transcoder, I get an "Object reference not set to an instance of an object" exception.
I have looked at the Media Transcoding Sample from Microsoft, but that falls over in exactly the same fashion if I try to modify it for audio.
Any ideas where I'm going wrong?
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
file1 = await storageFolder.GetFileAsync("Foo.wav");
file2 = await storageFolder.CreateFileAsync("Bar.m4a", CreationCollisionOption.ReplaceExisting);
MediaTranscoder transcoder = new MediaTranscoder();
var p = MediaEncodingProfile.CreateM4a(AudioEncodingQuality.Auto);
try
{
var preparedTranscodeResult = await transcoder.PrepareFileTranscodeAsync(file1, file2, p);
var progress = new Progress<double>(TranscodeProgress);
await preparedTranscodeResult.TranscodeAsync().AsTask(progress);
}
catch (Exception exc)
{
}
You cannot use AudioEncodingQuality.Auto
property without a video source.
In this case, you just have to use concrete property like this.
var p = MediaEncodingProfile.CreateM4a(AudioEncodingQuality.High);