How to Bundle all required codec in the AVI module

Posted on 2006-05-11
Last Modified: 2011-04-14
Hi Experts,
I had developed the program that let user record a avi file.

I used vfw.h lib for AVI record and avi codecs option dialog to let user choose what the codecs option need to be used.

This dialog list all AVI codecs that had installed all the computer as MicroSoft Video codec 1, Cinepak,...
If I want to used a codecs as Dix6.1 codecs I have to install this as separate software.

My problem is when I used AVI codecs dialog by AVISaveOption this list all the system codecs and have some codecs not work and have some unnecessary codecs for my application.
In addition to  I must to install Dix or MPEG coecs as separate if I want to use this, this is not advance for my appliction.

So now, I want to ask you if we have any way to bundle all required codecs (as Dix, MPEG1, MPEG4, MS Video Codec 1) to my required codecs I mean I want to list this by my self with own pop up codecs dialog not using AVISaveOptions(hwnd, 0, 1, &m_pAviStream, (LPAVICOMPRESSOPTIONS FAR *) &aopts)  to list and choose the codecs option.

Thanks in advance

Question by:CongUan
    LVL 8

    Expert Comment

    This is only idea:

    It is possible to list VCM codecs using DirectShow.

    CoCreateInstance(CLSID_SystemDeviceEnum, ..., (void **)&pSysDevEnum)

    and then

    pSysDevEnum->CreateClassEnumerator(CLSID_VideoCompressorCategory, ...);

    (see "Choosing a Compression Filter" topic in DirectShow doc)

    I don't know if you can interface this with your code (can you use codec name ?).


    Author Comment

    I thank you for this, but I had not used DirectShow in this,

    I used vfw to do record avi and choose the codecs option.

    The below is some my codes:

    if (FAILED(AVIFileOpen(&m_pAviFile, m_szFileName, OF_CREATE | OF_WRITE | OF_SHARE_EXCLUSIVE, NULL)))
                strcpy(m_szErrorMessage, "SetCodecsOption(): Unable to Create the Movie File");
                goto TerminateInit;
          ZeroMemory(&m_AviStreamInfo, sizeof(AVISTREAMINFO));
          m_AviStreamInfo.fccType = streamtypeVIDEO;
          m_AviStreamInfo.dwScale = m_dwScale;
          m_AviStreamInfo.dwRate = m_dwRate;
          m_AviStreamInfo.dwQuality = 10000;                                                            //      max quality

          m_AviStreamInfo.dwSuggestedBufferSize = nMaxWidth*nMaxHeight*4;
        SetRect(&m_AviStreamInfo.rcFrame, 0, 0, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight);
          strcpy(m_AviStreamInfo.szName, "Video Stream");
          if (FAILED(AVIFileCreateStream(m_pAviFile, &m_pAviStream, &m_AviStreamInfo)))
                strcpy(m_szErrorMessage, "SetCodecsOption(): Unable to Create Stream");
                goto TerminateInit;
          ZeroMemory(&m_AviCompressOptions, sizeof(AVICOMPRESSOPTIONS));

          if (!AVISaveOptions(hwnd, 0, 1, &m_pAviStream, (LPAVICOMPRESSOPTIONS FAR *) &aopts))
                AVISaveOptionsFree(1,(LPAVICOMPRESSOPTIONS FAR *) &aopts);
                goto TerminateInit;

    I used AVISaveOptions to list all the codecs in system
    But have some codecs don't need to use because it not work with AVI, and for more advance, I need bundle some codecs as Dix, MPEG1, or MPEG4 to my codecs.
    So I want to ask you if we can bundle codecs as Dix, MPEG1,... as own codecs with using a own pop up dialog.
    Please explain more if you can
    Thank in advance!

    LVL 8

    Accepted Solution

    "using a own pop up dialog." - I think that it is impossible. Note that AVICOMPRESSOPTIONS structure has lpParam member which is "Video-compressor specific data". Hence I cannot image creating own dialog and filling this structure manually.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
    C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
    The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now