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 API
    IltmmConvert* pConvert;   
    CoCreateInstance(&CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmConvert, (void**) &pConvert); 
    C++
    IltmmConvert* pConvert;   
    CoCreateInstance(CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, IID_IltmmConvert, (void**) &pConvert); 

    Note:

    Pick a compressor when splitting a non-AVI or a non-WAV file to avoid creating two huge uncompressed files.

  2. Set the source file as follows:

    C API
    BSTR bstr;   
    bstr = SysAllocString(L"c:\\Source.avi");   
    IltmmConvert_put_SourceFile(pConvert, bstr);   
    SysFreeString(bstr); 
    C++
    BSTR bstr;   
    bstr = SysAllocString(L"c:\\Source.avi");   
    pConvert->put_SourceFile(bstr);    
    SysFreeString(bstr); 

  3. Get the duration of the media as follows:

    C API
    double fDur;   
    IltmmConvert_get_Duration(pConvert, &fDur); 
    C++
    double fDur;   
    pConvert->get_Duration(&fDur); 

  4. Save the first small avi file as follows:

    C API
    bstr = SysAllocString(L"c:\\Avi1.avi");    
    IltmmConvert_put_TargetFile(pConvert, bstr);   
    SysFreeString(bstr);   
    IltmmConvert_put_SelectionEnd(pConvert, fDur/2);   
    IltmmConvert_StartConvert(pConvert); 
    C++
    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 API
    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++
    bstr = SysAllocString(L"c:\\Avi2.avi");    
    pConvert->put_TargetFile(bstr);   
    SysFreeString(bstr);   
    pConvert->put_SelectionStart(fDur/2);   
    pConvert->put_SelectionEnd(fDur);   
    pConvert->StartConvert(); 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Multimedia C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.