Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void do_video_stats(OutputStream *ost, int frame_size)
- {
- time_t today3;
- time(&today3);
- //OutputFile *file1=output_files[0];
- OutputStream *stream1 = ost;
- //struct tm *today1 = localtime(&today3);
- AVCodecContext *enc;
- int frame_number;
- double ti1, bitrate, avg_bitrate;
- /* this is executed just the first time do_video_stats is called */
- if (!vstats_file) {
- vstats_file = fopen(vstats_filename, "w");
- fprintf(vstats_file, "filename = %s\n",obj2.name);
- if (!vstats_file) {
- perror("fopen");
- exit_program(1);
- }
- }
- enc = ost->enc_ctx;
- 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 ? enc->coded_frame->quality / (float)FF_QP2LAMBDA : 0);
- if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR))
- fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
- // fprintf(vstats_file,"f_size= %6d ", frame_size);
- /* compute pts value */
- ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
- if (ti1 < 0.01)
- ti1 = 0.01;
- bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
- avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
- fprintf(vstats_file, "time= %0.3f\t ""clocktime = %s\t", ti1,ctime(&today3));
- //fprintf(vstats_file, "time= %0.3f\t ""clocktime = %02d:%02d:%02d\t""day/month/year = %02d:%02d:%04d\n" , ti1,today1->tm_hour,today1->tm_min,today1->tm_sec,today1->tm_mday,today1->tm_mon,today1->tm_year);
- //fprintf(vstats_file, "type= %c\n", enc->coded_frame ? av_get_picture_type_char(enc->coded_frame->pict_type) : 'I');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement