Convertir des fichiers WMA en MP3

Comment faire pour convertir facilement des WMA en MP3 sous Linux

Pré requis logiciels

Les logiciels suivants doivent etre presents :

  • perl
  • mplayer
  • lame

Le script

#! /usr/bin/perl

### WMA TO MP3 CONVERTER

$dir=`pwd`;

## READ EACH FILE, IF WMA, MAKE A "COPY" TO WAV THEN TO MP3 THEN DELETE WMA

chop($dir);

opendir(checkdir,"$dir");

while ($file=readdir(checkdir)) {

$orig_file=$file;

if ($orig_file !~ /\\.wma$/i) {next};

print "Checking file: $orig_file

";


$new_wav_file=$orig_file;$new_wav_file=~s/\\.wma/\\.wav/;
$new_mp3_file=$orig_file;$new_mp3_file=~s/\\.wma/\\.mp3/;

$convert_to_wav="mplayer \\"./$orig_file\\" -ao pcm -aofile \\"./$new_wav_file\\"";
$convert_to_mp3="lame -h \\"./$new_wav_file\\" \\"./$new_mp3_file\\"";
$remove_wav="rm -rf \\"./$new_wav_file\\"";

print "EXEC 1: $convert_to_wav

";

$cmd=`$convert_to_wav`;
print "EXEC 2: $convert_to_mp3

";

$cmd=`$convert_to_mp3`;
print "REMOVE WAV: $remove_wav

";

$cmd=`$remove_wav`;
print "

";

}

print "Done.";
Vus : 75
Publié par Littlewing : 368