VideoTransformEffectDefinition以错误结束:视频无法解码

时间:2016-04-11 12:23:23

标签: c# win-universal-app video-processing video-effects

我正在尝试使用VideoTransformEffectDefinition

<?php 

if(!empty($_REQUEST['first']) && $_REQUEST['second'] && $_REQUEST['third'] && $_REQUEST['fourth'] && $_REQUEST['fifth'])
  {

$first = $_REQUEST['first'];
$second = $_REQUEST['second'];
$third = $_REQUEST['third'];
$fourth = $_REQUEST['fourth'];
$fifth = $_REQUEST['fifth'];
$average = array($first,$second,$third,$fourth,$fifth);
$total = array_sum($average);

$the_average = $total/count($average);
echo $the_average;
}else{
echo 'Please complete all fields';
}

?>

这不会引发异常,但它会告诉我

  

“错误:视频无法解码”

媒体元素

很奇怪,因为代码与VideoStabilizationEffectDefinition

运行良好
        var clip = await MediaClip.CreateFromFileAsync(pickedFile);//creating clip from storage file
        MediaComposition composition = new MediaComposition();
        composition.Clips.Add(clip);
        VideoTransformEffectDefinition videoEffect1 = new VideoTransformEffectDefinition();
        videoEffect1.PaddingColor = Colors.Blue;//this line is not necessary, does not matter how videoEffect is changed 
        clip.VideoEffectDefinitions.Add(videoEffect1);//adding videoEffect
        this.mediaElement.SetMediaStreamSource(composition.GenerateMediaStreamSource());//setting source to MediaElement

我做错了什么?

1 个答案:

答案 0 :(得分:1)

VideoTransformEffectDefinition仅适用于MediaTranscoder。它对MediaComposition没有影响。当您将MediaElement设置为MediaElement.SetMediaStreamSource(MediaComposition .GenerateMediaStreamSource())时,它会抛出NullReferenceException。

来自GitHub的官方样本使用MediaTranscoder。在Scenario1中,它会按MediaTranscoder创建private MediaTranscoder _Transcoder = new MediaTranscoder();您可以VideoTransformEffectDefinitionMediaTranscoder添加到TranscodePreset

您可以在Scenario1_Default.xaml.cs中将以下代码添加到VideoTransformEffectDefinition videoEffect = new VideoTransformEffectDefinition(); _Transcoder.ClearEffects(); var activatableClassId = videoEffect.ActivatableClassId; _Transcoder.AddVideoEffect(activatableClassId, true, videoEffect.Properties); videoEffect.PaddingColor = Colors.Blue; videoEffect.Rotation = MediaRotation.Clockwise90Degrees; 事件中。

例如:

.dae