我写了一个视频采集程序,对采集到的视频进行压缩,用了ICSeqCompressFrame函数,可是它的返回总是NULL,谁知道大概是什么原因?谢谢。

解决方案 »

  1.   

    还有,当ICSeqCompressFrame调用产生错误的时候,怎么得到错误信息呀?
    请各位高手帮忙了。
      

  2.   

    我ICOpen,ICCompressGetFormat,ICSeqCompressFrameStart全部都返回正常,可是就是ICSeqCompressFrame返回总是空的。我的输入格式也应该没有问题。
      

  3.   

    class CSeqCompress  
    {
    public:
    CSeqCompress();
    virtual ~CSeqCompress(); BOOL InitDecompress();
    void CloseDecompress();
    void DecompressData(LPBYTE pData,LPBYTE pOutData,BOOL bKeyFrame);

    DWORD InitCompress();
    void CloseCompress();
    LONG CompressData(LPBYTE lpInData,LPBYTE lpOutData,BOOL *pbKeyFrame); COMPVARS pc; BITMAPINFOHEADER  biIn, biOut; //
    HIC hic;// BITMAPINFOHEADER bi,Dstbi;
    HIC dehic;
    int fccHandler;
    };#include "stdafx.h"
    #include "Avi.h"
    #include "SeqCompress.h"#ifdef _DEBUG
    #undef THIS_FILE
    static char THIS_FILE[]=__FILE__;
    #define new DEBUG_NEW
    #endif#define COLORBIT 24
    #define WIDTH 352
    #define HEIGHT 288#define CHOOSE
    //////////////////////////////////////////////////////////////////////
    // Construction/Destruction
    //////////////////////////////////////////////////////////////////////CSeqCompress::CSeqCompress()
    {
    /*
    fccHandler的值:
    879194221->Microsoft MPEG-4 Video CodecV1
    842297453->Microsoft MPEG-4 Video CodecV2
    c->Microsoft MPEG-4 Video CodecV3
    808810089->Indeo Video5.04
    2021026148->Divx mpeg4
    */
    // fccHandler=859074669;
    }CSeqCompress::~CSeqCompress()
    {}
    DWORD CSeqCompress::InitCompress()
    {
    biIn.biSize = sizeof(BITMAPINFOHEADER); 
    biIn.biBitCount =COLORBIT;              // 8 bits-per-pixel format 
      biIn.biCompression=BI_RGB;// standard RGB bitmap 
    biIn.biClrUsed = biIn.biClrImportant =0; 
    biIn.biPlanes = 1; 
    biIn.biXPelsPerMeter = biIn.biYPelsPerMeter = 3780; 
    biIn.biWidth = WIDTH;
    biIn.biHeight =HEIGHT; 
    biIn.biSizeImage = WIDTH*HEIGHT*(COLORBIT/8); 
    memcpy(&biOut,&biIn,40);
    /* hic = ICLocate (ICTYPE_VIDEO, fccHandler, (LPBITMAPINFOHEADER) &biIn, &biOut, ICMODE_COMPRESS); 
    //   hic = ICLocate (ICTYPE_VIDEO, 0L, (LPBITMAPINFOHEADER) &biIn, NULL, ICMODE_COMPRESS); 
       if(!hic)
    {
    AfxMessageBox("ICLocate error!");
    return FALSE;
    }
    */
    #ifdef CHOOSE
    pc.cbSize=sizeof(COMPVARS);
    pc.fccType=ICTYPE_VIDEO;
    pc.lpbiIn=(LPBITMAPINFO)&biIn;
    if(!(ICCompressorChoose(NULL,
    0|ICMF_CHOOSE_DATARATE|ICMF_CHOOSE_KEYFRAME|ICMF_CHOOSE_PREVIEW,//ICMF_CHOOSE_ALLCOMPRESSORS
    &biIn,NULL,&pc,"视频压缩选择")))
    {
    AfxMessageBox("ICCompressorChoose error!");
    return false;

    hic=pc.hic;
    fccHandler=pc.fccHandler;
    #else
    hic=ICOpen(mmioFOURCC('V','I','D','C'),fccHandler,ICMODE_COMPRESS);
    if(!hic)
    {
    AfxMessageBox("ICOpen error!");
    return 0;
    }
    pc.cbSize=sizeof(COMPVARS);
      pc.dwFlags=ICMF_COMPVARS_VALID;//Do not set this flag if you let ICCompressorChoose initialize this structure. 
    pc.hic=hic;
    pc.fccType=ICTYPE_VIDEO;
    pc.fccHandler=fccHandler;  
    pc.lpbiIn=(LPBITMAPINFO)&bihIn;
    pc.lpbiOut=(LPBITMAPINFO)&bihOut;//specify NULL to use the default compressor associated with the input format
    pc.lpBitsPrev=NULL;
    pc.lKey=25;
    pc.lQ=7500;//Quality setting
    pc.lDataRate=3000;
    pc.lFrame=0;
    pc.lKeyCount=5;
    pc.lpState=NULL;//(LPVOID)lpData;
    pc.lpState=0;
    pc.cbState=0;
    ICConfigure(hic,NULL);
    #endif
    biOut.biCompression=fccHandler;
    if(!(ICSeqCompressFrameStart(&pc,(LPBITMAPINFO)&biIn)))
    {
    AfxMessageBox("ICSeqCompressFrameStart error!");
    return false;
    } return fccHandler;
    }
    LONG CSeqCompress::CompressData(LPBYTE lpInData, LPBYTE lpOutData, BOOL *pbKeyFrame)
    {
    LONG lSize=0;
    LPBYTE lpTempData;
    lpTempData=(LPBYTE)ICSeqCompressFrame(&pc,0,lpInData,pbKeyFrame,&lSize);
    CopyMemory(lpOutData,lpTempData,lSize);
    return lSize;
    }void CSeqCompress::CloseCompress()
    {
    ICSeqCompressFrameEnd(&pc);
    ICClose(hic);
    ICCompressorFree(&pc);
    }
      

  4.   

    一般都用ICCompress的,不用ICSeqCompressFrame
      

  5.   

    duwenyong(啸海) :
    我用相同的方法取得MPEG4压缩后的数据
    ICOpen(ICTYPE_VIDEO, mmioFOURCC('m','p','g','4'), ICMODE_COMPRESS);
    但用ICDecompress解压总是出错
    请问为什么
    另请问能否把CSeqComress 的解压部分的代码给一份给我我可另起贴子把分数(100分)给你
      

  6.   

    你用什么压缩引擎,能用'm','p','g','4'?
      

  7.   

    用'm','p','g','4',据我知道,现在没有fcchandler为'm','p','g','4'的MPEG4算法呀?你是用哪个呀?MS的?那就MP42吧
    BOOL CSeqCompress::InitDecompress()
    {
    bi.biSize=40;
      bi.biCompression=fccHandler;
    bi.biBitCount=COLORBIT;
    bi.biClrImportant=bi.biClrUsed=0;
    bi.biPlanes=1;
    bi.biXPelsPerMeter=bi.biYPelsPerMeter= 3780;
    bi.biWidth=WIDTH;
    bi.biHeight=HEIGHT;
    bi.biSizeImage=WIDTH*HEIGHT*(COLORBIT/3);
    memcpy(&Dstbi,&bi,40);
    Dstbi.biCompression=BI_RGB;
    dehic=ICOpen(mmioFOURCC('V','I','D','C'),fccHandler,ICMODE_DECOMPRESS);
    if(!dehic)
    {
    AfxMessageBox("decompress ICOpen error!");
    return FALSE;
    }
    if(ICDecompressBegin(dehic,&bi,&Dstbi) != ICERR_OK)
    {
       AfxMessageBox("ICDecompressBegin error");
       return FALSE;
    }
    return TRUE;
    }void CSeqCompress::DecompressData(LPBYTE pData,LPBYTE pOutData,BOOL dwKeyFrame)
    {
    if(ICDecompress(dehic,0,&bi,pData,&Dstbi,pOutData)!=ICERR_OK)
    AfxMessageBox("ICDecompress error!");
    }void CSeqCompress::CloseDecompress()
    {
    ICDecompressEnd(dehic);
    }