我正在尝试使用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
我做错了什么?
答案 0 :(得分:1)
VideoTransformEffectDefinition
仅适用于MediaTranscoder
。它对MediaComposition
没有影响。当您将MediaElement
设置为MediaElement.SetMediaStreamSource(MediaComposition .GenerateMediaStreamSource())
时,它会抛出NullReferenceException。
来自GitHub的官方样本使用MediaTranscoder
。在Scenario1中,它会按MediaTranscoder
创建private MediaTranscoder _Transcoder = new MediaTranscoder();
您可以VideoTransformEffectDefinition
将MediaTranscoder
添加到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