Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
52866 views
1
#!/bin/env perl
2
# countquant_x264.pl: displays statistics from x264 multipass logfiles
3
# by Loren Merritt, 2005-4-5
4
5
@size{I,P,B} =
6
@n{I,P,B} = (0)x3;
7
8
sub proc_file {
9
my $fh = shift;
10
while(<$fh>) {
11
/type:(.) q:(\d+\.\d+) tex:(\d+) mv:(\d+) misc:(\d+)/ or next;
12
$type = uc $1;
13
$n{$type} ++;
14
$q[int($2+.5)] ++;
15
$avgq += $2;
16
$avgq{$type} += $2;
17
my $bytes = ($3+$4+$5)/8;
18
$size{$type} += $bytes;
19
}
20
$size = $size{I} + $size{P} + $size{B};
21
$n = $n{I} + $n{P} + $n{B};
22
$n or die "unrecognized input\n";
23
}
24
25
if(@ARGV) {
26
foreach(@ARGV) {
27
open $fh, "<", $_ or die "can't open '$_': $!";
28
proc_file($fh);
29
}
30
} else {
31
proc_file(STDIN);
32
}
33
34
for(0..51) {
35
$q[$_] or next;
36
printf "q%2d: %6d %4.1f%%\n", $_, $q[$_], 100*$q[$_]/$n;
37
}
38
print "\n";
39
$digits = int(log($n+1)/log(10))+2;
40
printf "All: %${digits}d %s avgQP:%5.2f avgBytes:%5d\n",
41
$n, $n==$n{I}?" ":"", $avgq/$n, $size/$n;
42
foreach(qw(I P B S)) {
43
$n{$_} or next;
44
printf "%s: %${digits}d (%4.1f%%) avgQP:%5.2f avgBytes:%5d\n",
45
$_, $n{$_}, 100*$n{$_}/$n, $avgq{$_}/$n{$_}, $size{$_}/$n{$_};
46
}
47
print "\n";
48
printf "total size: $size B = %.2f KiB = %.2f MiB\n",
49
$size/2**10, $size/2**20;
50
print "bitrate: ", join("\n = ",
51
map sprintf("%.2f kbps @ %s fps", $_*$size*8/1000/$n, $_),
52
23.976, 25, 29.97), "\n";
53
54