I am trying to record video received from a webcam to connect to a USB device. I am working with Qt5.1.0 on Linux 64 bit.
I have the following code:
camera = new QCamera(this); viewFinder = new QCameraViewfinder(this); camera->setViewfinder(viewFinder); recorder = new QMediaRecorder(camera,this); QVideoEncoderSettings settings = recorder->videoSettings(); settings.setResolution(1280,720); settings.setQuality(QMultimedia::VeryHighQuality); settings.setFrameRate(30.0); recorder->setVideoSettings(settings); camera->setCaptureMode(QCamera::CaptureVideo); camera->start(); QString name = filename + QDateTime::currentDateTime().toString("dd.MM.yy-hms"); recorder->setOutputLocation(QUrl::fromLocalFile(outputpath + "/" + name + ".mp4")); recorder->record();
When I run this code, I get the following warning and error
CameraBin error: "Internal data flow error." CameraBin error: "Could not negotiate format"
And actually nothing is recorded.
If I changed the line
camera->setCaptureMode(QCamera::CaptureVideo);
for
camera->setCaptureMode(QCamera::CaptureViewFinder);
The error is not output, the file is generated, but it contains only one frame (fixed image)
If I remove this piece of code:
QVideoEncoderSettings settings = recorder->videoSettings(); settings.setResolution(1280,720); settings.setQuality(QMultimedia::VeryHighQuality); settings.setFrameRate(30.0);
I get two different errors:
CameraBin warning: "A lot of buffers are being dropped." CameraBin error: "Could not encode stream."
But the video is really recorded.
source share