Sign in to follow this  

[SOLVED]Playing video file(avi) in Directx9

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,
i have some question;

1- i need to know how can i play a video file in directx.
(i need the best and easiest way)

2- i saw a sample in nvidia directx sdk 9 with name video filter, this code was very complicated, and i understood that sample convert video file in to texture then render that texture over a mesh.(in MDX you can do this in about 5 lines)
is this technique better or play in another window?

3- witch of those techniques have been used in big games?

i'm using directx 9 and c++

[Edited by - hossainiir on September 4, 2010 8:45:45 AM]

Share this post


Link to post
Share on other sites
Well when do you want your video to play in your game? Is it supposed to be in a scene like on a TV mesh in the background or just as a cutscene or intro style where it takes up the full screen?

If it's the first then you'll have to find a library to decode whichever format you're loading in and take a texture from that frame by frame to put as a texture for your model.

If it's the latter you can either do the same thing for a full screen quad or find a library that will just play it straight to the screen for you. I'm afraid I don't know of any that do that in c++ I haven't had much experience with doing that.

Share this post


Link to post
Share on other sites
Most commercial games use Bink Video to play video cutscenes over a DirectX application. Problem is, it's not free for use, and it require a re-encoding of the video in their format, .bnk. Anyway, what's a "normal" .avi? It can also be encoded using a multitude of codecs, and you don't necessarily want to force the player to install DivX or XViD to play.

Share this post


Link to post
Share on other sites
First google result for "playing video in directx" gave me this site:

http://www.programmersheaven.com/2/FAQ-DIRECTX-Play-Video-File(MPEG-and-AVI)

Something you could do, assuming this isn't for a commercial project is just take their code sample and hijack it at some point to pull out the texture and sound if you want sound or alternatively find some way of passing through a reference to a surface. After that all you have to do is use that surface anyway you want, just make sure to update the video player each frame.

Share this post


Link to post
Share on other sites
Our very own gamedev has a good tutorial on using .AVI.

One of the problems you run into (and which Bink solves) is that a .avi file can be encoded with any number of of codecs, either VFW (video for windows) or DirectShow type. You have to ensure that your end-user has the same codec as your content is using. Many of the codecs are free to use, but generally cannot be shipped with your app without licensing. In that case, instead of installing the codec, you could direct your users where to go get it - not that cool.

Share this post


Link to post
Share on other sites
thanks Scoob Droolins.
i found a sample that used bassclasses, and i compiled this BaseClasses solution and then, i'm using strmbasd.lib.
and now when i'm compile this sample this error occure:

error LNK2019: unresolved external symbol "public: __thiscall CBaseVideoRenderer::CBaseVideoRenderer(struct _GUID const &,char *,struct IUnknown *,long *)" (??0CBaseVideoRenderer@@QAE@ABU_GUID@@PADPAUIUnknown@@PAJ@Z) referenced in function "public: __thiscall CTextureRenderer::CTextureRenderer(struct IUnknown *,long *)" (??0CTextureRenderer@@QAE@PAUIUnknown@@PAJ@Z)

i found this :
http://www.gamedev.net/community/forums/topic.asp?topic_id=253818

but have't any answer.
any body know the solution??

Share this post


Link to post
Share on other sites
LNK2019 solved by setting "Use Unicode Character Set " in "Character set".

guestgulkan in cplusplus.com gave me this link:
http://social.msdn.microsoft.com/Forums/en-US/windowsdirectshowdevelopment/thread/0cae80fb-6ed7-4c19-8d5c-b45a98c2afdb

Share this post


Link to post
Share on other sites
I would forget direct show, have you looked into the royalty free format like off and theora?

I use libtheoraplayer library, which basically wraps the off theory code into a useable format I then copy the frame contents to a surface and apply it to a fillscreen quad or a texture its very flexible and handles all my videos great and without all the royalty issues with other video formats

Share this post


Link to post
Share on other sites
thanks Jamoflaw,
it's seems good site.

finally ,by using video filter sample(nvidia directx sdk)and BaseClasses and chapter 11 of "DirectX 9 Graphics - The Definitive Guide to Direct3D" i coulde render a avi file to texture, and worked good.

thanks all ,for reply.

Share this post


Link to post
Share on other sites
wouldnt a video in a texture be classed as a gif file?
Ive found a library you might be interested in...
http://sourceforge.net/projects/dsdxlibrary

Share this post


Link to post
Share on other sites

This topic is 2661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this