mirror of
https://github.com/librempeg/librempeg
synced 2024-11-22 18:49:58 +00:00
ffmpeg: flush delayed frames in codec copy scenarios
Bitstream filters inserted between the input and output were never drained, resulting in packets being lost if the bsf had any buffered. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
4f21a9ae6b
commit
afe485ee6b
@ -2001,7 +2001,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost)
|
||||
if (ost->source_index != ist_index)
|
||||
return 0;
|
||||
|
||||
if (ost->finished)
|
||||
if (ost->finished & MUXER_FINISHED)
|
||||
return 0;
|
||||
|
||||
if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time)
|
||||
@ -2733,7 +2733,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
|
||||
}
|
||||
ist->pts = ist->dts;
|
||||
ist->next_pts = ist->next_dts;
|
||||
}
|
||||
} else if (!ist->decoding_needed)
|
||||
eof_reached = 1;
|
||||
|
||||
for (i = 0; i < nb_output_streams; i++) {
|
||||
OutputStream *ost = output_streams[i];
|
||||
|
||||
@ -4213,10 +4215,11 @@ static int process_input(int file_index)
|
||||
for (i = 0; i < ifile->nb_streams; i++) {
|
||||
ist = input_streams[ifile->ist_index + i];
|
||||
avctx = ist->dec_ctx;
|
||||
if (ist->decoding_needed) {
|
||||
if (ist->processing_needed) {
|
||||
ret = process_input_packet(ist, NULL, 1);
|
||||
if (ret>0)
|
||||
return 0;
|
||||
if (ist->decoding_needed)
|
||||
avcodec_flush_buffers(avctx);
|
||||
}
|
||||
}
|
||||
@ -4247,7 +4250,7 @@ static int process_input(int file_index)
|
||||
|
||||
for (i = 0; i < ifile->nb_streams; i++) {
|
||||
ist = input_streams[ifile->ist_index + i];
|
||||
if (ist->decoding_needed) {
|
||||
if (ist->processing_needed) {
|
||||
ret = process_input_packet(ist, NULL, 0);
|
||||
if (ret>0)
|
||||
return 0;
|
||||
|
@ -307,6 +307,7 @@ typedef struct InputStream {
|
||||
int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
|
||||
#define DECODING_FOR_OST 1
|
||||
#define DECODING_FOR_FILTER 2
|
||||
int processing_needed; /* non zero if the packets must be processed */
|
||||
|
||||
AVCodecContext *dec_ctx;
|
||||
const AVCodec *dec;
|
||||
|
@ -277,6 +277,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
|
||||
ist->discard = 0;
|
||||
ist->decoding_needed |= DECODING_FOR_FILTER;
|
||||
ist->processing_needed = 1;
|
||||
ist->st->discard = AVDISCARD_NONE;
|
||||
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
|
@ -2610,6 +2610,7 @@ loop_end:
|
||||
if (ost->encoding_needed && ost->source_index >= 0) {
|
||||
InputStream *ist = input_streams[ost->source_index];
|
||||
ist->decoding_needed |= DECODING_FOR_OST;
|
||||
ist->processing_needed = 1;
|
||||
|
||||
if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
|
||||
ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
@ -2622,6 +2623,9 @@ loop_end:
|
||||
exit_program(1);
|
||||
}
|
||||
}
|
||||
} else if (ost->stream_copy && ost->source_index >= 0) {
|
||||
InputStream *ist = input_streams[ost->source_index];
|
||||
ist->processing_needed = 1;
|
||||
}
|
||||
|
||||
/* set the filter output constraints */
|
||||
|
Loading…
Reference in New Issue
Block a user