Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to convert FLAC 5.1 to mp3 2.0 ? (Read 3862 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to convert FLAC 5.1 to mp3 2.0 ?

Hi,

I have an album which is FLAC 1.3.2, 24 bits / 48 KHz, 5.1 channels, individual tracks
I'd like it to convert it to mp3 320 Kbps, 16 bits / 48 KHz, stereo, individual tracks
How can I easily achieve this ?

I have foobar2000 1.4, but its built-in converter doesn't seem to work : "An error occurred while writing to file (The encoder has terminated prematurely with code 1 (0x00000001); please re-check parameters)"

Thank you.

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #1
Mp3 cannot handle multichannel which is probably the cause of the error.

You need to downmix from 5.1 to stereo before you can encode to mp3.

Go to "Converter Setup" then "Processing" and use "Downmix channels to stereo".

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #2
You can use foobar as indicated above by having it downmix to stereo; I prefer to use ffmpeg to generate a downmixed FLAC and then, if needed, lossily convert that.

I'm a bit pedantic about these procedures, so I implement ATSC's recommendations and guidelines when I do this. According to page 91 of this document, the following ffmpeg command can be used to downmix a 5.1 input FLAC file to a stereo output FLAC file:

Code: [Select]
ffmpeg -i input.flac -af "pan=stereo|FL < 1.0*FL + 0.707*FC + 0.707*BL|FR < 1.0*FR + 0.707*FC + 0.707*BR" output.flac

tl;dr -- if you're looking for a quick solution and the output of foobar sounds fine, use that. If not, try this ffmpeg command, and see how it sounds.
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #3
Your ffmpeg command line left surround channels out from the mix with the first file I tested. That can be solved by replacing BL and BR with SL and SR. But personally I prefer foobar's mixer as it won't result in such surprises and I find leaving LFE out is nonsensical.

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #4
Your ffmpeg command line left surround channels out from the mix with the first file I tested. That can be solved by replacing BL and BR with SL and SR. But personally I prefer foobar's mixer as it won't result in such surprises and I find leaving LFE out is nonsensical.

You may be right, I'll give this command a whirl later to see if I goofed.
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #5
I find leaving LFE out is nonsensical.
https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.775-3-201208-I!!PDF-E.pdf
Quote
The  LFE  channel  should  not,  however,  be  used  for  the  entire  low  frequency  content  of  the  multichannel  sound  presentation. The  LFE  channel  is  an  option,  at  the  receiver,  and  thus  should  only  carry  the  additional  enhancement  information.  The  LFE channel  is  often  not  included  in  a  2-channel  downmix.  The  main  channels  must contain  all  the  essential  programm elements  necessary for the audience.

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #6
Thanks Mark (and the other posters). I naively thought the downmix would be automatic when converting to mp3.
Your setting did the trick. Problem solved !

For the record, I am keeping the original hi-res files, which I play on my Hi-Fi system, so don't worry.
The downmixed mp3 files are for my GF, who will play them at her place on a ridiculously small Bluetooth speaker. So let's not worry too much about the quality here. ;)

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #7
The downmixed mp3 files are for my GF, who will play them at her place on a ridiculously small Bluetooth speaker. So let's not worry too much about the quality here. ;)

Yes, in that case foobar's downmixer will be more than good enough. The other answers focus more on a procedural method in line with industry standards. Either way, the more pedantic method, so to speak, is also there for anyone else to know about in case someone searches around in the future.
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #8
And I appreciate that, blurry_light. I am a quality freak too, believe me. ;)
BTW, feel free to check your ffmpeg command line later to refine it eventually, for future reference.
Thanks again everybody !

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #9
As for ffmpeg, for myself i use
Code: [Select]
-af pan=stereo|FL=0.707*FC+FL+0.707*BL+0.707*SL+0.5*BC|FR=0.707*FC+FR+0.707*BR+0.707*SR+0.5*BC
This is suitable for downmixing 5.1 (both variants - with rear channels or with side channels), standard variant of 7.1 and 6.1 to stereo.
https://ffmpeg.org/ffmpeg-filters.html#pan-1
Quote
If the ‘=’ in a channel specification is replaced by ‘<’, then the gains for that specification will be renormalized so that the total is 1, thus avoiding clipping noise.

 

Re: How to convert FLAC 5.1 to mp3 2.0 ?

Reply #10
If using ffmpeg, you can simplify to just putting  -ac 2    before the output, and it will use the ATSC / ITU  approved algorithm.

https://trac.ffmpeg.org/wiki/AudioChannelManipulation#a5.1stereo

So the final command can be as straighforward as:
ffmpeg -i /audio/5.1-input.flac -ac 2 -c:a libmp3lame -b:a 320k stereo.mp3