From be23815c7c24725f7cb28035abf3208525181c97 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 7 Apr 2024 02:54:37 +0200 Subject: [PATCH] Call avfilter_graph_request_oldest after sending a frame to a filter --- src/cyanrip_encode.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cyanrip_encode.c b/src/cyanrip_encode.c index 04d8efb..e3ad09f 100644 --- a/src/cyanrip_encode.c +++ b/src/cyanrip_encode.c @@ -422,6 +422,7 @@ int cyanrip_create_dec_ctx(cyanrip_ctx *ctx, cyanrip_dec_ctx **s, if ((ctx->settings.decode_hdcd) || (ctx->settings.deemphasis && t->preemphasis) || (ctx->settings.force_deemphasis)) { + ret = init_filtering(ctx, &dec_ctx->filt, ctx->settings.decode_hdcd, (ctx->settings.deemphasis && t->preemphasis) || ctx->settings.force_deemphasis, @@ -491,6 +492,7 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx, if (!dec_ctx->filt.buffersrc_ctx) return push_frame_to_encs(ctx, enc_ctx, num_enc, frame); + ret = av_buffersrc_add_frame_flags(dec_ctx->filt.buffersrc_ctx, frame, AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT | AV_BUFFERSRC_FLAG_KEEP_REF); @@ -499,6 +501,14 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx, goto fail; } + ret = avfilter_graph_request_oldest(dec_ctx->filt.graph); + if (ret == AVERROR_EOF) { + return push_frame_to_encs(ctx, enc_ctx, num_enc, NULL); + } else if (ret < 0) { + cyanrip_log(ctx, 0, "Error filtering frame: %s!\n", av_err2str(ret)); + goto fail; + } + while (1) { dec_frame = av_frame_alloc(); if (!dec_frame) {