Skip to content

Commit

Permalink
Merge pull request gpac#2888 from DenizUgur/prevent-encoder-reconfig
Browse files Browse the repository at this point in the history
Preventing FFmpeg encoder from unnecessary reconfiguring
  • Loading branch information
jeanlf authored Jun 20, 2024
2 parents 5b48963 + c8ec559 commit 43f1295
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/filters/ff_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ typedef struct _gf_ffenc_ctx

GF_BitStream *sdbs;

GF_FilterPacket *reconfig_from_pck;
Bool reconfig_pending;
Bool infmt_negotiate;
Bool remap_ts;
Expand Down Expand Up @@ -496,6 +497,16 @@ static GF_Err ffenc_process_video(GF_Filter *filter, struct _gf_ffenc_ctx *ctx)
force_intra = 2;
}

//don't repeat encoder reconfiguration if we already forced one
if (force_intra == 2) {
if (ctx->reconfig_from_pck == pck) {
force_intra = 1;
ctx->reconfig_from_pck = NULL;
} else {
ctx->reconfig_from_pck = pck;
}
}

//check if we need to force a closed gop
if (pck && (ctx->fintra.den && (ctx->fintra.num>0)) && !ctx->force_reconfig) {
u64 cts = ffenc_get_cts(ctx, pck);
Expand Down

0 comments on commit 43f1295

Please sign in to comment.