Advertisement

Recording offscreen surfaces into video

Started by January 11, 2020 07:17 PM
5 comments, last by desiado 5 years ago

Hi guys

Has anyone here tried recording offscreen surfaces in D3D11 to video? The reason I ask is a client of mine is requesting the ability to record cockpit displays which I render with D3D11 in a flight simulator.

Any suggestions on where to start?

OpenCV will let you write the frames to a video file.

Advertisement

Can't use it. I didn't create the flight simulator, I only created the aircraft addition to it. I can't change graphics interfaces, so I am stuck with D3D11. So still need a way to record offscreen surfaces with DX11.

FFmpeg (using libav) has a c++ api that can encode video (pretty much any format you like)

Download the *DEV* build

https://ffmpeg.zeranoe.com/builds/

In the examples folder look at the muxing.c example which generates a video (with audio) created from a dummy picture.

In your flight sim, is it possible to copy your offscreen texture to a CPU read/writable texture using a device context CopyResource call.

Then use this as the input for the video frames in the muxing example .

I’ve done this in the past and it works well.

I can do so, I'm just concerned about the performance impact that can have.

Yes you’re right to think of the performance impact. I assume you’re having to record in real time.

I’m not sure of your setup, so hard to recommend. If your cockpit display was output to a screen, then some HDMI/DVI-D capture device would be the easiest solution. But when you say ‘offscreen’, I assume this is not possible.

If so, you’re stuck with some kind of performance hit somewhere, although it was acceptable for the software I was working on.

The CopyResource call won’t be that bad compared to CPU encoding of the video. I would favour a video codec and settings that was quick to encode but produced larger video files. You can always transcode to a more compressed format later, or even not bother compressing at all. You could also just send the raw data to another ‘dedicated device for encoding.

Another option is GPU encoding, some GPU cards (e.g. NVidia) can do GPU h.264 encoding and I think can use DX11 textures as input. https://developer.nvidia.com/nvidia-video-codec-sdk/download

This topic is closed to new replies.

Advertisement