You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Merge pull request #585 from OpenShot/opencv
3 New OpenCV Effects (Tracker, Stabilization, and Object Detection)
This commit is contained in:
@@ -94,43 +94,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user