0

I am trying to use usb cam with raspberry pi 3 to create a 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();
}
Elyas Karimi
  • 286
  • 3
  • 10

0 Answers0