Advertisement
Guest User

Untitled

a guest
Jun 26th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. static void do_video_stats(OutputStream *ost, int frame_size)
  2. {
  3.  
  4. time_t today3;
  5. time(&today3);
  6. //OutputFile *file1=output_files[0];
  7. OutputStream *stream1 = ost;
  8. //struct tm *today1 = localtime(&today3);
  9. AVCodecContext *enc;
  10. int frame_number;
  11. double ti1, bitrate, avg_bitrate;
  12.  
  13. /* this is executed just the first time do_video_stats is called */
  14. if (!vstats_file) {
  15. vstats_file = fopen(vstats_filename, "w");
  16. fprintf(vstats_file, "filename = %s\n",obj2.name);
  17. if (!vstats_file) {
  18. perror("fopen");
  19. exit_program(1);
  20. }
  21. }
  22.  
  23. enc = ost->enc_ctx;
  24. if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
  25. frame_number = ost->st->nb_frames;
  26. // fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame ? enc->coded_frame->quality / (float)FF_QP2LAMBDA : 0);
  27. if (enc->coded_frame && (enc->flags&CODEC_FLAG_PSNR))
  28. fprintf(vstats_file, "PSNR= %6.2f ", psnr(enc->coded_frame->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
  29.  
  30. // fprintf(vstats_file,"f_size= %6d ", frame_size);
  31. /* compute pts value */
  32. ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
  33. if (ti1 < 0.01)
  34. ti1 = 0.01;
  35.  
  36. bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
  37. avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
  38. fprintf(vstats_file, "time= %0.3f\t ""clocktime = %s\t", ti1,ctime(&today3));
  39. //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);
  40. //fprintf(vstats_file, "type= %c\n", enc->coded_frame ? av_get_picture_type_char(enc->coded_frame->pict_type) : 'I');
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement