WAV - MP3 Paperclip-processor

Uploads WAV files and converts them to MP3.

Requirements

  1. Rails 3

  2. Paperclip

  3. Lame

Install

Follow instructions on Lame

Include:

gem ‘wav-mp3’ & run:

bundle install

Or: gem install wav-mp3

Usage

Inside Model include:

has_attached_file :wav,

:styles => {
   :mp3 => { 
     :params => "-q1 -b 320",
     :format => "mp3" }
  },
  :processors => [:wav_mp3]

Plugin will upload and save song.wav file & convert and save song.mp3 file…

be carefull

it wont work with files that have special characters. Keep file-names simple an web friendly… or fork the GEM

Params

Quality related:

-m m/s/j/f/a mode selection -q n Internal algorithm quality setting 0..9. 0 = slowest algorithms, but potentially highest quality 9 = faster algorithms, very poor quality -h same as -q2 -f same as -q7

Constant Bit Rate (CBR)

-b n set bitrate (8, 16, 24, …, 320) –freeformat produce a free format bitstream. User must also specify a bitrate with -b, between 8 and 640 kbps.

Variable Bit Rate (VBR)

-v VBR –vbr-old use old variable bitrate (VBR) routine –vbr-new use new variable bitrate (VBR) routine (default) -V n VBR quality setting (0=highest quality, 9=lowest) -b n specify a minimum allowed bitrate (8,16,24,…,320) -B n specify a maximum allowed bitrate (8,16,24,…,320) -F strictly enforce minimum bitrate -t disable VBR informational tag –nohist disable display of VBR bitrate histogram

–abr n specify average bitrate desired

ID3 tagging:

–tt <title> audio/song title (max 30 chars for version 1 tag) –ta <artist> audio/song artist (max 30 chars for version 1 tag) –tl <album> audio/song album (max 30 chars for version 1 tag) –ty <year> audio/song year of issue (1 to 9999) –tc <comment> user-defined text (max 30 chars for v1 tag, 28 for v1.1) –tn <track> audio/song track number (1 to 255, creates v1.1 tag) –tg <genre> audio/song genre (name or number in list) –add-id3v2 force addition of version 2 tag –id3v1-only add only a version 1 tag –id3v2-only add only a version 2 tag –space-id3v1 pad version 1 tag with spaces instead of nulls –pad-id3v2 same as ‘–pad-id3v2-size 128’ –pad-id3v2-size <num> adds version 2 tag, pad with extra <num> bytes –genre-list print alphabetically sorted ID3 genre list and exit

For more details about Lame parameters visit: lame.cvs.sourceforge.net/viewvc/lame/lame/USAGE

Gem info

created by: moonFlash twitter: moonflash