c++ - Recording Video from USB Cam with Qt5 -


i trying record video acquired webcam connect usb device. workin qt5.1.0 in linux 64 bit.

i have 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 run code following warning , error

camerabin error: "internal data flow error."  camerabin error: "could not negotiate format" 

and in fact nothing recorded.

if change line

   camera->setcapturemode(qcamera::capturevideo); 

for

   camera->setcapturemode(qcamera::captureviewfinder); 

no error output, file generated, contains 1 frame (fixed image)

if remove piece of code:

qvideoencodersettings settings = recorder->videosettings(); settings.setresolution(1280,720); settings.setquality(qmultimedia::veryhighquality); settings.setframerate(30.0); 

i 2 different errors:

camerabin warning: "a lot of buffers being dropped."  camerabin error: "could not encode stream."  

but video recorded.

i'm having same problem, capturing image. discovered working default resolution 640 x 480. if set resolution higher value not work. i've tried 2 different cameras no success, seems qt5 problem. try don't set resolution, should able record video, default resolution of 640 x 480.


Comments