http://qs321.pair.com?node_id=573230

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

    RealPlayer 10.5 on Windows XP only renders a sound track for colors-char.avi


    DWIM is Perl's answer to Gödel
      Maybe you could try renaming it from .avi to .mpeg or .mpg? It actually is an mpeg video, but most players I've seen can properly detect the encoding. Maybe XP thinks an avi has to be a real avi, because of some file associations?

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum
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
    In case your system can play flv files, but not the avi produced by the script, here are 2 methods to do the conversion. The ffmpeg method produces the exact file size of the original flv input file. The mencoder method produces a flv which is smaller than the original, but the docs for mencoder say it is still somewhat buggy, and requires an odd commandline switch.

    Using ffmpeg

    #!/bin/sh ffmpeg -i $1 -f flv `basename $1 .avi`.flv

    And the mencoder method

    #!/bin/sh mencoder $1 -of lavf -ovc lavc \ -lavcopts vcodec=flv:vbitrate=150 \ -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames \ -ofps 29.97 -oac mp3lame -srate 22050 \ -o `basename $1 .avi`.flv

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: z-charcoal-video-converter
by yzf888 (Initiate) on Oct 08, 2009 at 12:03 UTC