func: static void flush_encoders() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; AVCodecContext * enc = ost -> st -> codec ; AVFormatContext * os = output_files [ ost -> file_index ] -> ctx ; int stop_encoding = 0 ; if ( ! ost -> encoding_needed )  if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_AUDIO && enc -> frame_size <= 1 )  if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO && os -> oformat -> flags & 0x20 && ( enc -> codec -> id ) == AV_CODEC_ID_RAWVIDEO )  switch ( ost -> st -> codec -> codec_type )  encode = avcodec_encode_audio2; encode = avcodec_encode_video2; stop_encoding = 1; if ( encode )  AVPacket pkt ; int got_packet ; pkt . data = ( ( void * ) 0 ); pkt . size = 0; if ( ost -> logfile && enc -> stats_out )  fprintf ( ost -> logfile , "%s" , enc -> stats_out ); if ( ! got_packet )  stop_encoding = 1; if ( pkt . pts != ( ( int64_t ) 0x8000000000000000UL ) )  pkt . pts = av_rescale_q ( pkt . pts , enc -> time_base , ost -> st -> time_base ); if ( pkt . dts != ( ( int64_t ) 0x8000000000000000UL ) )  pkt . dts = av_rescale_q ( pkt . dts , enc -> time_base , ost -> st -> time_base ); if ( pkt . duration > 0 )  pkt . duration = ( av_rescale_q ( pkt . duration , enc -> time_base , ost -> st -> time_base ) ); if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO && vstats_filename )  do_video_stats ( ost , pkt . size ); if ( stop_encoding )  static void do_video_stats(OutputStream *ost,int frame_size) AVCodecContext * enc ; int frame_number ; if ( ! vstats_file )  vstats_file = fopen ( vstats_filename , "w" ); enc = ost -> st -> codec; if ( ( enc -> codec_type ) == AVMEDIA_TYPE_VIDEO )  frame_number = ( ost -> st -> nb_frames ); fprintf ( vstats_file , "frame= %5d q= %2.1f " , frame_number , ( ( enc -> coded_frame -> quality ) / ( ( float ) 'v' ) ) ); fprintf ( vstats_file , "PSNR= %6.2f " , psnr ( enc -> coded_frame -> error [ 0 ] / ( ( enc -> width * enc -> height ) * 255.0 * 255.0 ) ) ); static double psnr(double d) return - 10.0 * log ( d ) / log ( 10.0 ) ; fprintf ( vstats_file , "f_size= %6d " , frame_size ); fprintf ( vstats_file , "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s " , ( ( double ) video_size ) / 1024 , ti1 , bitrate , avg_bitrate ); fprintf ( vstats_file , "type= %c\n" , ( av_get_picture_type_char ( enc -> coded_frame -> pict_type ) ) ); 