Welcome GuestLogin

A Drunken Wiki

RSS RSS

A Drunken Wiki is the companion wiki to the blog "A Drunken Madman", written by Jason Brown.

Navigation




Search the wiki
»

Vaccination Saves Lives: Stop The Australian Vaccination Network


Find me on Twitter, Facebook, Google+, Pinterest and LinkedIn





Pin It






Alpha Archive Atheism Blue Mountains Climbing Cycling Development DotNet GPS Guitar HMHB JavaScript JQuery LINQ Meta MTB Music Perl Powershell RNP SharePoint Skepticism Social Media Training Ukulele Vaccines Visual Studio WebParts Woodford Festival 2011 XML

PoweredBy

Driving FFMPEG with ActivePerl

RSS
Modified on 2012/05/01 02:40 by Administrator Categorized as Development, Perl
This example Perl script takes all AVIs in a folder (and its subfolders) and converts them to MP4s suitable for iPod/iPhone

for(`dir /S /B /A:-D`)	{
	if($_ =~ /avi/gi)	{
		chomp;
		my $repl = $_;
		$repl=~ s/avi/mp4/gi;
		`ffmpeg -pre libx264-ipod640 -i \"$_\" \"$repl\"`;
		print "\r\n";
	}
}

Requires FFMPEG in the system's PATH variable, and the script needs to be inside the folder of target videos, or its parent folder. Requires ActivePerl

Warning if editing - uses interpolation within backticks and as such it's easy to exploit via input.

Can be used equally to convert audio files - for instance between WAV, MP3, FLAC, OGG and so on. Very useful if, like me, you've ripped CDs to OGG or FLAC in the past and now own an iPhone which won't play them.



This technique can be used to drive just about any command-line process, so it's very useful, but needs respect. It's easy to do terrible things.

 

ScrewTurn Wiki version 3.0.5.600. Some of the icons created by FamFamFam.