Compress an existing AVI file?

I have an AVI file which I want to be able to open and compress and then resave.

The purpose of this is to be able to take an uncompressed AVI file and compress with various options to compare file sizes.

I am familiar with reading in AVI streams, but am uncertain on how to take existing uncompressed streams and compress them.

Thanks,

Don
dmetzlerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
When you use the AVISave function, pass the AVICOMPRESSOPTIONS structure containing the compression options. The AVISave function in turn uses the AVIMakeCompressedStream function.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dmetzlerAuthor Commented:
So, basically, read in all the streams and then write them out to a new file with the AVICOMPRESSOPTIONS structure set?
0
chensuCommented:
Right.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

dmetzlerAuthor Commented:
Thanks...
0
dmetzlerAuthor Commented:
Chensu,

I have my AVI streams loaded (2, actually - one DIB image and one WAV stream).  If I try to manipulate the fccHandler to 'MSVC' then the AVISaveV() function fails.

Where can I details about the results of a AVISaveV() failure?

Now - if I use the AVISaveOptions() function and select "Microsoft Video 1" then the compression is valid in the file (though the single image frame AVI does not change size from the original).

Can you help?

Thanks,

Don
0
chensuCommented:
// From vfw.h, hope this helps.

#ifndef AVIERR_OK
#define AVIERR_OK               0L

#define MAKE_AVIERR(error)      MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x4000 + error)

// !!! Questions to be answered:
// How can you get a string form of these errors?
// Which of these errors should be replaced by errors in SCODE.H?
#define AVIERR_UNSUPPORTED      MAKE_AVIERR(101)
#define AVIERR_BADFORMAT        MAKE_AVIERR(102)
#define AVIERR_MEMORY           MAKE_AVIERR(103)
#define AVIERR_INTERNAL         MAKE_AVIERR(104)
#define AVIERR_BADFLAGS         MAKE_AVIERR(105)
#define AVIERR_BADPARAM         MAKE_AVIERR(106)
#define AVIERR_BADSIZE          MAKE_AVIERR(107)
#define AVIERR_BADHANDLE        MAKE_AVIERR(108)
#define AVIERR_FILEREAD         MAKE_AVIERR(109)
#define AVIERR_FILEWRITE        MAKE_AVIERR(110)
#define AVIERR_FILEOPEN         MAKE_AVIERR(111)
#define AVIERR_COMPRESSOR       MAKE_AVIERR(112)
#define AVIERR_NOCOMPRESSOR     MAKE_AVIERR(113)
#define AVIERR_READONLY            MAKE_AVIERR(114)
#define AVIERR_NODATA            MAKE_AVIERR(115)
#define AVIERR_BUFFERTOOSMALL      MAKE_AVIERR(116)
#define AVIERR_CANTCOMPRESS      MAKE_AVIERR(117)
#define AVIERR_USERABORT        MAKE_AVIERR(198)
#define AVIERR_ERROR            MAKE_AVIERR(199)
0
dmetzlerAuthor Commented:
Yes - I am familiar with those, but the return code is a rather large number (something like 250938793 as a DWORD).

Will get exact results and post them.
0
dmetzlerAuthor Commented:
Chensu,

The exact result from AVISaveV() is: 2147762289 (DWORD).
0
chensuCommented:
That is AVIERR_NOCOMPRESSOR, meaning that you don't have that CODEC installed.

AVIERR_NOCOMPRESSOR is MAKE_SCODE(SEVERITY_ERROR, FACILITY_ITF, 0x4000 + 113) instead of 113.
0
dmetzlerAuthor Commented:
Thanks...guess I need to look at the MAKE_SCODE macro.

Don
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.