我想创建使用Windows.Media.Transcoding转换视频的UWP应用。下面的代码。运行该应用程序后-崩溃,并显示(0xc0000005)“访问冲突”代码。 我尝试在清单中添加权限,但无济于事。 此代码有什么问题?
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
openPicker.FileTypeFilter.Add(".wmv");
StorageFile source = await openPicker.PickSingleFileAsync();
StorageFile destination = await KnownFolders.VideosLibrary.CreateFileAsync("nowy.mp4", CreationCollisionOption.ReplaceExisting);
if (source != null)
{
MediaEncodingProfile profile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p);
MediaTranscoder transcoder = new MediaTranscoder();
var prepareOp = await transcoder.PrepareFileTranscodeAsync(source, destination, profile);
if (prepareOp.CanTranscode)
{
var transcodeOp = prepareOp.TranscodeAsync();
transcodeOp.Progress +=
new AsyncActionProgressHandler<double>(TranscodeProgress);
transcodeOp.Completed +=
new AsyncActionWithProgressCompletedHandler<double>(TranscodeComplete);
}
else
{
switch (prepareOp.FailureReason)
{
case TranscodeFailureReason.CodecNotFound:
System.Diagnostics.Debug.WriteLine("Codec not found.");
break;
case TranscodeFailureReason.InvalidProfile:
System.Diagnostics.Debug.WriteLine("Invalid profile.");
break;
default:
System.Diagnostics.Debug.WriteLine("Unknown failure.");
break;
}
}
}
编辑,我在使用GitHub
中的Windows示例时遇到了同样的问题