changing codec for loss less cause xvid lost some frame at end causing crashes
This commit is contained in:
@ -63,18 +63,23 @@ void ProcessWebcamThread::Execute() {
|
|||||||
else{
|
else{
|
||||||
|
|
||||||
InputVideo->read(*im);
|
InputVideo->read(*im);
|
||||||
|
mutex_pause.Lock();
|
||||||
__LOG_CAM__ << "Record frame clock: " << (float)current_frame_clock << "at index: "<< frame_index<<"\n";
|
temp_pause = pause;
|
||||||
|
mutex_pause.Unlock();
|
||||||
|
if(!temp_pause){
|
||||||
outputVideo->write(*im);
|
outputVideo->write(*im);
|
||||||
frame_index++;
|
frame_index++;
|
||||||
lutFile.write(reinterpret_cast<const char*>(¤t_frame_clock),sizeof(float));
|
lutFile.write(reinterpret_cast<const char*>(¤t_frame_clock),sizeof(float));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
__LOG_CAM__ << "THREAD STOPPED "<<videoIndex<<"\n";
|
__LOG_CAM__ << "THREAD STOPPED "<<videoIndex<<"\n";
|
||||||
outputVideo->release();
|
outputVideo->release();
|
||||||
im->release();
|
im->release();
|
||||||
lutFile.close();
|
lutFile.close();
|
||||||
|
|
||||||
|
Platform::Get().Sleep(50); // Laisser le fichier se finaliser
|
||||||
|
|
||||||
delete im;
|
delete im;
|
||||||
}
|
}
|
||||||
//*********************************************************
|
//*********************************************************
|
||||||
@ -238,8 +243,7 @@ void Webcam::ResetVideo() {
|
|||||||
std::stringstream video_name;
|
std::stringstream video_name;
|
||||||
video_name << "./webcam_record_" << index_save_video << ".avi";
|
video_name << "./webcam_record_" << index_save_video << ".avi";
|
||||||
// set the codec fourcc
|
// set the codec fourcc
|
||||||
unsigned int ex = outputVideo->fourcc('X', 'V', 'I', 'D');
|
unsigned int ex = outputVideo->fourcc('M', 'J', 'P', 'G');
|
||||||
outputVideo->set(VIDEOWRITER_PROP_QUALITY, 70);
|
|
||||||
outputVideo->open(video_name.str(), ex, webcam_fps, Size(width, height), true);
|
outputVideo->open(video_name.str(), ex, webcam_fps, Size(width, height), true);
|
||||||
|
|
||||||
if (!outputVideo->isOpened())
|
if (!outputVideo->isOpened())
|
||||||
@ -275,10 +279,14 @@ void Webcam::setPause(bool pause) {
|
|||||||
bool thread_pause = thread_process->pause;
|
bool thread_pause = thread_process->pause;
|
||||||
thread_process->mutex_pause.Unlock();
|
thread_process->mutex_pause.Unlock();
|
||||||
|
|
||||||
|
thread_process->mutex_pause.Lock();
|
||||||
|
thread_process->pause = pause;
|
||||||
|
thread_process->mutex_pause.Unlock();
|
||||||
|
|
||||||
if (!thread_pause && pause) {
|
if (!thread_pause && pause) {
|
||||||
__LOG_CAM__ <<"B\n";
|
__LOG_CAM__ <<"B\n";
|
||||||
Close();
|
Close();
|
||||||
|
Platform::Get().Sleep(50); // Laisser le fichier se finaliser
|
||||||
__LOG_CAM__ << "REPLAY INPUT RELEASE ./webcam_record_" << index_replay_video << ".avi\n ";
|
__LOG_CAM__ << "REPLAY INPUT RELEASE ./webcam_record_" << index_replay_video << ".avi\n ";
|
||||||
ReplayInputVideo->release();
|
ReplayInputVideo->release();
|
||||||
index_replay_video = index_save_video - 1;
|
index_replay_video = index_save_video - 1;
|
||||||
@ -319,6 +327,7 @@ void Webcam::Close() {
|
|||||||
thread_process = nullptr;
|
thread_process = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ReplayInputVideo)
|
||||||
ReplayInputVideo->release();
|
ReplayInputVideo->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,11 +377,11 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (record_index != index_replay_video) {
|
if (record_index != index_replay_video) {
|
||||||
__LOG_H__ << "Changing video\n";
|
__LOG_CAM__ << "Changing video\n";
|
||||||
index_replay_video = record_index;
|
index_replay_video = record_index;
|
||||||
std::stringstream video_name;
|
std::stringstream video_name;
|
||||||
video_name << record_name << "_" << index_replay_video << ".avi";
|
video_name << record_name << "_" << index_replay_video << ".avi";
|
||||||
__LOG_H__ << record_name << "_" << index_replay_video << ".avi";
|
__LOG_CAM__ << record_name << "_" << index_replay_video << ".avi\n";
|
||||||
ReplayInputVideo->release();
|
ReplayInputVideo->release();
|
||||||
ReplayInputVideo->open(video_name.str());
|
ReplayInputVideo->open(video_name.str());
|
||||||
}
|
}
|
||||||
@ -402,9 +411,7 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
|
|
||||||
if (it == video_times.begin())
|
if (it == video_times.begin())
|
||||||
{
|
{
|
||||||
// clock before first frame
|
|
||||||
__LOG_CAM__ << "clock before first frame\n";
|
__LOG_CAM__ << "clock before first frame\n";
|
||||||
//SetFrame(clock,record_name-1)
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,9 +422,11 @@ uchar *Webcam::SetFrame(float clock, GS::String record_name , int record_index)
|
|||||||
__LOG_CAM__ << "ReplayInputVideo not opened\n";
|
__LOG_CAM__ << "ReplayInputVideo not opened\n";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
__LOG_CAM__ << "Index found "<<index<<"for clock "<<clock<<"\n";
|
|
||||||
|
int frameCount = (int)ReplayInputVideo->get(cv::CAP_PROP_FRAME_COUNT) - 1;
|
||||||
ReplayInputVideo->set(cv::CAP_PROP_POS_FRAMES, index);
|
ReplayInputVideo->set(cv::CAP_PROP_POS_FRAMES, index);
|
||||||
|
|
||||||
|
|
||||||
if (!ReplayInputVideo->read(*ReplayImframe))
|
if (!ReplayInputVideo->read(*ReplayImframe))
|
||||||
{
|
{
|
||||||
__LOG_CAM__ << "Failed to read frame at index " << index << "\n";
|
__LOG_CAM__ << "Failed to read frame at index " << index << "\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user