LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 08-10-2006, 04:29 PM   #31
TradedManatee
LQ Newbie
 
Registered: Feb 2006
Posts: 5

Rep: Reputation: 0
Newer versions of mplayer


[
mplayer -ao pcm -aofile "${i%.wma}.wav" "$i" && lame -h "${i%.wma}.wav" "${i%.wma}.mp3"

]

Newer versions of mplayer have a slightly different syntax:

mplayer -ao pcm:file="${i%.wma}.wav" ...
 
Old 08-20-2007, 01:26 AM   #32
WARnux
LQ Newbie
 
Registered: Jun 2007
Distribution: Debian with KDE
Posts: 17

Rep: Reputation: 0
I thought I'd submit a fixed version of the original perl script:
Code:
#!/usr/bin/perl

#Searches a directory for mp3 files,
#normalizes the sound and then
#creates an .ogg file.

#$fromExt and $toExt can be used to change
#the default conversions. Remember
#to change the oggenc line as well.

#Modified by WARnux but still has no warrenty

$fromExt='mp3';
$toExt='ogg';
$tmpDir='/tmp/NormalizeAndConvertTmp/';
$outDir='./';
#'./Normalized_'.$toExt.'/';
mkdir($tmpDir);
mkdir($outDir);

$dir=`pwd`;
chop($dir);
opendir(checkdir,"$dir");

while($file=readdir(checkdir))
{
	$orig_file= $file;
#/in here matches a regex/
#$ makes it match the end of the string and i is for case insensitive
	if($orig_file !~ /\.$fromExt$/i)
	{next};
	
	print "Checking file: $orig_file\n";
	
	$temp= $orig_file;
#s is for substitute; it will replace the first match with the second string
	$temp =~ s/\.$fromExt$/\.wav/i;
	$out= $orig_file;
	$out =~ s/\.$fromExt$/\.$toExt/i;
	
	$convert1= "mplayer \"./$orig_file\" -vc null -vo null -af volnorm -ao pcm:file=\"$tmpDir$temp\"";
	$convert2= "oggenc \"$tmpDir$temp\" -o \"$outDir$out\"";
#"lame -h \"$tmpDir$temp\" \"$outDir$out\"";
	$remove_temp= "rm -rf \"$tmpDir$temp\"";
	
	print "Converting to .wav: $convert1\n";
	$cmd= `$convert1`;
	print "Converting to .ogg: $convert2\n";
	$cmd= `$convert2`;
	print "Removing .wav: $remove_temp\n";
	$cmd= `$remove_temp`;
	print "\n\n";
}
rmdir($tmpDir);
print "Done.\n\n";
The original had a few issues if files were .MP3 or .mp3.mp3 and I added scalability and other improvements. Oh, and by default, it converts mp3 not wma but that's easily changed.

Last edited by WARnux; 08-20-2007 at 08:03 AM. Reason: Didn't keep some slashes in post with [php]
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert wma to ogg lixy Linux - Software 20 10-12-2011 06:58 PM
DISCUSSION: Convert WMA to MP3 cadj LinuxAnswers Discussion 101 06-05-2011 10:06 AM
Wma to Mp3 Knowledgements Slackware 23 09-23-2006 10:07 AM
Any program that can convert mp3 files to wma? josh_hd_new Linux - Newbie 1 01-21-2005 03:03 AM
how to convert a wma to mp3?? yenonn Linux - General 2 04-26-2004 08:25 PM


All times are GMT -5. The time now is 01:00 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration