0

I have my large FLAC library separated by folder, each album, and all FLAC perfecty tagged, etc I want to convert one or more albums to mp3, but from the gmusicbrowser itself. AFAIK there is no option for that, only a "execute custom command on selected files" plugin option. I think maybe there is a commnad to do that. If not, does someone knows how can I do it?

Thanks in advance.

1 Answers1

1

Maybe it is not exactly what you are asking for, but I use the following script for this task:

#!/bin/bash
#
# convert FLAC-files to MP3 
# (similar folder structure, max quality)
#

export path=<flacpath>
export out=<mp3path>

echo "" > doit.sh
find $path -name \*.flac | (

    while read i; do
    echo
    echo "$i"

    newfile=`echo $i | sed s,$path,, | sed s,.flac,.mp3, | sed s,\",,g`
    echo $out/$newfile
    targetdir=`dirname "$newfile"`
    echo $targetdir

    echo "mkdir -pv \"$out/$targetdir\"" >> doit.sh


    echo "ffmpeg -y -i \"$i\" -aq 2 \"$out/$newfile\""  >> doit.sh

    done

)

This is just sort of a template, change 'flacpath' and 'mp3path' as you need. The file 'doit.sh' which is generated may be edited and then executed as sh doit.sh

FLAC tags will be included in MP3 as far as they are supported.

I think there are much better solutions, but this works for me.

To give an example:

I have a record digitized to FLAC at

/data/music_out/FLAC/Jimi_Hendrix/Smash_Hits/...

and I want to convert this to

/tmp/out/MP3/Jimi_Hendrix/Smash_Hits/...

Assuming ffmpeg is installed (otherwise sudo install ffmpeg), I set

export path=/data/music_out/FLAC/Jimi_Hendrix/Smash_Hits
export out=/tmp/out/MP3/Jimi_Hendrix/Smash_Hits

in the above script. When run, the script creates another script file called doit.shwith the contents

mkdir -pv "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//"
ffmpeg -y -i "/data/music-out/FLAC/Jimi_Hendrix/Smash_Hits/01-Purple Haze.flac" -aq 2 "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//01-Purple Haze.mp3"
mkdir -pv "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//"
ffmpeg -y -i "/data/music-out/FLAC/Jimi_Hendrix/Smash_Hits/02-Fire.flac" -aq 2 "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//02-Fire.mp3"
mkdir -pv "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//"
ffmpeg -y -i "/data/music-out/FLAC/Jimi_Hendrix/Smash_Hits/03-The Wind Cries Mary.flac" -aq 2 "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//03-The Wind Cries Mary.mp3"
mkdir -pv "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//"
ffmpeg -y -i "/data/music-out/FLAC/Jimi_Hendrix/Smash_Hits/04-Can You See Me.flac" -aq 2 "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//04-Can You See Me.mp3"
mkdir -pv "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//"
ffmpeg -y -i "/data/music-out/FLAC/Jimi_Hendrix/Smash_Hits/05-51st Anniversary.flac" -aq 2 "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//05-51st Anniversary.mp3"
mkdir -pv "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//"
ffmpeg -y -i "/data/music-out/FLAC/Jimi_Hendrix/Smash_Hits/06-Hey Joe.flac" -aq 2 "/tmp/out/MP3/Jimi_Hendrix/Smash_Hits//06-Hey Joe.mp3"
...

just to clarify the idea. Calling sh doit.shthe action will be done.

If there are special charcters (even like ' ') in your path, you have to change some parts of the script. And yes, the mkdir -pv is redundant in this example. But it does not hurt, and the script is kept simple this way.

ridgy
  • 2,516