Re: mp3tom4a via find and ffmpeg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 12 Aug 2011 13:42:36 -0400
Paul Davis <paul@xxxxxxxxxxxxxxxxxxxxx> 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.
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user


[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux