Link to home
Start Free TrialLog in
Avatar of dmetzler
dmetzler

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dmetzler
dmetzler

ASKER

So, basically, read in all the streams and then write them out to a new file with the AVICOMPRESSOPTIONS structure set?
Right.
Thanks...
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
// 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)
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.
Chensu,

The exact result from AVISaveV() is: 2147762289 (DWORD).
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.
Thanks...guess I need to look at the MAKE_SCODE macro.

Don