-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner
executable file
·88 lines (70 loc) · 2.89 KB
/
runner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/perl -w
use strict;
use File::Basename;
my ( @orig_videos ) = @ARGV;
my $cq_level = 50;
my $N_chunks = scalar @orig_videos;
sub video_basename {
my ( $filename ) = @_;
my ( $basename ) = basename( $filename, ".y4m" );
die unless defined $basename;
return $basename;
};
my $global_iteration_counter = 0;
# create output directory
mkdir "outputs";
# phase 1
print STDERR "=== Phase 1 (vpxenc, decode) ===\n";
for ( my $i = 0; $i < $N_chunks; $i++ ) {
my $this_input_video = $orig_videos[ $i ];
my $chunk_name = video_basename( $this_input_video );
system qq{./phase1 ${this_input_video} ${cq_level} outputs/${chunk_name}.${global_iteration_counter}.ivf outputs/${chunk_name}.${global_iteration_counter}.exit.state}
and die q{phase1 exited with error};
}
$global_iteration_counter++;
# phase 2a
print STDERR "=== Phase 2a (encode-given-state) ===\n";
for ( my $i = 1; $i < $N_chunks; $i++ ) {
my $this_input_video = $orig_videos[ $i ];
my $chunk_name = video_basename( $this_input_video );
my $last_chunk_name = video_basename( $orig_videos[ $i - 1 ] );
my $last_iteration = $global_iteration_counter - 1;
die unless ( $last_iteration >= 0 );
system qq{./phase2a ${this_input_video} outputs/${chunk_name}.${last_iteration}.ivf outputs/${last_chunk_name}.${last_iteration}.exit.state outputs/${chunk_name}.${global_iteration_counter}.ivf outputs/${chunk_name}.${global_iteration_counter}.exit.state}
and die q{phase2a exited with error};
}
$global_iteration_counter++;
# phase 2b
print STDERR "=== Phase 2b (rebase) ===\n";
for ( my $i = 2; $i < $N_chunks; $i++ ) {
my $this_input_video = $orig_videos[ $i ];
my $chunk_name = video_basename( $this_input_video );
my $last_chunk_name = video_basename( $orig_videos[ $i - 1 ] );
my $last_iteration = $global_iteration_counter - 1;
my $last_chunk_last_iteration = $global_iteration_counter - 1;
my $last_chunk_last_last_iteration = 0;
if ( $i > 2 ) {
$last_chunk_last_iteration = 2;
}
system qq{./phase2b ${this_input_video} outputs/${chunk_name}.${last_iteration}.ivf outputs/${last_chunk_name}.${last_chunk_last_last_iteration}.exit.state outputs/${last_chunk_name}.${last_chunk_last_iteration}.exit.state outputs/${chunk_name}.${global_iteration_counter}.ivf outputs/${chunk_name}.${global_iteration_counter}.exit.state}
and die q{phase2b exited with error};
}
$global_iteration_counter++;
# playability
print STDERR "=== Testing (decode-bundle) ===\n";
my $ivfs = "";
for ( my $i = 0; $i < $N_chunks; $i++ ) {
my $this_input_video = $orig_videos[ $i ];
my $chunk_name = video_basename( $this_input_video );
if ( $i == 0 ) {
$ivfs = qq{outputs/${chunk_name}.0.ivf};
}
elsif ( $i == 1 ) {
$ivfs .= qq{\noutputs/${chunk_name}.1.ivf};
}
else {
$ivfs .= qq{\noutputs/${chunk_name}.2.ivf};
}
}
system qq{echo "${ivfs}" | xc-decode-bundle > /dev/null}
and die q{xc-decode-bundle exited with error}