Unsolved Hi,I'm viewing 2 camera video simultanesly and recording them on linux system, but both camera lags(slow) after 3sec and I tried to put recording in Qtconcurrent::run(). but also both camera lags(slow)
-
Hi,I'm viewing 2 camera video simultanesly and recording them on linux system,
but both camera lags(slow) after 3sec and I tried to put recording in Qtconcurrent::run().
but also both camera lags(slow)
plz give me solution. -
@thippu How is anybody supposed to give you a solution if you do not provide much information?
Does your app leak memory? -
Hi,
To add to @jsulm, please change your thread title to something meaningful. You won't get much attention with what you wrote there.
-
@jsulm , @SGaist ,Im sorry about title.
@jsulm there is no error.here is the code plz help me:
//function kept in Qtconcurrent and thread calls rec1() and function will record and same for cam2 record :
connect(ui->radio_cam1_rec_on,&QAbstractButton::clicked,this,={if(camera1){
QtConcurrent::run(=
{rec1();
});
}});//rec1()
definition is:
{
ui->radio_cam1_rec_on->setEnabled(0);
ui->radio_cam1_rec_off->setEnabled(1);
QString filename = "thippu" + QDateTime::currentDateTime().toString("dd.MM.yy-h-m-s");
QString name="/home/mmrfic/Desktop/RECORD/"+filename+".mp4";
qDebug()<< mediarecorder1->setOutputLocation(QUrl::fromLocalFile(name));
mediarecorder1->record();
}@SGaist @jsulm , Can we pass below function to QtConcurrent thread
below function is to view the camera
code:
void MainWindow::setCameratoview1(const QCameraInfo cam)
{ delete camera1;ui->radio_cam1_on->setEnabled(0); ui->radio_cam1_off->setEnabled(1); ui->radio_cam1_rec_off->setEnabled(0); ui->radio_cam1_rec_on->setEnabled(1); camera1=new QCamera(cam); camera1->setViewfinder(ui->camview1); mediarecorder1=new QMediaRecorder(camera1); QVideoEncoderSettings settings1 = mediarecorder1->videoSettings(); settings1.setResolution(640,480); settings1.setQuality(QMultimedia::VeryHighQuality); settings1.setFrameRate(30.0); mediarecorder1->setVideoSettings(settings1); camera1->setCaptureMode(QCamera::CaptureVideo); camera1->start();
}
-
No you can't. You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden.
You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up.
Also, recording an mp4 file is a pretty heavy task, did you benchmark your computer to be sure you can support recording two streams at once ?
-
@SGaist I did take bench mark and I'm using highend system lenovo carbon x1.
May I know the best and light recording file otherthan mp4 format? -
@thippu What about fixing these issues first mentioned by @SGaist :
"You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden.You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up."
? -
@jsulm You might also be trying to write twice in the same file and from the looks of it, you'd might even be deleting your camera objects while setting them up."
? ans: No twice write rec2() function got diffrent file name so,that is not a problem for me.
"You are trying to modify GUI objects from another thread than the GUI thread which is wrong and forbidden. ans: I want there should no lag in cameras view thats y went to do in diffrent thread but I dono how to avoid lags
plz help me -
@thippu Never modify any GUI related classes from other thread than GUI thread. From other threads you should emit signals if something needs to be changed in the GUI.
-
Are you using a embedded device?
With a Raspberry Pi I can watch only one camera without to have problem.I'm watching 4 videocameras with a Pentium 4 and more than 8 with a Intel Core 2 duo, with motion detection ...
To do this I'm using the FFMpeg libs for the rtsp cameras and OpenCV for the /dev/video* cameras.
I suggest you to use a dedicated object (thread) for each camera and, if you want to watch and not only to store, to emit an event for each frame.
Please considered that if you are resizing the frames that it is very cpu expensive activity.
-
@mrdebug Thnx for the replay and suggestions
please send me example code or code which u have developed to my email : thippeswamydcts@gmail.com
for this : "I suggest you to use a dedicated object (thread) for each camera and, if you want to watch and not only to store, to emit an event for each frame." -
@jsulm hey is there any source, i can get to understand the gui thread like how to those gui threads are there and what we shouldnot do.
-
-
@jsulm Thank u so much