Click here to Skip to main content
6,631,404 members and growing! (18,338 online)
Email Password   helpLost your password?
Multimedia » Audio and Video » General     Beginner

AVI2BMP

By Danila Markelov

Converter from AVI file to BMP file(s)
VC6, Windows, MFC, Dev
Posted:3 Jul 2004
Views:35,096
Bookmarked:21 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
16 votes for this article.
Popularity: 2.68 Rating: 2.22 out of 5
7 votes, 43.8%
1
3 votes, 18.8%
2

3
2 votes, 12.5%
4
4 votes, 25.0%
5

Introduction

This is a very small console program to convert video in AVI format into BMP file or files. I guess that's all that I can tell about this program. Oh, once more. I use some pragma directives to reduce the size of a program. That's all.

Using the code

OK! In my program I use standart way to extract one frame from AVI file and save it into BMP file. There's nothing special or secret in it. Just standard Win32 API and VFW API. That's all!

// Some steps:

  char   AVIFileName[_SIZE]={0};
 AVIFILE   aviFile;
 PAVISTREAM  aviStream;
 AVISTREAMINFO  aviStreamInfo;

 AVIFileInit();
 AVIFileOpen(&aviFile,AVIFileName,OF_READ,NULL);
 AVIFileGetStream(aviFile,&aviStream,streamtypeVIDEO,0);
 AVIFileRelease(aviFile);
 AVIStreamInfo(aviStream,&aviStreamInfo,sizeof(aviStreamInfo));

// OK! Now we can extract any frame from AVI stream!


 BITMAPFILEHEADER BMPFileHeader;
 LPBITMAPINFOHEADER lpbi;
 PGETFRAME  pgf;

 pgf=AVIStreamGetFrameOpen(aviStream,NULL); 
 lpbi=(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf,fr);
 BMPFileHeader.bfType=0x4d42;
 BMPFileHeader.bfSize=(DWORD)(sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage);
 BMPFileHeader.bfReserved1=0;
 BMPFileHeader.bfReserved2=0;
 BMPFileHeader.bfOffBits=(DWORD)sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  lpbi->biClrUsed*sizeof(RGBQUAD);

// Than create file to save frame and write BMP sections into it!


 WriteFile(hFile,(LPVOID)&BMPFileHeader,sizeof(BITMAPFILEHEADER),
  (LPDWORD)&lpNumberOfBytesWritten,NULL);
 WriteFile(hFile,(LPVOID)lpbi,sizeof(BITMAPFILEHEADER)+lpbi->biSize+
  lpbi->biClrUsed*sizeof(RGBQUAD)+lpbi->biSizeImage,
  (LPDWORD)&lpNumberOfBytesWritten,NULL);

// And in the end make some clean!


 AVIStreamGetFrameClose(pgf);

// We can save one more frame or finish or work.


 AVIFileExit();

History

OK! I want to correct some error handlers, but may be next time.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Danila Markelov


Member

Location: Russian Federation Russian Federation

Other popular Audio and Video articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 7 of 7 (Total in Forum: 7) (Refresh)FirstPrevNext
QuestionHelp !!! PinmemberDinterinBebin6:31 29 Aug '07  
GeneralUpdated code PinmemberJArdussi9:03 11 Jul '07  
Generalalthough don't explain well, but it help me, thanks for share Pinmemberikohl3:59 8 Jul '07  
Generalerror while building PinmemberJohotech7:18 19 Jun '07  
Generalwhy? Pinmemberbyrz6:48 3 Jun '07  
GeneralHmmm PinmemberPatrik Svensson7:41 4 Jul '04  
GeneralRe: Hmmm PinmemberWREY12:18 4 Jul '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 3 Jul 2004
Editor:
Copyright 2004 by Danila Markelov
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project