How to convert the XAML / WPF file to video (AVI, WMV, etc.)

I have a simple WPF (XAML) file that has some animated shapes and text. Animation has no interactive behavior. I want to record this animation as a video file, which I intend to use later as an intro screen for the screencast.

What I need: C # code that accepts an input XAML file and produces high-quality WMV (e.g. 24 frames per second).

Possible alternatives that I have already explored

  • Recording using on-screen recording software such as Camtasia Studio. This works, but the animations are not so smooth, especially when the animation has many transitions or movements.

  • Use hardware such as the DVI2USB from Epiphan Systems. Costs are too high; did not try.

  • Record TV output (S-Video, etc.) using a DVR card - Poor quality and low resolution.

October 28, 2008 Patch - working source code

This blog post has a complete working example of the WPF / XAML export source code as AVI. It is not as fast as we would like, but it works for my needs:

link to Bosnian MSDN blog

+4
source share
1 answer

Render frames with RenderTargetBitmap, then encode using the codec of your choice. Not very fast, but 24 fps is achievable on a regular PC. We use a similar technique to feed the video stream from the new WPF indicators to an outdated raster system. There may be a better solution, but it works.

I also heard about a solution that extracts rendering from DirectX buffers that WPF uses internally, which is much faster than RenderTargetBitmap, but it seemed too unreliable for use on a production system

Update: it seems you don't need it in real time, so RenderTargetBitmap should work without problems.

+4
source

Source: https://habr.com/ru/post/1276764/


All Articles