You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自行编译OpenCV程序仅识别MJPG编解码器问题求助

编解码器检测异常问题

运行预编译版本的程序时,能识别本机上的大量压缩编解码器;但因复杂需求自行使用Python、OpenCV等编译程序后,仅能识别MJPG这一种压缩编解码器。不确定该问题是由编译方式、软件版本、路径配置还是编解码器检测逻辑导致。

以下是程序检测编解码器的代码:

void backEnd::testCodecSupport()
{
    // This function will test which codecs are supported on host's machine
    cv::VideoWriter testVid;
//    testVid.open("test.avi", -1,20, cv::Size(640, 480), true);
    QVector<QString> possibleCodec({"DIB ", "MJPG", "MJ2C", "XVID", "FFV1", "DX50", "FLV1", "H264", "I420","MPEG","mp4v", "0000", "LAGS", "ASV1", "GREY"});
    for (int i = 0; i < possibleCodec.length(); i++) {
        testVid.open("test.avi", cv::VideoWriter::fourcc(possibleCodec[i].toStdString()[0],possibleCodec[i].toStdString()[1],possibleCodec[i].toStdString()[2],possibleCodec[i].toStdString()[3]),
                20, cv::Size(640, 480), true);
        if (testVid.isOpened()) {
            m_availableCodec.append(possibleCodec[i]);
            qDebug() << "Codec" << possibleCodec[i] << "supported for color";
            testVid.release();
        }
        else
            unAvailableCodec.append(possibleCodec[i]);
    }
}

编译环境及设备信息如下:

  • Windows 10家庭版21H2
  • 程序为Win32架构
  • 使用QT Creator(Desktop QT 5.15.2 MSVC2019 32bit)
  • 通过Microsoft Visual C++编译器编译
  • Python 3.1
  • OpenCV 4.5.5

内容的提问来源于stack exchange,提问作者hw22s

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 06:54:09