Using Media Foundation to encode Direct X surfaces

前端 未结 1 1135
[愿得一人]
[愿得一人] 2021-02-04 19:42

I\'m trying to use the MediaFoundation API to encode a video but I\'m having problems pushing the samples to the SinkWriter.

I\'m getting the frames to encode through th

相关标签:
1条回答
  • 2021-02-04 20:12

    First of all you should learn to use mftrace tool. Very likely, it will tell you the problem right away.

    But my guess is, following problems are likely.

    1. Probably, some other attributes are required besides SampleTime / SampleDuration.

    2. Probably, SinkWriter needs a texture it can read on CPU. To fix that, when a frame is available, create a staging texture of the same format + size, call CopyResource to copy desktop to staging texture, then pass that staging texture to MF.

    3. Even if you use a hardware encoder so the CPU never tries to read the texture data, I don’t think it’s a good idea to directly pass your desktop texture to MF.

    When you set a D3D texture for sample, no data is copied anywhere, the sample merely retains the texture.

    MF works asynchronously, it may buffer several samples in its topology nodes if they want to.

    DD gives you data synchronously, you may only access the texture between AcquireNextFrame and ReleaseFrame calls.

    0 讨论(0)
提交回复
热议问题