Click here to Skip to main content
Licence CPOL
First Posted 15 Dec 2005
Views 48,298
Downloads 1,162
Bookmarked 36 times

Displaying, Reading, and Writing AVI Files

By | 21 Aug 2006 | Article
Loading AVI files from inside other files, and saving them as files (also export the BMPs).

Introduction

I want to show a nice AVI to indicate to the user that my MFC-program is working. So I tried some stuff to work with AVI files, and looked at CP for getting AVI out files, but found none. So I wrote my own plain stuff which fulfills my needs. The file output is directed to the "C:" drive. For checking, I added another control which displays an AVI file.

Additionally, I found the article "Extracting AVI Frames" by A. Riazu, Shafiee, which gets the BMPs out of the AVI. I included it because, in that article, there is no sample project. Warning: there seems to be a bug in the code.

Demonstration

It demonstrates the use of Resource API and loading an AVI from a different file (shell32.dll), and the CAnimateCtrl from MFC and the included BMP export.

Sample screenshot

Code Snippets

For better understanding, here is some code with comments:

//one way: get Resource out of dll: dll Handle and ID of the resource and play infinitly 
if( pAnimateCtrl1->SendMessage( ACM_OPEN, (WPARAM) m_hDll, (LPARAM) m_uiResource ) )
{
    if( !pAnimateCtrl1->Play( 0, (UINT) -1, (UINT) -1 ) ) 
        TRACE( "Cannot play animated control. Reason: %d.\n", GetLastError() ); 
} 
//the second: open the file and play 
if( pAnimateCtrl2->Open( m_csAviExport ) )// 
{ 
    if( !pAnimateCtrl2->Play( 0, (UINT) -1, (UINT) -1 ) ) 
        TRACE( "Cannot play animated control. Reason: %d.\n", GetLastError() ); 
}

Conclusion

You got a working project which will help you to access and play AVI files, modify it for your needs. It is necessary to do this because the CAnimateCtrl of MS doesn't like all AVI formats.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

KarstenK

Software Developer

Germany Germany

Member

I am living in germany and now living from programming for some Years. In my spare time I like sports as jogging, playing football (soccer) and basketball.
 
We must take care for our planet, because we and our family has no other. And everybody has to do something for it.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generaljust a little advise PinmemberRoman Tarasov0:02 1 Feb '10  
GeneralRe: just a little advise PinmemberKarstenK0:43 1 Feb '10  
GeneralMy vote of 1 Pinmemberdxlee3:48 6 Oct '09  
GeneralPlease explain the application and code :-) PinmemberCorinna John6:35 6 May '06  
GeneralRe: Please explain the application and code :-) PinmemberKarstenK22:15 7 May '06  
GeneralThis needs a small effort of explanation... PinmemberMohamed Abu Abdillah7:03 16 Dec '05  
GeneralRe: This needs a small effort of explanation... PinmemberKarstenK23:53 19 Dec '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 21 Aug 2006
Article Copyright 2005 by KarstenK
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid