通过AVISaveOptions这个函数可以弹出一个对话框,在里面可以选择avi的压缩格式和压缩百分比,但是我想在程序中实现,不要它弹出这个对话框,我要怎么办呢?

解决方案 »

  1.   

    I got rid of AVISaveOptions (with much pain) by using the debugger and finding out the values of the AVICOMPRESSOPTIONS structure after the dialog returned, and then hardwiring those values.  It may be the
    case that you have to set lpParms with the result of a GlobalAlloc (as opposed to just pointing it to a static long somewhere), because I tried that and it didn't work (but I may have done something else wrong then).  I've put in microsoft video 1 and cinepak as two examples.  I've only tried this on one machine so far. ...from (variation of) writeavi.c //turn on or off popup
    int DoPopupSelection = 0; _fmemset(&opts, 0, sizeof(opts)); if(DoPopupSelection) {
                    //old path, using dialog
    if (!AVISaveOptions(topParent, 0, 1, &ps,
    (LPAVICOMPRESSOPTIONS FAR *) &aopts)) {
    toglErr("toglSimpleAvi::open()\n"
    "error getting save options");
    toglErr("user message, error opening avi file "
    "(error on save options)");
    Cleanup();
    if(topParent != NULL) { DestroyWindow(topParent); }
    return 1;
    }
    } else {
                    //new path, using hardwired values //this is microsoft video 1 compression
    opts.fccHandler = 0x6376736d;
    opts.dwQuality = 10000;  //100% quality, 9000 would be 90%, etc.
    opts.dwFlags = 8;
    opts.lpParms = (LPVOID *)GlobalAlloc(NULL, 4);
    opts.cbParms = 4;
    *((long*)opts.lpParms) = 75; //this is cinepak
    opts.fccHandler = 0x64697663;
    opts.dwQuality = 10000;  //100% quality, 9000 would be 90%, etc.
    opts.dwFlags = 8;
    opts.lpParms = (LPVOID *)GlobalAlloc(NULL, 4);
    opts.cbParms = 4;
    *((long*)opts.lpParms) = 0x726c6f63; //uncompressed is all 0's I believe, (so just let ride
    //from _fmemset(&opts, 0, sizeof(opts));
    } hr = AVIMakeCompressedStream(&psCompressed, ps, &opts, NULL);
    if (hr != AVIERR_OK) {
    toglErr("toglSimpleAvi::open()\n"
    "error creating compressed stream");
    toglErr("user message, error opening avi file "
    "(couldn't create compressed stream)");
    Cleanup();
    return 1;
    } ...Submitted By: Jeff Mauldin (2002/01/18) 
      

  2.   

    谢谢版主,我已经试出来了,用video 5 压缩格式,可以压缩到30秒1M的效果。
      

  3.   

    我正在试xvid mpeg-4的 目前还没有结果
    对lpParams的赋值仍然不是很清楚