我正在尝试使用我在网上找到的示例(不记得确切的来源)以编程方式从位图生成 AVI 文件。
这是我获取选项的代码
unsafe private void SetOptions() {
AVICOMPRESSOPTIONS opts = new AVICOMPRESSOPTIONS();
opts.fccType = 0; //fccType_;
opts.fccHandler = 541215044;//0;//fccHandler_;
opts.dwKeyFrameEvery = 0;
opts.dwQuality = 0; // 0 .. 10000
opts.dwFlags = 8;//0; // AVICOMRPESSF_KEYFRAMES = 4
opts.dwBytesPerSecond = 0;
opts.lpFormat = (System.IntPtr)0; //new IntPtr(0);
opts.cbFormat = 0;
opts.lpParms = (System.IntPtr)0; //new IntPtr(0);
opts.cbParms = 3232;//0;
opts.dwInterleaveEvery = 0;
AVICOMPRESSOPTIONS* p = &opts;
AVICOMPRESSOPTIONS** pp = &p;
IntPtr x = ps_;
IntPtr* ptr_ps = &x;
AVISaveOptions(0,0,1,ptr_ps,pp);
// TODO: AVISaveOptionsFree(...)
int hr = AVIMakeCompressedStream(out psCompressed_, ps_, ref opts, 0);
if (hr != 0) {
throw new AviException("AVIMakeCompressedStream");
}
BITMAPINFOHEADER bi = new BITMAPINFOHEADER();
bi.biSize = 40;
bi.biWidth = (Int32) width_;
bi.biHeight = (Int32) height_;
bi.biPlanes = 1;
bi.biBitCount = 24;
bi.biCompression = 0; // 0 = BI_RGB
bi.biSizeImage = stride_*height_;
bi.biXPelsPerMeter= 0;
bi.biYPelsPerMeter= 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
hr = AVIStreamSetFormat(psCompressed_, 0, ref bi, 40);
if (hr != 0) {
throw new AviException("AVIStreamSetFormat",hr);
}
}
Run Code Online (Sandbox Code Playgroud)
然而,我不想显示 AVISaveOptions 对话框,并且更喜欢在后端完成这一切,我已经搜索了几个小时,但到目前为止没有发现任何非常有用的东西,除了这个: https: //groups.google。 com/forum/#!topic/microsoft.public.win32.programmer.mmedia/jH0d3H2orOo
所以我的问题是,在不显示对话框的情况下如何解决这个问题,和/或如何以编程方式填充压缩选项?
最终通过注册表获取所有已安装编解码器的列表,然后创建 FourCC 并使用它来设置 fccType 和 fccHandler。
| 归档时间: |
|
| 查看次数: |
2283 次 |
| 最近记录: |