Split a Large AVI Into Smaller Files

The following steps will split a large AVI into 2 smaller files.

1.

Create an instance of the ltmmConvert class. This is accomplished using the Win32 CoCreateInstance function as follows:

C Source

IltmmConvert* pConvert;

CoCreateInstance(&CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmConvert, (void**) &pConvert);

C++ Source

IltmmConvert* pConvert;

CoCreateInstance(CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, IID_IltmmConvert, (void**) &pConvert);

"font-weight:bold; ">Note:

If you split a non-AVI or a non-WAV file you might want to pick a compressor, or you will get two huge uncompressed files.

 

2.

Set the source file as follows:

C Source

BSTR bstr;

bstr = SysAllocString(L"c:\\Source.avi");
IltmmConvert_put_SourceFile(pConvert, bstr);
SysFreeString(bstr);

C++ Source

BSTR bstr;

bstr = SysAllocString(L"c:\\Source.avi");
pConvert->put_SourceFile(bstr); 
SysFreeString(bstr);

 

3.

Get the duration of the media as follows:

C Source

double fDur;
IltmmConvert_get_Duration(pConvert, &fDur);

C++ Source

double fDur;
pConvert->get_Duration(&fDur);

 

4.

Save the first small avi file as follows:

C Source

bstr = SysAllocString(L"c:\\Avi1.avi"); 
IltmmConvert_put_TargetFile(pConvert, bstr);
SysFreeString(bstr);

IltmmConvert_put_SelectionEnd(pConvert, fDur/2);

IltmmConvert_StartConvert(pConvert);

C++ Source

BSTR bstr;

bstr = SysAllocString(L"c:\\Avi1.avi"); 
pConvert->put_TargetFile(bstr);
SysFreeString(bstr);

pConvert->put_SelectionEnd(fDur/2);

pConvert->StartConvert();

5.

Save the second small avi file as follows:

C Source

bstr = SysAllocString(L"c:\\Avi2.avi"); 
IltmmConvert_put_TargetFile(pConvert, bstr);
SysFreeString(bstr);

IltmmConvert_put_SelectionStart(fDur/2);
IltmmConvert_put_SelectionEnd(pConvert, fDur);

IltmmConvert_StartConvert(pConvert);

C++ Source

bstr = SysAllocString(L"c:\\Avi2.avi"); 
pConvert->put_TargetFile(bstr);
SysFreeString(bstr);

pConvert->put_SelectionStart(fDur/2);
pConvert->put_SelectionEnd(fDur);

pConvert->StartConvert();