Sign in to follow this  

Direct Show.

This topic is 4836 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

Hello. I have an application which uses Direct Show to render video to Direct3D textures (as in the Texture 3D9 example in the SDK)which I then use in my interface. The problem I have is that some of the files are extremely large and I am encountering all sorts of problems. The current videos output ARGB32 data and the larger ones are 4-5 seconds long at 800x600. Is it possible to compress these files whilst retaining the ARGB32 output when they are decompressed? At the moment my filter graph is as below: Source -> AVI Splitter -> Custom Renderer Hopefully I could achieve something as in the below: Source -> Decompressor -> AVI Splitter -> Custom Renderer Any help would be greatly appreciated, I would rather find out from you guys if this is possible before I dive in head first only to find that I have wasted my time. Thanks in advance. Mark Coleman

Share this post


Link to post
Share on other sites
800x600?? You do realize that that produces 1024x1024x32 textures (about 6.5 MB including MIP maps) each frame?. If the videos are 30fps you're swapping out 195MB of texture data each second + creation of mip maps. Without mip maps you'll merely swap 120MB each second.

I made a 3d video player myself using the Video Texture sample. Playing a 512x384 file was ok, but if I tried to play a file that was more than 512 pixels in any direction it was extremely jerky.

What are you using it for?

If it's an in-game monitor that displays a video file it would probably be better to loose some resolution. If you go below 512 (512x384 has the same aspect ratio as 800x600) you'll cut the above figures in 4 (49MB with MIP maps and 30 without). Much more managable.

If you have to cache the data you can probably output the video frame to a DXT compressed texture surface in advance and swap the texture maps each frame. It will still require a lot of data movement and the texture map generation will use a lot of CPU power. Memory will probably also be a problem. DXT compressed images are usually compressed 6:1, so 4 seconds at 30fps 800x600 (1024x1024) requires about 130MB of memory (and diskspace if you decide to store the compressed surfaces on disk to avoid having to decode the avi during runtime). Uncompressed it's 780MB.

EDIT: I'm not sure what you mean by compressing the files tho.
I was assuming that the files were normal AVI files compressed with divx or something. If you mean that the AVI files are stored as raw image (IE several 100MB for 4 seconds), then yes. And possibly no, if you have alpha encoded in the AVI (I'm not sure how to do that [smile]). If the AVI files are uncompressed you can compress them using a codec such as MPEG1, MPEG2, MPEG4, DivX, Xvid etc. This will reduce filesize and also the amount of data you need to read from the disk (if they're uncompressed that's probably a big bottleneck). Directshow will load the correct codec and decompress the file. I played 512x384x30fps xvid compressed file fine in my 3d video app (spinning quad with video [smile]). The "textureswap data rate" will still be the same tho (195MB or 120MB for 800x600 and 49MB or 30MB for 512x384).

Share this post


Link to post
Share on other sites
Thankyou Frostburn, for your quick response, but I have one last question.

Is it actually possible to compress an AVI in in the format ARGB32? I have heard some people say that it is not possible to compress an AVI that has an alpha channel?!

Mark Coleman

Share this post


Link to post
Share on other sites
Quote:
Original post by mrmrcoleman
Thankyou Frostburn, for your quick response, but I have one last question.

Is it actually possible to compress an AVI in in the format ARGB32? I have heard some people say that it is not possible to compress an AVI that has an alpha channel?!

Mark Coleman

Yes it is possible. There are avi codecs out there that support alpha (can't remember where - just google for them[wink]). If you just need masking, I'd suggest using a simple colorkey, though.
Alternativly you can still use two avi streams (the color and a seperate gray-scale alpha stream), which you can mix at runtime
using mutli-texturing. The alpha texture only needs to be A8 format and can be scaled down by a factor of two or four so it should not add too much overhead.

Thinking about it - I'd go for the second approach [smile].

Share this post


Link to post
Share on other sites
I just went through this myself ;). It is true, there is no AVI compression that will preserve the alpha channel. I would recommend using the QuickTime format (.mov) along with MPEG4 compression. QuickTime does have the ability to compress and preserve the alpha channel. Good luck!

EDIT: darookie, if you can think of the name of one that would be great. All of my searches turned up negative and the people I asked (who do video production) said they do not think it is possible and recommended QuickTime. I would rather use AVI. Thanks!

[Edited by - CodeMunkie on September 17, 2004 10:13:46 AM]

Share this post


Link to post
Share on other sites
Cheers guys that is a huge help, I am on a tight schedule and changing all my code to combine two streams at this point would leave me up shit creek with a distinct lack of padelling equipment.

I will post back here with my findings if you are interested?

Mark Coleman

Share this post


Link to post
Share on other sites
Yes please post back. I am now having a problem that is Premiere related. I have installed the Indeo 5.1 codec and can select it in Video Settings under Export Movie. The problem is, I only get the option for Depth of Millions and not Millions+ (millions of colors +alpha channel). Even if I click Configure and select alpha channel for transparency in the Encoder options window it still does not save the alpha channel. If I select QuickTime for the file type, I can select Millions+, just not if I select AVI :(. Let me know if you get this working and what program you use fom video editing. Thank you!

[Edited by - CodeMunkie on September 17, 2004 11:31:03 AM]

Share this post


Link to post
Share on other sites
Bollocks!! I got the same results guys, can't get it to work in 32-bit!! Now I really am screwed, does anybody know how I would go about converting 32bit AVI's to Quicktime? If I convert to Quicktime will I still be able to compress the files or are Quicktime files automatically compressed?

Thanks in advance.

Mark Coleman

Share this post


Link to post
Share on other sites
mrmr, try HuffyUV. I found it just before I left work so I did not really get a chance to play with it, but it did spit me out a 32bit compressed AVI. Hope it works for you. I could not get it to work with my old VFW code, but DirectShow was no problem.

Share this post


Link to post
Share on other sites
Hello.

I have successfully compressed some ARGB2 video files and the alpha is retained. The files are in some cases 33% of their original size and the performance is much better, however there is just one question that I have.

The output from the AVI decompressor is RGB32 not ARGB32 which my Custom Renderer accepts. Directshow kindly inserts a Colour Space Filter for me and converts the RGB32 to an ARGB32 but is this acceptable?? Will the alpha still be present Is looks like it is when rendered, but I just need to know for sure..

Actually I lied there is another question :)

Codemunkie, you metioned that you have done this kind of thing before. Did you notice that you ever had white flashes on the texture where the video should have been rendered? I keep getting these and I can't get them to go away, any ideas?

Thanks in advance.

Mark Coleman

Share this post


Link to post
Share on other sites

This topic is 4836 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