Time for Friday afternoon fun!!
Ever want to make one of those animated videos, like are currently popular on american tv, that are obviously recorded, yet appear to be drawn? Here is a 1 shot script to do it. A more powerful program to do this is Lives
A sample video is at a sample from youtube and it's charcoal version in avi format and it's charcoal in flv format
UPDATE: See comments below on how to convert the avi output back to flv output. (to address grandfather's problem on XP)
#!/usr/bin/perl use warnings; use strict; use File::Path qw(rmtree); use Image::Magick; # Usage: $0 colors.flv OR $0 r # The r option will skip ripping and recombine # the contents of the riptemp-$base subdir. # This allows you to manually edit individual files. # If more than 2 riptemp dirs are present, the first # in a dirlist will be used. So.... work on 1 at a time # in their own directories. This is just a snippet. :-) # I admit, that the Lives (Linux Video Editing System) # at http://lives.sourceforge.net/ # is much more powerful than this. Check it out, and # it's "smogrify" perl script.... which is it's workhorse. $|++; my $video = shift || 'colors.flv'; my $base; if($video eq 'r'){ recombine(); }else{ $video =~ /^(.+)(\.\w+)$/; $base = $1; } #rip to jpg's and audio #will make it's own temp dir my @moptions =( 'mplayer', '-osdlevel', 0, '-vo', "jpeg:quality=100:outdir=riptemp-$base:maxfiles +=2000", '-noframedrop', #important for quality '-ao', "pcm:file=$base.wav", $video, ); system(@moptions); opendir my $dh, "riptemp-$base" or die "Error: $!\n"; my @files = grep !/^\.\.?$/, readdir $dh; closedir $dh; my $p = new Image::Magick; #only make one and reuse my $max = scalar @files; my $count = 0; foreach my $file ( @files ) { # operate on jpgs for effects $count++; print "\rprocessing file $count/$max"; $p->Read("riptemp-$base/$file"); $p->Negate(); $p->Charcoal('0x1'); $p->Write("riptemp-$base/$file"); undef @$p; #clear out object data } print "\n\nDone effects processing\n\n"; ##################### # recombine recombine(); #ask to keep clips or not print "\n\nDone! Delete temp clips? (n/y) Defaults to n\n"; my $return = <>; if($return =~ /^[yY].*$/){ rmtree("riptemp-$base", 0, 1); # verbose report, and ignore undelete +ables }else{exit} ##################################################################### sub recombine{ opendir my $dh, '.' or die "Error: $!\n"; my @files = grep !/^\.\.?$/, readdir $dh; @files = grep /^riptemp-(.*)$/, @files; closedir $dh; my $dir = $files[0]; $dir =~ /^riptemp-(.*)$/; my $base = $1; #print "$dir\t$base\n"; my @moptions =( 'mencoder', "mf://$dir/*.jpg", '-mf', 'fps=29.97', #NTSC tv video rate in '-audiofile', "$base.wav", '-srate', 22050, '-o', "$base-char.avi", '-ovc', 'lavc', '-lavcopts', 'vcodec=mpeg4:vbitrate=100', '-oac', 'mp3lame', # '-audio-delay', 0.2, #adjust for audio syncing problems ); system(@moptions); } ###################################################################### +3
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: z-charcoal-video-converter
by GrandFather (Saint) on Sep 15, 2006 at 19:40 UTC | |
by wazoox (Prior) on Sep 16, 2006 at 09:20 UTC | |
by zentara (Archbishop) on Sep 16, 2006 at 11:32 UTC | |
Re: z-charcoal-video-converter
by wazoox (Prior) on Sep 16, 2006 at 09:22 UTC | |
Re: z-charcoal-video-converter
by zentara (Archbishop) on Sep 16, 2006 at 14:09 UTC | |
Re: z-charcoal-video-converter
by yzf888 (Initiate) on Oct 08, 2009 at 12:03 UTC |
Back to
Cool Uses for Perl