Is there a way to render a video from file (avi, mp4, etc...) to a texture in a directx11 environment?

If so, how?


Yes, first you need to read the container (avi, mp4 etc) and then decodee it's contents that can be h264 for example) and then you'll get an rgb output that can be copied over into a texture like you normally would do, if the video is not HD you could do this every frame to play it back.

You can use libffmpeg to read the video, but it's a little tricky i recommend you if the video is not too big to convert it into raw RGB data that you can read easily in your app.

| improve this answer | |
  • \$\begingroup\$ This pretty much nails it. Other library alternatives are possible of course - and other libraries exist to further supplement the process if you give more language details. If you're using .NET (with say SlimDX or SharpDX) there's some nifty bindings for all sorts of tools to make this job a cinhch. \$\endgroup\$ – Vaughan Hilts Feb 12 '13 at 16:11
  • \$\begingroup\$ thanks, actually the video is quite large (720p) i am not sure if copying a texture that big each frame is fast enough for 60fps. anyway isnt there a way to decode on the gpu directly to a texture? \$\endgroup\$ – clamp Feb 15 '13 at 8:53
  • \$\begingroup\$ The problem about decoding high resolution videos is the latency almost all codecs have high latency decoding, even decoding in the gpu what you need is a fast decoder like developer.nvidia.com/nvidia-codec-libraries for example , just to put it in perspective Bink Video is the standard in AAA games this days cuz it's ultra fast to decode in realtime, but isn't free tho... \$\endgroup\$ – Jeremy Rodriguez Feb 16 '13 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.