From 68c5a200007a843b630bc693ad4b8334ec9cf215 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Thu, 31 May 2018 10:27:35 -0700 Subject: [PATCH] avfilter: fix flushing final frame Fixes https://github.com/HandBrake/HandBrake/issues/1357 (cherry picked from commit f70380a7b1c99f919712cb69b28bfc48eeb0b83d) --- libhb/avfilter.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libhb/avfilter.c b/libhb/avfilter.c index b82621426..91b571301 100644 --- a/libhb/avfilter.c +++ b/libhb/avfilter.c @@ -406,8 +406,15 @@ static hb_buffer_t* filterFrame( hb_filter_private_t * pv, hb_buffer_t * in ) int result; hb_buffer_list_t list; - fill_frame(pv, pv->frame, in); - result = av_buffersrc_add_frame(pv->input, pv->frame); + if (in != NULL) + { + fill_frame(pv, pv->frame, in); + result = av_buffersrc_add_frame(pv->input, pv->frame); + } + else + { + result = av_buffersrc_add_frame(pv->input, NULL); + } if (result < 0) { return NULL; @@ -444,11 +451,13 @@ static int avfilter_work( hb_filter_object_t * filter, if (in->s.flags & HB_BUF_FLAG_EOF) { + hb_buffer_t * out = filterFrame(pv, NULL); hb_buffer_t * last = hb_buffer_list_tail(&pv->list); if (last != NULL && last->s.start != AV_NOPTS_VALUE) { last->s.stop = last->s.start + last->s.duration; } + hb_buffer_list_prepend(&pv->list, out); hb_buffer_list_append(&pv->list, in); *buf_out = hb_buffer_list_clear(&pv->list); *buf_in = NULL; -- 2.40.0