[UWP]更改自定义视频效果的属性 [英] [UWP]Change properties of custom video effect

查看:80
本文介绍了[UWP]更改自定义视频效果的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建一个UWP应用程序,用滑块更改视频的颜色。我可以使用Win2D TempAndTintEffect以自定义视频效果静态更改视频的颜色。


$
这是我视频效果类的代码:

 public sealed class HardwareEffect:IBasicVideoEffect {
public void ProcessFrame(ProcessVideoFrameContext context)
{

using(CanvasBitmap inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice,context.InputFrame.Direct3DSurface))
using(CanvasRenderTarget renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(canvasDevice,context.OutputFrame.Direct3DSurface))
using(CanvasDrawingSession ds = renderTarget.CreateDrawingSession())
{
this.tempAndTintEffect = new TemperatureAndTintEffect
{
Source = inputBitmap,
Temperature = 0,
Tint = 0
};

ds.DrawImage(this.tempAndTintEffect);
}
}
}


这里我将效果添加到我的剪辑:

 var clip = await MediaClip.CreateFromFileAsync(pickedFile); 
composition.Clips.Add(clip);

var videoEffect = new VideoEffectDefinition(" VideoEffectComponent.HardwareEffect",new PropertySet(){{" Tint",.5}});
clip.VideoEffectDefinitions.Add(this.videoEffect);


现在我想用滑块更改温度和色调,并将更改动态应用于视频效果。


$
如何动态更改效果属性?
$

解决方案


如果需要动态更改它,则需要更新ProcessFrame中的效果。我会问其他工程师这个问题。会有一些时间延迟。


感谢您的耐心等待。


祝你好运,


Roy


I try to create an UWP app which changes the color of a video with a slider. I can change the color of a video statically with a custom video effect using the Win2D TempAndTintEffect.

This is the code from my video effect class:

public sealed class HardwareEffect : IBasicVideoEffect {
    public void ProcessFrame(ProcessVideoFrameContext context)
    {

        using (CanvasBitmap inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice, context.InputFrame.Direct3DSurface))
        using (CanvasRenderTarget renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(canvasDevice, context.OutputFrame.Direct3DSurface))
        using (CanvasDrawingSession ds = renderTarget.CreateDrawingSession())
        {
            this.tempAndTintEffect = new TemperatureAndTintEffect
            {
                Source = inputBitmap,
                Temperature = 0,
                Tint = 0
            };

            ds.DrawImage(this.tempAndTintEffect);
        }
    }
}

Here I'm adding the effect to my clip:

var clip = await MediaClip.CreateFromFileAsync(pickedFile);
composition.Clips.Add(clip);

var videoEffect= new VideoEffectDefinition("VideoEffectComponent.HardwareEffect", new PropertySet() { { "Tint", .5 } });
clip.VideoEffectDefinitions.Add(this.videoEffect);

Now I would like to change the temperature and tint with a slider and apply the changes dynamically to the video effect.

How can I change the effect properties with a slider dynamically?

解决方案

Hi,

If you need to change it dynamically, you will need to update the effect in the ProcessFrame. I'll ask other engineers about this question. There will be some time delay.

Thank you for your patience.

Best regards,

Roy


这篇关于[UWP]更改自定义视频效果的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆