Skip to content

Commit 571e92a

Browse files
committed
base: Add multi video and frame rate divisor support to GetOutputDuration
1 parent eed8a49 commit 571e92a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/utils/Obs_NumberHelper.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output)
3131
video_t *video = obs_output_video(output);
3232
uint64_t frameTimeNs = video_output_get_frame_time(video);
3333
int totalFrames = obs_output_get_total_frames(output);
34-
35-
return util_mul_div64(totalFrames, frameTimeNs, 1000000ULL);
34+
uint64_t divisor = 0ULL;
35+
for (size_t i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
36+
obs_encoder_t *encoder = obs_output_get_video_encoder2(output, i);
37+
if (!encoder)
38+
continue;
39+
uint32_t encoder_divisor = obs_encoder_get_frame_rate_divisor(encoder);
40+
divisor += encoder_divisor <= 1 ? 1000000ULL : 1000000ULL / encoder_divisor;
41+
}
42+
return util_mul_div64(totalFrames, frameTimeNs, divisor ? divisor : 1000000ULL);
3643
}
3744

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

0 commit comments

Comments
 (0)