@ -987,6 +987,19 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
AVCodecContext * avctx = ost - > st - > codec ;
AVCodecContext * avctx = ost - > st - > codec ;
int ret ;
int ret ;
/*
* Audio encoders may split the packets - - # frames in ! = # packets out .
* But there is no reordering , so we can limit the number of output packets
* by simply dropping them here .
* Counting encoded video frames needs to be done separately because of
* reordering , see do_video_out ( )
*/
if ( ! ( avctx - > codec_type = = AVMEDIA_TYPE_VIDEO & & avctx - > codec ) ) {
if ( ost - > frame_number > = ost - > max_frames )
return ;
ost - > frame_number + + ;
}
while ( bsfc ) {
while ( bsfc ) {
AVPacket new_pkt = * pkt ;
AVPacket new_pkt = * pkt ;
int a = av_bitstream_filter_filter ( bsfc , avctx , NULL ,
int a = av_bitstream_filter_filter ( bsfc , avctx , NULL ,
@ -1014,7 +1027,6 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
print_error ( " av_interleaved_write_frame() " , ret ) ;
print_error ( " av_interleaved_write_frame() " , ret ) ;
exit_program ( 1 ) ;
exit_program ( 1 ) ;
}
}
ost - > frame_number + + ;
}
}
static void generate_silence ( uint8_t * buf , enum AVSampleFormat sample_fmt , size_t size )
static void generate_silence ( uint8_t * buf , enum AVSampleFormat sample_fmt , size_t size )
@ -1568,6 +1580,12 @@ static void do_video_out(AVFormatContext *s,
}
}
}
}
ost - > sync_opts + + ;
ost - > sync_opts + + ;
/*
* For video , number of frames in = = number of packets out .
* But there may be reordering , so we can ' t throw away frames on encoder
* flush , we need to limit them here , before they go into encoder .
*/
ost - > frame_number + + ;
}
}
}
}