středa 28. prosince 2011

spojit videa


#!/usr/bin/perl -w

# create a list of all *.MP4 files in
# the current directory
# YYYY_MM_DD_HHmmSS.MP4
opendir(DIR, ".");
@files = sort { $a cmp $b } grep(/\.MP4$/,readdir(DIR));
closedir(DIR);

# print all the filenames in our array
my $lastPrefix = '';
my $command = 'MP4Box';

my $cnt = 0;
my $auxCnt = 0;
my $curCmd = "$command";
my $LIMIT=20;

foreach $file (@files) {
my $prefix = substr $file, 0, 10;
if ($prefix ne $lastPrefix or $cnt >= $LIMIT){
print "\n$prefix $file\n";
if ($lastPrefix ne ''){
&doFile();
}
}
++$cnt;
$curCmd .= " -cat \"$file\"";
$lastPrefix = $prefix;

}
&doFile();


sub doFile {
my $cmd = "$curCmd -new ./spojeno/$lastPrefix.JOINED.".sprintf("%03d",$auxCnt).".MP4";
print ($cmd);
system ($cmd);
++$auxCnt;
$curCmd = "$command";
$cnt = 0;
}

Žádné komentáře: