MCPcopy Create free account
hub / github.com/byhook/ffmpeg4android / do_video_stats

Function do_video_stats

ffmpeg-single-cmd/src/main/cpp/ffmpeg_mod.c:1360–1401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1358}
1359
1360static void do_video_stats(OutputStream *ost, int frame_size)
1361{
1362 AVCodecContext *enc;
1363 int frame_number;
1364 double ti1, bitrate, avg_bitrate;
1365
1366 /* this is executed just the first time do_video_stats is called */
1367 if (!vstats_file) {
1368 vstats_file = fopen(vstats_filename, "w");
1369 if (!vstats_file) {
1370 perror("fopen");
1371 exit_program(1);
1372 }
1373 }
1374
1375 enc = ost->enc_ctx;
1376 if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
1377 frame_number = ost->st->nb_frames;
1378 if (vstats_version <= 1) {
1379 fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number,
1380 ost->quality / (float)FF_QP2LAMBDA);
1381 } else {
1382 fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", ost->file_index, ost->index, frame_number,
1383 ost->quality / (float)FF_QP2LAMBDA);
1384 }
1385
1386 if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR))
1387 fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0)));
1388
1389 fprintf(vstats_file,"f_size= %6d ", frame_size);
1390 /* compute pts value */
1391 ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
1392 if (ti1 < 0.01)
1393 ti1 = 0.01;
1394
1395 bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0;
1396 avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0;
1397 fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1398 (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate);
1399 fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type));
1400 }
1401}
1402
1403static int init_output_stream(OutputStream *ost, char *error, int error_len);
1404

Callers 2

do_video_outFunction · 0.85
flush_encodersFunction · 0.85

Calls 3

exit_programFunction · 0.85
psnrFunction · 0.85
av_q2dFunction · 0.50

Tested by

no test coverage detected