What is the proper way to convert .flac files to 320 kBit/sec .mp3?

Solution 1:

First of all you must make sure that it's installed.

sudo apt-get install libav-tools

It should have lame and flac codecs, now is just create a bash script to finish the job:

$ cat > flac2mp3

Here the shell will wait for your commands, copy and paste this:

#!/bin/bash
[[ $# == 0 ]] && set -- *.flac
for f; do
  avconv -i "$f" -qscale:a 0 "${f[@]/%flac/mp3}"
done

Now press Ctrl + D. Make your script executable chmod +x flac2mp3. Now go you can use it like this:

./flac2mp3 /path/with/all/my/flacs/*.flac

You can also copy the script to somewhere in your PATH and then cd to the directory with the flacs and execute it.


With regards to the following parameter used above:

-qscale:a 0

will not actually give you a exact 320k file, although it is probably the best setting to use anyway. The suggested settings actually give a target bitrate of 245 kbits/s with a range of 220-260. If you really wanted 320k mp3s you would have to go to CBR and use:

-c:a libmp3lame -b:a 320k

but you would need great ears to notice the difference...

Reference:

  • https://wiki.archlinux.org/index.php/Convert_Flac_to_Mp3#With_FFmpeg

Solution 2:

For Single File i use this and its work perfect for me.

avconv -i [FileName.flac] -c:a libmp3lame -b:a 320k [FileName.mp3]

Solution 3:

I know this is a quite old thread, but I have had a similar task, so I created a little tool for converting FLAC to MP3. (Raspberry pi 3, with OSMC) Maybe someone will find this with the same search, that I did.

https://github.com/erdnuesse/flac-to-mp3

Features:

  • Multithreaded
  • preserves FLAC tags
  • preserve relative directory structure
  • does not delete, does not overwrite

It consists of 2 scripts, the first starts the given number of worker-instances (one for each core, or how many you want). While the second does the work.

It's based on avconv (my OSMC has 4 cores, but does not support ffmpeg out-of-the-box, so, meh, whatever.)

It's still running, so I hope, there will be no major setbacks.

Regards, Kay

Solution 4:

This script will convert all the files in the current directory to mp3 or just about any file extension you wish from just about any audio video filetype.

I've named the script mp423 because it's easy to remember and common filetypes although you can convert any type.

#!/bin/bash
for f in *."$1"; do
 mplayer "$f" -novideo -ao pcm:file=tmp.wav
 lame -V 0 -q 0 tmp.wav "${f/.$1/.$2}"
 rm -f tmp.wav
done

Here's a use example. Save the script to your home directory and don't forget to make it executable. There is no need to provide any filename or path. Just cd into the directory where the files are and then run the script like this:

~/mp423 flac mp3 

Another example converting all mp4 files in a directory to mp3:

~/mp423 mp4 mp3

Convert all mp4 to m4a:

~/mp423 mp4 m4a

This comes in handy when you have an entire directory full of files you need to convert.

If you only have one or two files you want to convert, just make a directory to run the files in.

Also, does not delete the original files.