A keyframe could be buffered in the bsf and not be output until more packets had been fed to it.
Signed-off-by: James Almer <jamr...@gmail.com> --- This replaces/supersedes [PATCH 2/6] avcodec/bsf: add a capabilities field to AVBitStreamFilter [PATCH 4/6] ffmpeg: don't skip packets before a keyframe was seen if a bsf with delay is used fftools/ffmpeg.c | 4 +++- fftools/ffmpeg.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aa0986f02..2a56b2f0e7 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -889,6 +889,8 @@ static void output_packet(OutputFile *of, AVPacket *pkt, /* apply the output bitstream filters */ if (ost->bsf_ctx) { + if (pkt && (pkt->flags & AV_PKT_FLAG_KEY)) + ost->seen_kf = 1; ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); if (ret < 0) goto finish; @@ -2026,7 +2028,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p } if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && - !ost->copy_initial_nonkeyframes) + !ost->copy_initial_nonkeyframes && !ost->seen_kf) return; if (!ost->frame_number && !ost->copy_prior_start) { diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1b8bbace3f..cc8f767e5d 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -535,6 +535,7 @@ typedef struct OutputStream { int inputs_done; const char *attachment_filename; + int seen_kf; int copy_initial_nonkeyframes; int copy_prior_start; char *disposition; -- 2.35.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-requ...@ffmpeg.org with subject "unsubscribe".