libobs: Fix skipped frames reporting
When frames are skipped the skipped frame count would increment, but the total frame count would not increment, causing the percentage calculation to fail. Additionally, the skipped frames log reporting has been moved to media-io/video-io.c instead of each output.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include "../util/bmem.h"
|
||||
#include "../util/platform.h"
|
||||
#include "../util/profiler.h"
|
||||
@@ -150,6 +151,8 @@ static inline bool video_output_cur_frame(struct video_output *video)
|
||||
|
||||
if (++video->available_frames == video->info.cache_size)
|
||||
video->last_added = video->first_added;
|
||||
} else {
|
||||
++video->skipped_frames;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&video->data_mutex);
|
||||
@@ -333,6 +336,11 @@ bool video_output_connect(video_t *video,
|
||||
|
||||
pthread_mutex_lock(&video->input_mutex);
|
||||
|
||||
if (video->inputs.num == 0) {
|
||||
video->skipped_frames = 0;
|
||||
video->total_frames = 0;
|
||||
}
|
||||
|
||||
if (video_get_input_idx(video, callback, param) == DARRAY_INVALID) {
|
||||
struct video_input input;
|
||||
memset(&input, 0, sizeof(input));
|
||||
@@ -378,6 +386,20 @@ void video_output_disconnect(video_t *video,
|
||||
da_erase(video->inputs, idx);
|
||||
}
|
||||
|
||||
if (video->inputs.num == 0) {
|
||||
double percentage_skipped = (double)video->skipped_frames /
|
||||
(double)video->total_frames * 100.0;
|
||||
|
||||
if (video->skipped_frames)
|
||||
blog(LOG_INFO, "Video stopped, number of "
|
||||
"skipped frames due "
|
||||
"to encoding lag: "
|
||||
"%"PRIu32"/%"PRIu32" (%0.1f%%)",
|
||||
video->skipped_frames,
|
||||
video->total_frames,
|
||||
percentage_skipped);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&video->input_mutex);
|
||||
}
|
||||
|
||||
@@ -403,7 +425,6 @@ bool video_output_lock_frame(video_t *video, struct video_frame *frame,
|
||||
pthread_mutex_lock(&video->data_mutex);
|
||||
|
||||
if (video->available_frames == 0) {
|
||||
video->skipped_frames += count;
|
||||
video->cache[video->last_added].count += count;
|
||||
locked = false;
|
||||
|
||||
|
Reference in New Issue
Block a user