Click here to Skip to main content
Click here to Skip to main content

Copy a period of AVI chunks

By , 22 May 2006
 

Introduction

Generally, we have two mothods to copy a period of AVI video.

  • Use AVIStreamGetFrame and AVIStreamWriteData. The disadvantage of this method is it will cost a long time and generate a very big output file (uncompressed), especially when copying a long period.
  • Use EditStreamCopy and EditStreamPaste. This can give the user a chance to select an encoder, and use this encoder to compress the output file. Still, the output file is always more than 10 times the same period of the input file, and also this will cost a very long time.

How to Copy AVI Chunks

Basicly, the format of AVI files should like this:

RIFF                   RIFF HEADER
|-AVI                  AVI CHUNK  
  |-hdrl               MAIN AVI HEADER
  | |- ......          OTHER HEADER INFORMATION
  |-movi               MOVIE DATA
  | |-chunk1           chunk data
  | |- ......          chunk data
  | |-chunkn           chunk data
  |-idx1               AVI INDEX
    |-[index data]     DATA

So, we can copy the chunks of certain periods to the output file by the following steps:

  • Copy header.
  • Copy chunks.
  • Reconstruct index data.
  • Correct some data of the header, such as the file length and the data length.

Advantages and Disadvantages

This methed can run very fast, and the size of the output files corresponds to the input file. Still the disadvantages are obvious too. This class depends on the codec and may not work for some kinds of AVI files.

How to Use

The only code required to use this class is:
CCopyAVIChunk copier;
copier.CopyFile("C:\\tests\\test1.avi", "C:\\tests\\test2.avi", 123, 765);

Comments

I use this class for certain projects, so I only care if it can work with "those" kind of AVI files. Still I have no chance to test for general AVI files. If you are interested in this class and finds it can't work, please feel free to contact me at yinglong_w@hotmail.com.

Version History

  • Version 1.0 - posted May 23, 2006 to CodeProject.

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

Denny50
Software Developer (Senior)
Australia Australia
Member
Senior software engineer with 10 years experience of C/C++ programming. Now also has some project with C#. I'm from Shanghai and now working at Melbourne. At I spare time, I enjoy my family life. My blog, Childhood is a collection about my family, epically my lovely son. Most of them write in Chinese, and a few in my poor English - please forgive me, I'm improving my English as soon as I can.

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questioncombining avi video filesmembersukumarvenkata18 May '08 - 19:09 
Questionhow to create parser filters.memberamiya das27 Sep '07 - 0:15 
GeneralNo souce code for the main functionmemberSuper Garrison11 Sep '07 - 12:02 
GeneralCant compile in Visual Studio 2005memberZysen(CodeProjectSpam)8 Apr '07 - 18:11 
GeneralHimembernaraimha27 Dec '06 - 18:30 
GeneralDemuxing MP3memberjfdoubell10 Jul '06 - 8:10 

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 23 May 2006
Article Copyright 2006 by Denny50
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid