動画の縦横サイズごとの振り分け
http://d.hatena.ne.jp/ore_de_work/20130123#1358948425
例のSONY動画プレイヤーは縦480以上はHARD DECORDERで再生できない。
というわけで、動画をトランスコードするんだが、なにがトランスコード済かどうかわかんない。
なので、サイズごとにフォルダに振り分け
mplayer使うのでパスは通しておいてください。
#!/bin/perl use strict; use warnings; use File::Path; use Cwd 'getcwd'; use Fcntl; use File::Find; use utf8; use File::Copy; my %wh = (); find( \&d, '.' ); sub d{ return if($_ eq '.'); return if($_ eq '..'); return unless(-f); my $file = $_; # for my $f(1..5){ open my $info, 'mplayer -vo null -ao null -ni -nobps -forceidx -mc 0 -frames ' . $f . ' "' . $file . '" |'; while(<$info>) { if (/^VO: \[null\] (\d+)x(\d+) => (\d+)x(\d+).*$/) { $wh{$file} = sprintf "%sx%s" , $1, $2; } } close $info; print "$wh{$file} ($f) : $file --" . exists($wh{$file}) . "--\n"; last if(exists($wh{$file})); } } foreach my $file(sort keys %wh ) { next unless(exists($wh{$file})); mkdir $wh{$file}; my $dst = $wh{$file} . "\\" . $file; print " cwd : " . getcwd . " as : $wh{$file} rename : $file -> $dst "; move $file, $dst || print $!; }