File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -590,6 +590,23 @@ void FFmpegWriter::flush_encoders()
590590 // Encode video packet (latest version of FFmpeg)
591591 error_code = avcodec_send_frame (video_codec, NULL );
592592 got_packet = 0 ;
593+ while (error_code >= 0 ) {
594+ error_code = avcodec_receive_packet (video_codec, &pkt);
595+ if (error_code == AVERROR (EAGAIN)|| error_code == AVERROR_EOF) {
596+ got_packet = 0 ;
597+ // Write packet
598+ avcodec_flush_buffers (video_codec);
599+ break ;
600+ }
601+ if (pkt.pts != AV_NOPTS_VALUE)
602+ pkt.pts = av_rescale_q (pkt.pts , video_codec->time_base , video_st->time_base );
603+ if (pkt.dts != AV_NOPTS_VALUE)
604+ pkt.dts = av_rescale_q (pkt.dts , video_codec->time_base , video_st->time_base );
605+ if (pkt.duration > 0 )
606+ pkt.duration = av_rescale_q (pkt.duration , video_codec->time_base , video_st->time_base );
607+ pkt.stream_index = video_st->index ;
608+ error_code = av_interleaved_write_frame (oc, &pkt);
609+ }
593610 }
594611 #else
595612
You can’t perform that action at this time.
0 commit comments