diff --git a/src/Frame.cpp b/src/Frame.cpp index b32a7d20..e25aa5ad 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -968,14 +968,14 @@ cv::Mat Frame::GetImageCV() std::shared_ptr Frame::Mat2Qimage(cv::Mat img){ cv::cvtColor(img, img, cv::COLOR_BGR2RGB); - QImage qimg((uchar*) img.data, img.cols, img.rows, img.step, QImage::Format_RGBA8888_Premultiplied); + QImage qimg((uchar*) img.data, img.cols, img.rows, img.step, QImage::Format_RGB888); std::shared_ptr imgIn = std::make_shared(qimg.copy()); // Always convert to RGBA8888 (if different) if (imgIn->format() != QImage::Format_RGBA8888_Premultiplied) *imgIn = imgIn->convertToFormat(QImage::Format_RGBA8888_Premultiplied); - + return imgIn; } diff --git a/src/Qt/PlayerPrivate.cpp b/src/Qt/PlayerPrivate.cpp index 75052fc3..7a3943c7 100644 --- a/src/Qt/PlayerPrivate.cpp +++ b/src/Qt/PlayerPrivate.cpp @@ -195,10 +195,10 @@ namespace openshot // Stop video/audio playback void PlayerPrivate::stopPlayback(int timeOutMilliseconds) { - if (isThreadRunning()) stopThread(timeOutMilliseconds); if (audioPlayback->isThreadRunning() && reader->info.has_audio) audioPlayback->stopThread(timeOutMilliseconds); if (videoCache->isThreadRunning() && reader->info.has_video) videoCache->stopThread(timeOutMilliseconds); if (videoPlayback->isThreadRunning() && reader->info.has_video) videoPlayback->stopThread(timeOutMilliseconds); + if (isThreadRunning()) stopThread(timeOutMilliseconds); } } diff --git a/src/Qt/VideoCacheThread.cpp b/src/Qt/VideoCacheThread.cpp index e1e53f5d..0cf76ef0 100644 --- a/src/Qt/VideoCacheThread.cpp +++ b/src/Qt/VideoCacheThread.cpp @@ -93,43 +93,43 @@ namespace openshot while (!threadShouldExit() && is_playing) { - // Cache frames before the other threads need them - // Cache frames up to the max frames. Reset to current position - // if cache gets too far away from display frame. Cache frames - // even when player is paused (i.e. speed 0). - while ((position - current_display_frame) < max_frames) - { - // Only cache up till the max_frames amount... then sleep - try + // Cache frames before the other threads need them + // Cache frames up to the max frames. Reset to current position + // if cache gets too far away from display frame. Cache frames + // even when player is paused (i.e. speed 0). + while (((position - current_display_frame) < max_frames) && is_playing) { - if (reader) { - ZmqLogger::Instance()->AppendDebugMethod("VideoCacheThread::run (cache frame)", "position", position, "current_display_frame", current_display_frame, "max_frames", max_frames, "needed_frames", (position - current_display_frame)); + // Only cache up till the max_frames amount... then sleep + try + { + if (reader) { + ZmqLogger::Instance()->AppendDebugMethod("VideoCacheThread::run (cache frame)", "position", position, "current_display_frame", current_display_frame, "max_frames", max_frames, "needed_frames", (position - current_display_frame)); - // Force the frame to be generated - if (reader->GetCache()->GetSmallestFrame()) { - int64_t smallest_cached_frame = reader->GetCache()->GetSmallestFrame()->number; - if (smallest_cached_frame > current_display_frame) { - // Cache position has gotten too far away from current display frame. - // Reset the position to the current display frame. - position = current_display_frame; + // Force the frame to be generated + if (reader->GetCache()->GetSmallestFrame()) { + int64_t smallest_cached_frame = reader->GetCache()->GetSmallestFrame()->number; + if (smallest_cached_frame > current_display_frame) { + // Cache position has gotten too far away from current display frame. + // Reset the position to the current display frame. + position = current_display_frame; + } } + reader->GetFrame(position); } - reader->GetFrame(position); + + } + catch (const OutOfBoundsFrame & e) + { + // Ignore out of bounds frame exceptions } - } - catch (const OutOfBoundsFrame & e) - { - // Ignore out of bounds frame exceptions + // Increment frame number + position++; } - // Increment frame number - position++; - } - - // Sleep for 1 frame length - std::this_thread::sleep_for(frame_duration); - } + // Sleep for 1 frame length + std::this_thread::sleep_for(frame_duration); + } return; }