You are not logged in.

#1 2005-05-09 06:12:01

jbsnake
Member
Registered: 2004-04-26
Posts: 23

encode an mp3 from a flac file

i like flac...but mp3 seems to be the most commonly used format (ogg is a closing second)
all the songs on my system are in flac (thanks to the recomendation of a fellow archlinux user from #archlinux)
now to make an mp3 from those files
:: ahem ::

fSlash='/'

function notAForwardSlash
{
    if [[ $1 != $fSlash ]]
        then
        return 0
        else
            return 1
        fi
}
### end notAForwardSlash ###


function getFileName 
{
    STRING="${1}"
        LENGTH=${#STRING}
    # echo "${STRING}: is ${LENGTH} long"
    for ((n=0;n <= $LENGTH; n++))
        do
        CHAR=${STRING:$n:1}
        if notAForwardSlash $CHAR
        then
            FileName="${FileName}${CHAR}"
        else
            FileName=""
        fi
        # echo "${FileName}"
    done
}
### end getFileName ###


# call like
# encode_mp3 "/music/flac/Smile Empty Soul/Shadow Zone/Monster.flac" "/music/mp3/Smile Empty Soul/Shadow Zone"

function encode_mp3
{
    old_file="${1}"
    new_dir="${2}"
    getFileName "${old_file}"
    new_file="${FileName:0:${#FileName}-5}.mp3"
    
        # this is the important part of this script
        # the actual encoding 
        # the rest is just stuff to make it easier and less tedious
    flac -d -o - "${old_file}" | lame -b 320 -h - > "${new_dir}/${new_file}"
}

i wrote more about this here
you can see this inside my whole script here

hope this helps someone out there smile

Offline

#2 2005-05-12 16:48:27

JGC
Developer
Registered: 2003-12-03
Posts: 1,659

Re: encode an mp3 from a flac file

It's even more simple, install gst-plugins-flac and gst-plugins-lame and then use this:

gst-launch filesrc location=music.flac ! decodebin ! lame ! filesink location=music.mp3

Offline

#3 2006-03-01 17:49:39

Jefg60
Member
From: UK
Registered: 2006-01-07
Posts: 100

Re: encode an mp3 from a flac file

cool, this is coming in handy. I either have too much music or not enough space to store it as flac files! btw some of your links are dead. but I found it anyway with google. Thanks!

Offline

Board footer

Powered by FluxBB