Jump to content
  • Advertisement
Sign in to follow this  
shvalb

Can DirectShow create an Avi file ??

This topic is 5008 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 wonder if DirectShow can create an AVI file ?? or it can only maniplute an existing one. If it can, is it possible to take a buffer from the backbuffer and sae it as a frame in an AVI file ? Thanks

Share this post


Link to post
Share on other sites
Advertisement
It certainly is possible to create an AVI using DirectShow, off the top of my head I can't recall the exact method I used. Have a look in the SDK under DirectShow Tutorials->Recompressing an AVI. That will give you a bit of an incite into how DirectShow writes to files.

Also, you might want to look at the PushSource bitmap set sample in the SDK, this is almost the opposite of the sample grabber in fucntionality.

Kind regards.

Mark Colemanp

Share this post


Link to post
Share on other sites
yeah, I'm familiar with the example of the avi compression, I even used it to compress some avi's, but I need to create an Avi from nothing, meaning, to take a buffer from the backbuffer and create a frame in a new fresh avi file.

what is the interface I have to use that knows how to receieve a buffer from memory ??

Thanks.

Share this post


Link to post
Share on other sites
yeah, but is there an interface of DirectShow that accepts a buffer as input and adds it as a frame in a fresh clean AVI file ?? if yes, which one is it ??

Thanks

Share this post


Link to post
Share on other sites
To the best of my knowledge, there isn't. You'll have to write a custom filter to push data from your backbuffer into the filter graph. It's not hard.

Share this post


Link to post
Share on other sites
There is. Take a look at this.
You'll just have to modify it to take the data from your source (direct3d backbuffer)

Share this post


Link to post
Share on other sites
I've never done it myself but I guess it would something like:


void copyBackBufferToMediaSample( IMediaSample* pSample )
{
// assuming pBBSurface is a surface returned by IDirect3DDevice9::GetBackBuffer
D3DLOCKED_RECT lockedRect;
pBBSurface->LockRect( &lockedRect, NULL, D3DLOCK_READONLY );

BYTE* pOutBuffer;
pSample->GetPointer( &pOutBuffer );

// assuming bbHeight is the height of the backbuffer surface
for( int y=0 ; y<bbHeight ; y++ )
{
// Here I'm assuming that your input and output formats are ARGB
//and so I copy bbWidth*4 bytes per line, that is 4 bytes per pixel
memcpy( pOutBuffer, lockedRect.pBits, bbWidth*4 );

// also, I don't know how to get the output pitch here,
// I suppose that if you're exporting a simple bitmap
// off this filter you'll only have to align it to 4 bytes
// at the end of each scanline.

// assuming outPitch is the pitch of the outputted image
pOutBuffer += outPitch;
lockedRect.pbits += lockedRect.Pitch;
}
}



I'm sorry for my bad english, I hope you'll understand.
Also, remember that I've never done this myself so I can be forgetting something here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!