1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

ffmpeg: ensure a keyframe was not seen before skipping packets

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 <jamrial@gmail.com>
This commit is contained in:
James Almer
2022-02-15 09:44:21 -03:00
parent afe485ee6b
commit d75e7a9a83
2 changed files with 4 additions and 1 deletions

View File

@@ -889,6 +889,8 @@ static void output_packet(OutputFile *of, AVPacket *pkt,
/* apply the output bitstream filters */ /* apply the output bitstream filters */
if (ost->bsf_ctx) { if (ost->bsf_ctx) {
if (pkt->flags & AV_PKT_FLAG_KEY)
ost->seen_kf = 1;
ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt); ret = av_bsf_send_packet(ost->bsf_ctx, eof ? NULL : pkt);
if (ret < 0) if (ret < 0)
goto finish; 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)) && if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) &&
!ost->copy_initial_nonkeyframes) !ost->copy_initial_nonkeyframes && !ost->seen_kf)
return; return;
if (!ost->frame_number && !ost->copy_prior_start) { if (!ost->frame_number && !ost->copy_prior_start) {

View File

@@ -535,6 +535,7 @@ typedef struct OutputStream {
int inputs_done; int inputs_done;
const char *attachment_filename; const char *attachment_filename;
int seen_kf;
int copy_initial_nonkeyframes; int copy_initial_nonkeyframes;
int copy_prior_start; int copy_prior_start;
char *disposition; char *disposition;