#!/usr/bin/perl -w # createvcd.pl - by dual # # Put createvcd.pl in the directory of # the AVIs you want to convert and issue # the following command: # # perl createVCD.pl -[vs] # # -v = VCD # -s = SVCD ######################################## use strict; # Check for format switch print ">>> Use -v for VCD or -s for SVCD...\n" and exit unless defined(my $format = shift); # Check for tovid and vcdimager my $tovid = `whereis tovid`; my (undef, $loc_of_tovid) = split(/: /, $tovid); defined($loc_of_tovid) ? print "Good, tovid found: $loc_of_tovid" : (print ">>> tovid not found: exiting...\n" and exit); my $vcdi = `whereis vcdimager`; my (undef, $loc_of_vcdi) = split(/: /, $vcdi); defined($loc_of_vcdi) ? print "Good, vcdimager found: $loc_of_vcdi" : (print ">>> vcdimager not found: exiting...\n" and exit); # Replace spaces in file names with underscores foreach my $temp (<*>) { my $newtemp = $temp; if ($newtemp =~ s/\s/_/g) { rename $temp, $newtemp; } } # Glob files my @files = <*>; # Convert files foreach my $file(@files) { if ($file =~ /\w+\.avi/) { my ($prefix, undef) = split(/\./, $file); if ($format =~ /-v/i) { system("tovid -vcd $file $prefix && vcdimager -c $prefix.cue -b $prefix.bin $prefix.mpg"); } elsif ($format =~ /-s/i) { system("tovid -svcd $file $prefix && vcdimager -t svcd -c $prefix.cue -b $prefix.bin $prefix.mpg"); } else { print ">>> Incompatible format switch\n"; print ">>> Use -v for VCD or -s for SVCD...\n"; exit; } } else { print ">>> $file not AVI: skipping...\n"; } } # Print closing message print " * Finished * \n";