[LAU] mp3tom4a via find and ffmpeg
    David 
    dplist at free.fr
       
    Fri Aug 12 18:52:05 UTC 2011
    
    
  
On Fri, 12 Aug 2011 13:42:36 -0400
Paul Davis <paul at linuxaudiosystems.com> wrote:
> I strong, STRONGLY *STRONGLY recommend *not* doing file manipulations
> on audio files inside the shell. the proliferation of what once would
> have been considered "wierd" names for files makes this extremely
> "risky". it is very hard to prevent the shell from somehow getting
> stuff wrong when the filenames can include ' or " or $ themselves.
> 
> use perl or python to do what you want, and thus avoid every issue
> with shell globbing etc.
You're right Paul, of course. So here is the hopefully safe Perl
version :
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
use File::Copy;
sub wanted {
	my $input = $File::Find::name;
	return unless (-f $input);
	return unless ($input =~ m/\.mp3$/);
	my $output = $input;
	$output =~ s/\.mp3$/.m4a/;
	File::Copy::copy($input, "/tmp/i.$$");
	`ffmpeg -i /tmp/i.$$ -y -acodec libfaac -ab 192k /tmp/o.$$`;
	rename("/tmp/o.$$", $output);
	unlink("/tmp/i.$$");
}
File::Find::find({wanted => \&wanted}, '.');
-- David.
    
    
More information about the Linux-audio-user
mailing list