LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   nautilus script audio conversion (https://www.linuxquestions.org/questions/linux-software-2/nautilus-script-audio-conversion-697095/)

itzig 01-13-2009 04:28 PM

nautilus script audio conversion
 
HI Im running Ubuntu 7.10 and Gnome. I was trying to batch convert a bunch of wave file to high quality mp3's(320kbs). I figured it's best to use those nautilus scripts below:
http://g-scripts.sourceforge.net/cat-multimedia.php
I copied them to the scripts directory, and made them executable.
When I right click in nautilus and choose audio-converter or Naudilus, nothing happens. When I try Wom-audio converter a window comes up where only the mp3's option does anything at all, and it only puts out an empty file (0kb)!?
What am I missing here?

thank you!

itzig 01-14-2009 08:13 PM

update: I found this:
https://bugs.launchpad.net/ubuntu/+s...rt/+bug/130055

and it added a new menu item under scripts, which seems to work, but it also only puts out a file with 0kb!?
why is that?

itzig 01-14-2009 11:00 PM

doing the conversion with lame only, also puts out an emapty file, So here must be where the problem is.

Quote:

lame test.wav test.mp3
LAME 3.97 32bits (http://www.mp3dev.org/)
CPU features: MMX (ASM used), SSE, SSE2
Using polyphase lowpass filter, transition band: 8269 Hz - 8535 Hz
Encoding test.wav to test.mp3
Encoding as 22.05 kHz 32 kbps single-ch MPEG-2 Layer III (11x) qval=3
Only 8, 16, 24 and 32 bit input files supported

jschiwal 01-14-2009 11:06 PM

Here is the script that I use to convert oggs to mp3s. I first convert the ogg to a wave file and then use lame to convert the temporary wave file to an mp3.
Code:

#!/usr/bin/env  bash
# convert ogg file to wav file using mplayer

# ${1} is the ogg filename
oggfile="${1}"
echo "$oggfile"  # debug
mplayer -vo null -vc null -ao pcm:waveheader:file="${oggfile%.ogg}.wav" "${oggfile}"

# Extract the tag variables TITLE, YEAR, ARTIST, ALBUM
# define get_tags() function
. ~/bin/get_tags "${oggfile}"
get_tags ${oggfile}

if [ -d $DATE ]; then YEAR=$DATE; fi

# Convert .wav file to .mp3 file.  Set the tags as well.
lame "${oggfile%.ogg}.wav"      \
            --tt "${TITLE}"  \
            --ty "${DATE}"  \
            --ta "${ARTIST}" \
            --tl "${ALBUM}"  \
            --tg "${GENRE}"  \
            --tn "${TRACKNUMBER}" \
    "${oggfile%.ogg}.mp3"

# remove the temporary file
rm "${oggfile%.ogg}.wav"

Here is where the get_tags() function is defined:
Code:

cat bin/get_tags
get_tags()
{
    # clear out old tags
    ALBUM='';
    ARTIST='';
    DATE='';
    GENRE='';
    TITLE='';
    # the tags returned by ogginfo are of the form NAME=VALUE.
    # put single quotes around the values to encapsulate white space.
    # eval will set the tag variables ALBUM, ARTIST, DATE, GENRE, TITLE
    eval $(ogginfo ${1} | sed '/[A-Z][A-Z]*=/!d;s/=\(.*\)$/='"'"'\1'"'"'/;s/^\t//')
}


itzig 01-15-2009 11:02 AM

nice, thank you! How would I use this script just for wav to mp3 (high quality, 320kbs) conversion?

jschiwal 01-17-2009 03:13 AM

This is the part that performs wav to ogg conversion:
Code:

# Convert .wav file to .mp3 file.  Set the tags as well.
lame "${oggfile%.ogg}.wav"      \
            --tt "${TITLE}"  \
            --ty "${DATE}"  \
            --ta "${ARTIST}" \
            --tl "${ALBUM}"  \
            --tg "${GENRE}"  \
            --tn "${TRACKNUMBER}" \
    "${oggfile%.ogg}.mp3"

# remove the temporary file
rm "${oggfile%.ogg}.wav"

It is lame that does the work of conversion, so you can do it with just a lame command.
Look at the manpage of lame for more options such as setting the cbr bitrate or vbr bitrate ranges.
Code:

      CBR (constant bitrate, the default) options:

      -b n  For MPEG1 (sampling frequencies of 32, 44.1 and 48 kHz)
              n = 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320

              For MPEG2 (sampling frequencies of 16, 22.05 and 24 kHz)
              n = 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160

              Default is 128 for MPEG1 and 64 for MPEG2.

      --cbr  enforce use of constant bitrate


      ABR (average bitrate) options:

      --abr n
              Turns on encoding with a targeted average bitrate of n kbits, allowing to use frames of different sizes.  The allowed range of n is 8 -  310,  you  can  use  any
              integer value within that range.

              It  can be combined with the -b and -B switches like: lame --abr 123 -b 64 -B 192 a.wav a.mp3 which would limit the allowed frame sizes between 64 and 192 kbits.


itzig 01-17-2009 06:33 PM

great, thanks you! that's what I was looking for, I also found this:
http://www.experts-exchange.com/Digi..._23692279.html
for i in *.wav; do lame -h -b 192 "$i" "${i%.wav}.mp3"; done
but, I get errors using this line. Sorry Im not well versed in the command line!
I am in a folder with a bunch of .wav files and want to convert them, how do I need to change that line?

thanks in advance for any insight!

itzig 01-18-2009 12:17 PM

I guess my problem is that lame isn't really working from the command line, it always put out an empty file, even when trying to do a simple conversion such as:
Quote:

$ lame -b 128 test.wav test.mp3
LAME 3.97 32bits (http://www.mp3dev.org/)
CPU features: MMX (ASM used), SSE, SSE2
polyphase lowpass filter disabled
Encoding test.wav to test.mp3
Encoding as 22.05 kHz 128 kbps single-ch MPEG-2 Layer III (2.8x) qval=3
Only 8, 16, 24 and 32 bit input files supported
phi@Betelgeuse:~/Music/NEW$ lame -b 32 test.wav test.mp3
LAME 3.97 32bits (http://www.mp3dev.org/)
CPU features: MMX (ASM used), SSE, SSE2
Using polyphase lowpass filter, transition band: 8269 Hz - 8535 Hz
Encoding test.wav to test.mp3
Encoding as 22.05 kHz 32 kbps single-ch MPEG-2 Layer III (11x) qval=3
Only 8, 16, 24 and 32 bit input files supported
This is frustrating, I have no idea why it's doing that!

jschiwal 01-18-2009 03:00 PM

You might also try using sox to convert the audio.

One thing to check is that you have the needed libraries.

itzig 01-19-2009 12:16 PM

Ah! I have it, but I get:
'SoX was compiled without MP3 encoding support'
same thing probably happened on all the other command line encoders I got installed here.
For some reason ripping off CD's, encodes just fine, but not from my HD.

I guess I have to recompile and reinstall, what a PITA!

Thanks anyhow!~


All times are GMT -5. The time now is 12:12 AM.