diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp
index 736e95ee..adf957f1 100644
--- a/src/FFmpegReader.cpp
+++ b/src/FFmpegReader.cpp
@@ -607,6 +607,12 @@ std::shared_ptr FFmpegReader::ReadStream(int64_t requested_frame)
// Process Video Packet
ProcessVideoPacket(requested_frame);
+
+ if (!use_omp_threads) {
+ // Wait on each OMP task to complete before moving on to the next one. This slows
+ // down processing considerably, but might be more stable on some systems.
+ #pragma omp taskwait
+ }
}
}
@@ -638,12 +644,6 @@ std::shared_ptr FFmpegReader::ReadStream(int64_t requested_frame)
ProcessAudioPacket(requested_frame, location.frame, location.sample_start);
}
- if (!use_omp_threads) {
- // Wait on each OMP task to complete before moving on to the next one. This slows
- // down processing considerably, but might be more stable on some systems.
- #pragma omp taskwait
- }
-
// Check if working frames are 'finished'
if (!is_seeking) {
// Check for any missing frames