Skip to content

Commit 8e0704f

Browse files
committed
Hook up infinite GOP support.
1 parent 57c4d89 commit 8e0704f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

third_party/pyroenc

video/ffmpeg_encode.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,11 @@ bool VideoEncoder::Impl::init_video_codec_av(const AVCodec *codec)
10861086
video.av_ctx->rc_max_rate = options.realtime_options.max_bitrate_kbits * 1000;
10871087
video.av_ctx->gop_size = int(options.realtime_options.gop_seconds *
10881088
float(video.av_ctx->framerate.num) / float(video.av_ctx->framerate.den));
1089-
if (video.av_ctx->gop_size == 0)
1089+
1090+
// TODO: Is there a way to express infinite GOP here?
1091+
if (video.av_ctx->gop_size < 0)
1092+
video.av_ctx->gop_size = 120;
1093+
else if (video.av_ctx->gop_size == 0)
10901094
video.av_ctx->gop_size = 1;
10911095

10921096
if (is_x264)
@@ -1229,8 +1233,17 @@ bool VideoEncoder::Impl::init_video_codec_pyro(PyroEnc::Profile profile)
12291233
rate_info.mode = options.low_latency ? PyroEnc::RateControlMode::CBR : PyroEnc::RateControlMode::VBR;
12301234
rate_info.bitrate_kbits = options.realtime_options.bitrate_kbits;
12311235
rate_info.max_bitrate_kbits = options.realtime_options.max_bitrate_kbits;
1232-
rate_info.gop_frames = unsigned(
1233-
options.realtime_options.gop_seconds * float(pyro_info.frame_rate_num) / float(pyro_info.frame_rate_den));
1236+
1237+
if (options.realtime_options.gop_seconds < 0.0f)
1238+
{
1239+
rate_info.gop_frames = UINT32_MAX;
1240+
}
1241+
else
1242+
{
1243+
rate_info.gop_frames = unsigned(
1244+
options.realtime_options.gop_seconds * float(pyro_info.frame_rate_num) /
1245+
float(pyro_info.frame_rate_den));
1246+
}
12341247

12351248
if (!pyro_encoder.set_rate_control_info(rate_info))
12361249
{

0 commit comments

Comments
 (0)