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

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.

  • Thanks ridgy. I'm testing this script. The path for flac is /usr/bin/flac really? and /usr/bin/lame for mp3? Should I run this script from each directory? Can I run it as a command from any path and convert the mp3 to specific folder? (ie the Artist and album name? – rootsandculture Aug 10 '16 at 20:16
  • Sorry I did not explain completely. The path for FLAC is the directory where your .flac files reside (or the subdirectory you want to convert). And mp3path means where you want your .mp3 files directories be created. And you need to have ffmpeg installed (I do not know if it's default in your distribution). – ridgy Aug 10 '16 at 20:38
  • I still should manually add the path for conversion, I'm looking for a way to do it from gmusicbrowser interface, selecting which files I want to convert while I'm listening, just like foobar allows. I moved to ElementaryOS (Trusty based) and looking for a similar way to do it. Thanks for your help anyway. – rootsandculture Aug 10 '16 at 21:20
  • Maybe there is a way in nautilus to make right click in a specific folder and execute the script. But anyway all the mp3s will be converted to the specified folder in the script, no in separated ones really? – rootsandculture Aug 10 '16 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.