Skip to content

Commit 647dd6e

Browse files
committed
utils: Add multi video and frame rate divisor support to GetOutputDuration
1 parent eed8a49 commit 647dd6e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/utils/Obs_NumberHelper.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@ uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output)
3232
uint64_t frameTimeNs = video_output_get_frame_time(video);
3333
int totalFrames = obs_output_get_total_frames(output);
3434

35-
return util_mul_div64(totalFrames, frameTimeNs, 1000000ULL);
35+
// calculating the divisor is a hack to support multiple video encoders, someone please improve this in the future
36+
uint64_t divisor = 0ULL;
37+
for (size_t i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
38+
obs_encoder_t *encoder = obs_output_get_video_encoder2(output, i);
39+
if (!encoder)
40+
continue;
41+
uint32_t encoder_divisor = obs_encoder_get_frame_rate_divisor(encoder);
42+
divisor += encoder_divisor <= 1 ? 1000000ULL : 1000000ULL / encoder_divisor;
43+
}
44+
45+
return util_mul_div64(totalFrames, frameTimeNs, divisor ? divisor : 1000000ULL);
3646
}
3747

3848
size_t Utils::Obs::NumberHelper::GetSceneCount()

0 commit comments

Comments
 (0)