Sponsored Content
Full Discussion: Batch MP3 transcoding.
Top Forums Shell Programming and Scripting Batch MP3 transcoding. Post 302270466 by lvxferre on Monday 22nd of December 2008 02:23:56 AM
Old 12-22-2008
Batch MP3 transcoding.

Hello everyone, I've made a script and I want to share and get new ideas for improving it. So far, the script

1. Searches a directory tree for MP3 files;
2. Check their bitrates;
3. Change any bitrate higher than 128 kbps to VBR 4
(It ignores files with a bitrate lower or equal to 128, as well already with variable bitrate);
4. Remove original files.

The script uses MP3Info, Gawk, and Lame. I've made it for Bash, but I think it would work in others shells too.

Here it is:
Code:
#!/bin/bash
#Script made by Eduardo Xavier - eduardoc[dot]xavier[at]yahoo[dot]com[dot]br
#Script license: GPL v3

#Makes a MP3s list in the dir, with bitrates, in "allfiles.list":
find . -name "*.mp3" -exec mp3info -r v -p "%r \"%F\"\n" '{}' \; > allfiles.list

#Filter only files with 160, 192, 224, 256 or 320 bitrates:
gawk '$1 == 160 {$1 = ""; print}
$1 == 192 {$1 = ""; print}
$1 == 224 {$1 = ""; print}
$1 == 256 {$1 = ""; print}
$1 == 320 {$1 = ""; print}' allfiles.list > onlyhigh.list

#Change the filtered files to VBR, quality 4:
gawk '{system("lame -v" $0)}' onlyhigh.list

#Remove original files. Comment the line below if you don't want this happening.
gawk '{system("rm" $0)}' onlyhigh.list

#Remove os arquivos de listas que foram feitos.
rm onlyhigh.list allfiles.list

Troubles until now:
*IDE3 tags are lost (not a great deal since I name all my MP3s with the relevant info);
*The output files are all with extension ".mp3.mp3", I want the script renaming them automatically (however, I made this with KRename).
*The script is slow. Especially in the LAME part.

Anyone got ideas?
 

5 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

MP3 driver for Unix

I need to play mp3 sound files on unix platform. Is there any mp3 drivers available for unix (rue unix-64 and unixware 7.0)? (3 Replies)
Discussion started by: parbende
3 Replies

2. Shell Programming and Scripting

Sorting mp3

Hi all... Here's my question: -> considering i've got thousands of mp3s', named like "Artist name - Track Name", how could i write a shell (ksh, or bash my favorite, not knowinf enough any other language) that would create a directory (if not existing already) with the Artist's name, and move... (3 Replies)
Discussion started by: penguin-friend
3 Replies

3. UNIX for Dummies Questions & Answers

mp3 codec

I just need a mp3 codec that will decode mp3s so I can play them with my media player (probably going to be using XMMS) (0 Replies)
Discussion started by: Synbios
0 Replies

4. Shell Programming and Scripting

Check file is mp3

Hello, I am trying to check if a file is an mp3. file -b file_path g ives me AUDIO for many MP3 but there are many working MP3 files that return something else. How can I get better result? Thank you (2 Replies)
Discussion started by: JCR
2 Replies

5. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies
MP3::Tag::File(3pm)					User Contributed Perl Documentation				       MP3::Tag::File(3pm)

NAME
MP3::Tag::File - Module for reading / writing files SYNOPSIS
my $mp3 = MP3::Tag->new($filename); ($title, $artist, $no, $album, $year) = $mp3->parse_filename(); see MP3::Tag DESCRIPTION
MP3::Tag::File is designed to be called from the MP3::Tag module. It offers possibilities to read/write data from files via read(), write(), truncate(), seek(), tell(), open(), close(); one can find the filename via the filename() method. parse_filename() ($title, $artist, $no, $album, $year) = $mp3->parse_filename($what, $filename); parse_filename() tries to extract information about artist, title, track number, album and year from the filename. (For backward compatibility it may be also called by deprecated name read_filename().) This is likely to fail for a lot of filenames, especially the album will be often wrongly guessed, as the name of the parent directory is taken as album name. $what and $filename are optional. $what maybe title, track, artist, album or year. If $what is defined parse_filename() will return only this element. If $filename is defined this filename will be used and not the real filename which was set by MP3::Tag with "MP3::Tag->new($filename)". Otherwise the actual filename is used (subject to configuration variable "decode_encoding_filename"). Following formats will be hopefully recognized: - album name/artist name - song name.mp3 - album_name/artist_name-song_name.mp3 - album.name/artist.name_song.name.mp3 - album name/(artist name) song name.mp3 - album name/01. artist name - song name.mp3 - album name/artist name - 01 - song.name.mp3 If artist or title end in "(NUMBER)" with 4-digit NUMBER, it is considered the year. title() $title = $mp3->title($filename); Returns the title, guessed from the filename. See also parse_filename(). (For backward compatibility, can be called by deprecated name song().) $filename is optional and will be used instead of the real filename if defined. artist() $artist = $mp3->artist($filename); Returns the artist name, guessed from the filename. See also parse_filename() $filename is optional and will be used instead of the real filename if defined. track() $track = $mp3->track($filename); Returns the track number, guessed from the filename. See also parse_filename() $filename is optional and will be used instead of the real filename if defined. year() $year = $mp3->year($filename); Returns the year, guessed from the filename. See also parse_filename() $filename is optional and will be used instead of the real filename if defined. album() $album = $mp3->album($filename); Returns the album name, guessed from the filename. See also parse_filename() The album name is guessed from the parent directory, so it is very likely to fail. $filename is optional and will be used instead of the real filename if defined. comment() $comment = $mp3->comment($filename); # Always undef genre() $genre = $mp3->genre($filename); # Always undef perl v5.14.2 2009-11-28 MP3::Tag::File(3pm)
All times are GMT -4. The time now is 05:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy