From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [PATCH] examples/transcode: flush decoder on EOF Date: Fri, 11 Aug 2023 00:54:27 +0800 Message-ID: <tencent_0CB4662FD09B26E827C0EA80D31E1C7F4B06@qq.com> (raw) From: Zhao Zhili <zhilizhao@tencent.com> Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> --- doc/examples/transcode.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/doc/examples/transcode.c b/doc/examples/transcode.c index 305181663c..ed6ac9fa03 100644 --- a/doc/examples/transcode.c +++ b/doc/examples/transcode.c @@ -585,11 +585,38 @@ int main(int argc, char **argv) av_packet_unref(packet); } - /* flush filters and encoders */ + /* flush decoders, filters and encoders */ for (i = 0; i < ifmt_ctx->nb_streams; i++) { - /* flush filter */ + StreamContext *stream; + if (!filter_ctx[i].filter_graph) continue; + + stream = &stream_ctx[i]; + + av_log(NULL, AV_LOG_INFO, "Flushing stream %u decoder\n", i); + + /* flush decoder */ + ret = avcodec_send_packet(stream->dec_ctx, NULL); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Flushing decoding failed\n"); + goto end; + } + + while (ret >= 0) { + ret = avcodec_receive_frame(stream->dec_ctx, stream->dec_frame); + if (ret == AVERROR_EOF) + break; + else if (ret < 0) + goto end; + + stream->dec_frame->pts = stream->dec_frame->best_effort_timestamp; + ret = filter_encode_write_frame(stream->dec_frame, i); + if (ret < 0) + goto end; + } + + /* flush filter */ ret = filter_encode_write_frame(NULL, i); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Flushing filter failed\n"); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2023-08-10 16:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tencent_0CB4662FD09B26E827C0EA80D31E1C7F4B06@qq.com \ --to=quinkblack@foxmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=zhilizhao@tencent.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git