Displaying a video in DirectX

别等时光非礼了梦想. 提交于 2019-12-07 04:16:51

问题


What is the best/easiest way to display a video (with sound!) in an application using XAudio2 and Direct3D9/10?

At the very least it needs to be able to stream potentially larger videos, and take care of the fact that the windows aspect ratio may differ from the videos (eg by adding letter boxes), although ideally Id like the ability to embed the video into a 3D scene.

I could of course work out a way to load each frame into a texture, discarding/reusing the textures once rendered, and playing the audio separately through XAudio2, however as well as writing a loader for at least one format, ive also got to deal with stuff like synchronising the video and audio components, so hopefully there is an eaier solution available or even a ready made free one with a suitable lisence (commercial distribution in binary form, dynamic linking is fine in the case of say LGPL).


回答1:


In Windows SDK, there is a DirectShow example for rendering video to texture. It handles audio output too.

But there are limitations and I can't honestly call it easy.




回答2:


Have you looked at Bink video? Its what lots of games use for video playback. Works great and you don't have to code all that video stuff yourself from scratch.



来源:https://stackoverflow.com/questions/1144609/displaying-a-video-in-directx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!