C++ QMediareRecorder不记录任何内容

C++ QMediareRecorder不记录任何内容,c++,mingw,qt-creator,webcam,video-capture,C++,Mingw,Qt Creator,Webcam,Video Capture,我有一个从网络摄像机录制视频的程序。它在窗体中显示摄影机视图。单击开始按钮时,应开始录制视频,并在按下停止按钮后停止。程序编译得很好,但没有录制视频。有人能说它有什么问题吗? 这是我的密码 { camera = new QCamera(this); viewFinder = new QCameraViewfinder(this); camera->setViewfinder(viewFinder);

我有一个从网络摄像机录制视频的程序。它在窗体中显示摄影机视图。单击开始按钮时,应开始录制视频,并在按下停止按钮后停止。程序编译得很好,但没有录制视频。有人能说它有什么问题吗? 这是我的密码

 {      
            camera = new QCamera(this);
            viewFinder = new QCameraViewfinder(this);
            camera->setViewfinder(viewFinder);
            recorder = new QMediaRecorder(camera,this);

            QBoxLayout *layout = new QVBoxLayout;
            layout->addWidget(viewFinder);
            ui->widget->setLayout(layout);

            QVideoEncoderSettings settings = recorder->videoSettings();

            settings.setResolution(640,480);
            settings.setQuality(QMultimedia::VeryHighQuality);
            settings.setFrameRate(30.0);
            //settings.setCodec("video/mp4");

            recorder->setVideoSettings(settings);
            recorder->setContainerFormat("mp4");
            camera->setCaptureMode(QCamera::CaptureVideo);
            camera->start();
       }

        void usbrecorder::on_btn_Record_clicked()
        {                
            usbrecorder::startRecording();
        }

        void usbrecorder::on_btn_Stop_clicked()
        {
            usbrecorder::stopRecording();
        }


        void usbrecorder::startRecording()
        {              

            recorder->setOutputLocation(QUrl::fromLocalFile("C:\\Users\\Stranger\\Downloads\\Video\\vidoe_001.mp4"));
            recorder->record();
        }

        void usbrecorder::stopRecording()
        {
            recorder->stop();
        }

您需要指定输出位置:

QMediaRecorder::setOutputLocation(const QUrl& location)
e、 g


setOutputLocation(QUrl)file:///home/user/vid.mp4"));

尝试打印状态、状态和错误消息:

qDebug()<<record.state();
qDebug()<<record.status();
qDebug()<<record.error();

qDebug()这是由于Windows上的限制

如Qt文档中所述:

目前不支持视频录制。此外,DirectShow插件不支持任何低级视频功能,例如监视使用QVideoProbe或相关类播放或录制的视频帧


我已将路径指定为recorder->setOutputLocation(QUrl::fromLocalFile(“C:\\Users\\Undergrounds\\Downloads\\Video\\vidoe_001.mp4”);但它不起作用。