c++ - Using Media Foundation to encode Direct X surfaces -
i'm trying use mediafoundation api encode video i'm having problems pushing samples sinkwriter.
i'm getting frames encode through desktop duplication api. end id3d11texture2d desktop image in it.
i'm trying create imfvideosample containing surface , push video sample sinkwriter.
i've tried going in different ways:
i called
mfcreatevideosamplefromsurface(texture, &psample)
texture id3d11texture2d, filled in sampletime , sampleduration , passed created sample sinkwriter.
sinkwriter returned e_invalidarg.i tried creating sample passing nullptr first argument , creating buffer myself using mfcreatedxgisurfacebuffer, , passing resulting buffer sample.
didn't work either.i read through mediafoundation documentation , couldn't find detailed information on how create sample out of directx texture.
i ran out of things try.
has out there used api before , can think of things should check, or of way on how can go debugging this?
first of should learn use mftrace
tool. likely, tell problem right away.
but guess is, following problems likely.
probably, other attributes required besides sampletime / sampleduration.
probably, sinkwriter needs texture can read on cpu. fix that, when frame available, create staging texture of same format + size, call copyresource copy desktop staging texture, pass staging texture mf.
even if use hardware encoder cpu never tries read texture data, don’t think it’s idea directly pass desktop texture mf.
when set d3d texture sample, no data copied anywhere, sample merely retains texture.
mf works asynchronously, may buffer several samples in topology nodes if want to.
dd gives data synchronously, may access texture between acquirenextframe , releaseframe calls.
Comments
Post a Comment