There are lots of other scripts that do similar things, but I created this script to handle wildcards, work recursively, and handle filenames with spaces and other strange characters (question marks, single quotes, double quotes, etc). Hopefully this script saves you some time with file conversion, it should be especialy useful for making mp3 CDs for portable mp3 players. It may look complicated, but its actually quite simple to use; just look at some of the examples and play around with it a bit. Its released under the GNU GPL version 2.
Here's a few other OSS audio manipulation programs that I've found but haven't used:
»http://soundconverter.berlios.de/ GTK and Python based GUI conversion program that uses Gstreamer for conversion of audio formats, very impressive program. Great for those who prefer GUIs. Currently it cannot read wma files.
»http://pacpl.sourceforge.net/
»https://savannah.nongnu.org/projects/audio-convert
»http://klira.sourceforge.net/
Mp3gain »http://mp3gain.sourceforge.net/ is a great program that can adjust the gain of mp3s with a lossless method that doesn't rely on replayGain settings. This is only useful for mp3s however, so its not used by this script. This script uses normalize to normalize the intermediate .wav file before converting to the desired output format.
"./audio_conv.py" or: "python audio_conv.py" "./audio_conv.py -h" will display detailed help info and usage.
usage: audio_conv.py -i <input> [options] --to-mp3 | --to-ogg | --to-wav | --to-flac This script is for conveting from an input audio format to an intermediate wav file, then outputting to the selected output format while keeping the tag info. At first this sounds crazy, why go from one lossy format to another? This may be the only option for your portable mp3 player. It is also an easy way to convert a music collection from a high quality format (eg: flac or wav) to a different format (eg: mp3 or ogg vorbis). Optionally works recursively, keeps the tag information, and handles filenames with strange characters such as spaces, single quotes, and question marks. It can also output the converted file to a different directory, maintaining the directory structure. Most of the other wma2ogg or ogg2mp3 scripts fail on these or dont do recursion, which is why this script exists. Supported input formats: wma flac wav ogg mp3 rpm RealAudio streams rm/ra RealAudio files Supported output formats: wav flac mp3 ogg Requires mplayer (for wma), vorbis tools, flac, lame, normalize and mp3info. Note: if there are no tags in the input file, the filename will be used as the 'title' tag in the output file. Examples: This example converts the ogg vorbis file 'foo.ogg' to 'foo.mp3': audio_conv.py -i foo.ogg --to-mp3 This example converts all wma files to ogg vorbis files in a directory (not recursive and wont delete the original files): audio_conv.py -i "*.wma" --to-ogg This command passes a string to the encoder (lame in this case, since mp3s are being created), which can be any sort of option (variable bitrate, mode, etc). The option here specifies that variable bitrate level 6 is to be used (see encoder documentation for more info): audio_conv.py -i file.mp3 --to-mp3 --encoder-option "-V 6" This dry-run example lists all the files that would be processed, but are simply listed instead (an output format is needed, so --to-mp3 is chosen though no conversion is done): audio_conv.py -i "*.wma" -r --to-mp3 --dry-run This command converts all recoginized files to mp3s recursively, performs normalization and deletes the original files. If the file doesn't have a recognized extension, then it is skipped. audio_conv.py -i "*.*" --to-mp3 --recursive --normalize --delete Here is the same command with short options: audio_conv.py -i "*.*" --to-mp3 -r -n -d This is the same command, but with a different destination directory. This will duplicate the directory structure present in the source to subdirectories of the destination directory populating it only with the converted files. audio_conv.py -i "*.*" --to-mp3 -r -n -d --dest-dir /home/user/newdir options: -h, --help show this help message and exit -i INPUT, --input=INPUT Specify input file, accepts wildcards in quotes. -b BITRATE, --bitrate=BITRATE Specify bitrate of output file. Some encoders(eg Lame) will only accept certain values such as 32, 40, 48, 56, 64, 80, 96, 112, 128, etc. The default bitrate of the output file is the same as the input bitrate. This option will be ignored if the '--encoder-option' is used. -r, --recursive Convert all files matching the input filename in current directory and all subdirectories. If using wildcards, they must be in quotes. --dry-run List the path of each input file and output file but do not convert anything. --to-ogg Ogg vorbis output format. --to-mp3 Mp3 output format --to-wav Wav output format --to-flac Flac output format -n, --normalize Normalize the volume of output files. -d, --delete Delete the input file after conversion (use with caution!). -f, --force Force conversion of files even if the input and output bitrate are the same [default skips these files]. --dest-dir=DESTINATION Specify a different output directory. This will duplicate the same file and directory structure seen in the source directory, and populate it with converted files. If the destination directory does not exist, it will be created. Works especially well with the recursive option. -t PATH, --tempfile=PATH Specify the path for a user defined tempfile. The default tempfile uses a system tempfile. -e STRING, --encoder-option=STRING Specify options to be passed to the encoder. May include any option supported by the encoder such as variable bitrate encoding. This option overrides the 'bitrate' option, so a custom bitrate or vbr setting should be specified otherwsie the encoder will use its default bitrate. Be careful not to specify tags that may conflict with tags taken from input file. String must be encapsulated by quotes. -v, --verbose Show all standard output and error messages from backend programs. Default is to hide these messages.
Email: crleblanc at gmail dot com.
(Powered by PWP Version 1-4-3 )