blob: 88c6f93d57e15ba2507c4e6b467b31dc1a2824f0 (
plain) (
blame)
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
|
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
sub checktype_filename {
# reads in 1kb of selected file, or returns undef if can't open,
# then checks contents
my($filename) = @_;
my $fh = IO::File->new($filename) || return;
my $data;
$fh->sysread($data, 1024);
$fh->close;
return $data;
}
sub personal_check {
my ($read) = @_;
if ($read =~ m/V_VP9/) {
return "WebM V9 detected.";
}
elsif ($read =~ m/V_VP8/) {
return "WebM V8 detected.";
}
elsif ($read =~ m/WEBPVP8L/) {
return "WebP V8 (Lossless) detected.";
}
elsif ($read =~ m/WEBPVP8/) {
return "WebP V8 (Not Lossless) detected.";
}
elsif ($read =~ m{google/video-file}) {
# Guess which mime is impossible to find info for?
# I happen to know that iPhone's can't play it.
return "WebM google/video-file.";
}
else {
return;
}
}
for (my $i = 0; $i < @ARGV; $i++) {
if (! -e $ARGV[$i]) {
warn "$ARGV[$i] doesn't exist or is not a file.";
next;
}
my $read = checktype_filename($ARGV[$i]). "\n";
my $matched = personal_check($read);
if ($matched) {
say "$ARGV[$i]: $matched";
#say "$matched";
}
else {
say "$ARGV[$i]: $read";
}
}
|