blib/lib/Media/Convert/FfmpegInfo.pm

filter: Statementstmt 40.8% 20 / 49 Branchbran 0.0% 0 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod n/a totaltotal 29.2% 24 / 82 CC 16 SCAR 45.5
CC
16
Cov
26%
_build_codecs
132.7
_build_version
12.0
BEGIN
1.0
CRAP 94.9
« blib/lib/Media/Convert/Map.pm ↑ Summary blib/lib/Media/Convert/AccurateCut.pm »
1 package Media::Convert::FfmpegInfo;
2  
3 2 ▶use MooseX::Singleton;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use SemVer;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 has 'codecs' => (
8 is => 'ro',
9 isa => 'HashRef',
10 lazy => 1,
11 builder => '_build_codecs',
12 );
13  
14 2 ▶sub _build_codecs {
Subroutine _build_codecs: called CC=14 SCAR=48.9
15 2 local $/ = "";
16 2 open my $ffmpeg, "-|", "ffmpeg -codecs 2>/dev/null";
17 2 my $codeclist = <$ffmpeg>;
18 2 close $ffmpeg;
19 2 my $parsing = 0;
20 2 my $rv = {};
21 2 foreach my $line(split /\n/, $codeclist) {
22 0 ▶ if(!$parsing) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsing) 0 0 0
23 0 ▶ if($line =~ /^ ---+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^ ---+/) 0 0 0
24 0 $parsing = 1;
25 }
26 0 next;
27 }
28 0 my ($decode, $encode, $type, $intra, $lossy, $lossless, $name, $desc) = unpack("xAAAAAAxA20xA*", $line);
29 0 my $h = {};
30 0 ▶ $h->{decode} = ($decode eq "D") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$decode eq 'D' ? : 0 0 0
31 0 ▶ $h->{encode} = ($encode eq "E") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$encode eq 'E' ? : 0 0 0
32 0 $h->{type} = $type;
33 0 ▶ $h->{is_video} = ($type eq "V") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'V' ? : 0 0 0
34 0 ▶ $h->{is_audio} = ($type eq "A") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'A' ? : 0 0 0
35 0 ▶ $h->{is_subtitle} = ($type eq "S") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'S' ? : 0 0 0
36 0 ▶ $h->{is_data} = ($type eq "D") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'D' ? : 0 0 0
37 0 ▶ $h->{is_attachment} = ($type eq "T") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'T' ? : 0 0 0
38 0 ▶ $h->{is_intra_only} = ($intra eq "I") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$intra eq 'I' ? : 0 0 0
39 0 ▶ $h->{is_lossy} = ($lossy eq "L") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$lossy eq 'L' ? : 0 0 0
40 0 ▶ $h->{is_lossless} = ($lossless eq "S") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$lossless eq 'S' ? : 0 0 0
41 0 $h->{name} = $name;
42 0 $h->{description} = $desc;
43 0 $rv->{$name} = $h;
44 };
45 2 return $rv;
46 }
47  
48 2 has version => (
49 is => 'ro',
50 isa => 'SemVer',
51 lazy => 1,
52 builder => '_build_version',
53 );
54  
55 0 ▶sub _build_version {
Subroutine _build_version: not called CC=3 SCAR=24.8
56 0 open my $ffprobe, "-|", "ffprobe -loglevel quiet -show_program_version -print_format json";
57 0 local $/ = undef;
58 0 my $json = decode_json(<$ffprobe>);
59 0 my $version = $json->{program_version}{version};
60 0 ▶ if($version =~ /([0-9.]+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version =~ /([0-9.]+)/) 0 0 0
61 0 my $ver = $1;
62 0 ▶ while(scalar(split /\./, $ver) < 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar split(/\./, $ver, 0) < 3) 0 0 0
63 0 $ver .= ".0";
64 }
65 0 return SemVer->new($ver);
66 }
67 }
68  
69 2 1;
« blib/lib/Media/Convert/Map.pm ↑ Summary blib/lib/Media/Convert/AccurateCut.pm »