qt creator using QMediaRecorder with usb cam in raspberrypi
-
i am trying to use usb cam with raspberry pi 3 to creat program that stream video from cam and record it . i am using qt creator to do that but there is a problem in QMediaRecorder after i record a video the video is just show one image please can any one help me to solve this problem . the code is here
#include "widget.h" #include "ui_widget.h" #include <QCamera> #include <QCameraViewfinder> #include <QCameraImageCapture> #include <QVBoxLayout> #include <QFileDialog> #include <QMediaRecorder> #include <QMediaService> #include <QCameraInfo> #include <QMediaMetaData> #include <QMessageBox> #include <QPalette> #include <QtWidgets> ui->setupUi(this); mCamera = new QCamera(this); mCameraViewfinder = new QCameraViewfinder(this); mCameraImageCapture = new QCameraImageCapture(mCamera,this); mCameraVideoRecord = new QMediaRecorder(mCamera,this); mLayout = new QVBoxLayout; mCamera->setViewfinder(mCameraViewfinder); mLayout->addWidget(mCameraViewfinder); ui->frame->setLayout(mLayout); } Widget::~Widget() { delete ui; } void Widget::on_PushButton_clicked(){ mCamera->setCaptureMode(QCamera::CaptureVideo); mCamera->start(); mCameraVideoRecord->record(); } void Widget::on_pushButton_clicked() { mCamera->setCaptureMode(QCamera::CaptureStillImage); mCamera->start(); // Viewfinder frames start flowing mCamera->searchAndLock(); mCameraImageCapture->capture(); mCamera->unlock(); } void Widget::on_pushButton_2_clicked() { mCameraVideoRecord->stop(); }
-
@mouaiad-salaas Which of the two slots, which have almost identical names (which is bad!) do you mean? Because one of them records still images...
-
@jsulm thank you very much for your reply .
yes it is right that bad but this is just a test .
the first one which has
mCamera->setCaptureMode(QCamera::CaptureVideo);
mCamera->start();
mCameraVideoRecord->record();
is to start record and the last one is to stop the recording -
the first one is to start recording
the second is to capture image and save it
the last one is to stop recordingthe image capture and save is working but video recording is not
please can you help me to solve it -
This post is deleted!
-
@mouaiad-salaas Please connect a slot to https://doc.qt.io/qt-5/qmediarecorder.html#error-1 and check what https://doc.qt.io/qt-5/qmediarecorder.html#errorString returns. You should always have error handling in your apps!
-
@jsulm
the code i add:
connect(mCameraVideoRecord, QOverloadQMediaRecorder::Error::of(&QMediaRecorder::error),
={
qDebug() <<"test error";
qDebug() << mCameraVideoRecord->errorString();
});application output :
11:09:36: Starting /home/pi/build-CameraTest-Desktop-Debug/CameraTest...
libEGL warning: DRI2: failed to authenticate
qt5ct: using qt5ct plugin
test error
"Service has not been started" -
@mouaiad-salaas You should take a look at https://doc.qt.io/qt-5/qtmultimedia-multimediawidgets-camera-example.html
-
@jsulm i used the example but now i cannot click on video button it seems like not activated
and i got this in application output :Unsupported media type: "{32595559-0000-0010-8000-00AA00389B71}"
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}"
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}"
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}"
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}"
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}"
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}" -
@mouaiad-salaas said in qt creator using QMediaRecorder with usb cam in raspberrypi:
Unsupported media type: "{47504A4D-0000-0010-8000-00AA00389B71}"
What media type did you configure?
-
i did not change any thing in the code just enabled the tabs where should i edit the media type??
-
@mouaiad-salaas I posted the link to the example...
-
Is there any resolution to the Unsupported media type issue? It appears the camera is returning a list of pixel formats and it doesn't like the YUY2 {32595559-0000-0010-8000-00AA00389B71} and Motion JPEG {47504A4D-0000-0010-8000-00AA00389B71} formats.I'm still trying to wrap my head around how to do camera configurations, and looking at the code in dscamerasession.cpp it doesn't look like there's much one can do to fix this issue but I haven't dug too deep in yet.I should note that the camera is working correctly, but the terminal is full of these messages when I hit QCamera::load() function, so I guess I'm just wondering if there's a way to hint to the camera class to ignore these formats ahead of time.Appears this works just fine in QT6 and QT5 doesn't support recording video anyway :P