Direct Show.
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
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).
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).
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
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
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].
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]
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]
Hey darookie, you are right! Indeo 5.10 supports alpha channel! Wheeee! Look into it mrmrcoleman.
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
I will post back here with my findings if you are interested?
Mark Coleman
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]
[Edited by - CodeMunkie on September 17, 2004 11:31:03 AM]
Even using GraphEdit I can't make any of the encoder filters output a 32bit video. I don't think it is possible with AVI. Happy feelings gone :(.
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
Thanks in advance.
Mark Coleman
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement