如何将WPF动画逐帧渲染为视频? [英] How to render WPF animation as a video frame by frame?

查看:355
本文介绍了如何将WPF动画逐帧渲染为视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF中创建了一个我喜欢的效果,希望能够录制该效果。

I've created a nice effect that I like in WPF, I'd like to be able to "record" this effect. But it is choppy during run-time.

有没有一种方法可以将其转换为逐帧过程,并自己保存为视频,而无需尝试在播放过程中记录它?

Is there a way I can convert it to a frame-by-frame process and save it as a video myself instead of trying to record it during playback?

基本上我想将WPF渲染为视频,或列出一系列保存为位图的帧。

Basically I'd like to render WPF as a video, or list a series of frames saved as bitmaps.

关键是要能够录制动画而没有断断续续。

Key thing is to be able to record the animation with out the choppiness.

推荐答案

有你看过使用 RenderTargetBitmap 将Visual呈现为位图吗?
您可能必须使用动画的时间安排或加入OnRender事件,但这将使您可以将控件捕获为图像。

Have you looked at using RenderTargetBitmap to render your Visual as a bitmap? You might have to play with the animation's timing or hook into the OnRender event, but that will let you capture your control as an image.

要扩展动画的定时位:如果要渲染动画并将其另存为位图(然后制作视频),则可以使用Clock的 ClockController 手动推进动画并将每个帧渲染到文件。

To expand on the animation's timing bit: If you want to render your animation and save it as bitmaps (to then make a video), you might be able to use a Clock's ClockController to manually advance the animation and render each frame to file.

另一种方法是将设置为 ,然后通过设置为可渲染每一帧的值(例如,如果动画花费一秒钟,并且您想制作30 fps视频,则最坏的情况是更改动画花费30秒,前进一秒钟,然后每次前进后渲染到位图。

Another alternative is to set the To, From, and By to values that let you render each frame (e.g. if the animation takes one second, and you want to make a 30 fps video, you could worst case alter the animation to take 30 seconds, advance by one second, and render to bitmap after each advance).

这篇关于如何将WPF动画逐帧渲染为视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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