diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index b51fe5f7..d1eb4da2 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -14,7 +14,7 @@ #ifndef INT64_MAX #define INT64_MAX 9223372036854775807LL #endif -#define MAX_RETRY 1000 +#define MAX_RETRY 4000 // max pts/curr_pos drift allowed before correction (in seconds) #define AUDIO_PTS_TOLERANCE 0.04 @@ -608,7 +608,8 @@ int FFStream::encode_frame(AVFrame *frame) if( ret < 0 && ret != AVERROR(EAGAIN) ) break; FFPacket opkt; ret = avcodec_receive_packet(avctx, opkt); - if( !frame && ret == AVERROR_EOF ) return pkts; + if( !frame && (ret == AVERROR_EOF) || (ret == AVERROR(EAGAIN))) + return pkts; if( ret < 0 ) break; ret = write_packet(opkt); if( ret < 0 ) break; @@ -627,7 +628,7 @@ int FFStream::flush() { if( writing < 0 ) return -1; - int ret = encode_frame(0); + int ret = encode_frame(NULL); if( ret >= 0 && stats_fp ) { ret = write_stats_file(); close_stats_file();