我正在尝试录制 QMediaPlayer 播放的视频。稍后我需要在它上面放置一个简单的小部件(覆盖)。实施它的最佳方法是什么?这是我的变体,但它不生成任何文件:
班级成员:
QWidget* parentWidget;
QMediaPlayer* mediaPlayer;
QVideoWidget* videoWidget;
QMediaRecorder *mediaRecorder;
记录功能:
mediaPlayer = new QMediaPlayer(parentWidget);
mediaRecorder = new QMediaRecorder(mediaPlayer);
videoWidget = new QVideoWidget;
mediaPlayer->setVideoOutput(videoWidget);
mediaPlayer->setSource(QUrl::fromLocalFile("C:/DJI_0051.MP4"));
mediaRecorder->setVideoResolution(1920, 1080);
mediaRecorder->setQuality(QMediaRecorder::HighQuality);
mediaRecorder->setOutputLocation(QUrl::fromLocalFile("C:/DJI_0051_EDITED.MP4"));
mediaRecorder->setVideoFrameRate(60);
QMediaFormat mediaFormat;
mediaFormat.setAudioCodec(QMediaFormat::AudioCodec::AAC);
mediaFormat.setVideoCodec(QMediaFormat::VideoCodec::H264);
mediaFormat.setFileFormat(QMediaFormat::MPEG4);
mediaRecorder->setMediaFormat(mediaFormat);
mediaPlayer->play();
mediaRecorder->record();