4

I am trying to record a video acquired from a webcam connect to the usb device. I am workin with Qt5.1.0 in 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-h-m-s");
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 in fact nothing is recorded.

If I change the line

   camera->setCaptureMode(QCamera::CaptureVideo);

for

   camera->setCaptureMode(QCamera::CaptureViewFinder);

No error is output, the file is generated, but it only contains 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 actually recorded.

avalero
  • 91
  • 1
  • 6
  • Sounds like the problem is related to the exact model of camera? – Mats Petersson Jul 15 '13 at 09:27
  • @MatsPetersson it does not seem to be that. I have tried with three different cameras and I am still getting the same error – avalero Jul 15 '13 at 09:49
  • The message "Could not negotiate format" seems to indicate that the camera doesn't support the format you are asking for, so either it's the camera or the format you are asking for that is wrong. – Mats Petersson Jul 15 '13 at 09:50

1 Answers1

3

I'm having almost the same problem, with capturing an image. I discovered that it is only working with the default resolution 640 x 480. If you set the resolution to a higher value it does not work. I've also tried with 2 different cameras with no success, so it seems to be a qt5 problem. You could try to don't set a resolution, then you should be able to record a video, but only with the default resolution of 640 x 480.

Hironimus
  • 46
  • 1
  • Thanks!, Removing the setResolution() works! although I keep getting the CameraBin error: ** "Could not encode stream." ** although in fact it records the video – avalero Jul 16 '13 at 06:39