Open source and free software is so amazing! And you learn new tricks every day. Today I learned how to make my music collection even more awesome to listen to on my home hifi setup. The setup is nothing really spectacular, mainly consisting of an older Yamaha RX-V661 amplifier, a matching Yamaha active subwoofer, two good hifi front speakers, a pretty decent Magnat center speaker and two small Magnat rear speakers. I use this setup mostly for watching TV, really nice, Dolby Digital stuff really sounds amazing and with the active subwoofer you get a little bit of this cinema rumble when the deep basses roll through, I love that!
For some time now I noticed that music in the movies we watch always sounds so much better than when I playback some stuff from my music collection. Of course one difference here is that my music collection is only plain stereo whereas movies come with that 5.1 Dolby Digital audio track – 5.1 means 2 front channels, 1 center channel, 2 rear channels and .1 is the subwoofer channel, the so called LFE „low frequency“ channel. But I would like all my music to sound like this! The amplifier also has a 7-channel stereo mode where it upmixes a stereo input but it still does not sound how it could.
Also in my hardware setup is a Raspberry PI connected via HDMI to the amplifier. Via HDMI and raw digital passthrough using „omxplayer“ I can playback digital full surround 5.1 audio using AC3, aka Dolby Digital. I found some AC3 sample files on the internet and yes, right, that sounds like I want it! But for some reason it seems that music up to today is not recorded in 5.1 or any other surround format. You can only find very very few real surround recordings, many things are so called upmixes of the stereo version.
Then today I sat down to figure out how this upmixing works and if I could do this on my own using free software. And it turns out, it is by far less complicated than I anticipated! Actually, it is pretty simple! The only tool you need is the swiss army knife of free software media conversion, ffmpeg. With ffmpeg you can then take any stereo input file and map the channels plus doing some operations on them and voilà – you have a proper 5.1 AC3 stream! And wow, does this sound differently!
Here is the commandline I figured out that worked well for me today:
ffmpeg -i input.mp3 -ar 48000 -filter_complex "[0:a]pan=5.1(side)|FL=FL|FR=FR|FC=0.2*FR+0.2*FL|LFE<FL+FR|SL=FL|SR=FR[a]" -map 0 -map -0:a -map "[a]" -c:a ac3 -b:a 320k output.ac3
So what this does is:
- decode the input stream (here an .mp3 file)
- resample to 48kHz
- assign channels using the amazing pan filter:
- front left = stereo left
- front right = stereo right
- center = mix of stereo left and right, muted down by .2
- LFE = mix of stereo front + right and clamped to 1.0 (using ‚<‚, to avoid clipping)
- rear left = stereo left
- rear right = stereo right
- codec is AC3
- bitrate for the output is 320kbit/s, I found it sounds pretty much the same as the default 448k but 256k started to show minor glitches and distortions
So that’s it, beautiful home made 5.1 surround upmix of stereo music!
I am not yet super happy with the center and rear channels. I would like the center to be the mono component of left+right only, so not FL+FR but rather FL-FR + FR-FL, I think… and the rear could probably be with a little delay or so. But that’s for later, I am already super happy with this upmix – and the LFE being active makes such a huge difference!
PS: If you have more tips for enhanced stereo -> 5.1 upmixing please send me an email or comment!
Update: The LFE channel is a bit too prominent. But weirdly the LFE channel still outputs something even if I set it to 0…
Thank you (or Danke I should say, but sorry I don’t speak German). I’m building a Dolby Atmos 7.1.4 home theater/game room, and am figuring how to make my audio play in 5.1 even if not a real, professional mix. Your command works well for duplicating the Left and Right channels to the Surround channels, Center channel, and LFE channel. I’m currently playing the output back through two speakers only on my PC, but using PC software I can see signal being sent to all 6 channels.
Stating the obvious: Removing the LFE parameter from the command entirely results in no signal to the LFE. Making it the same 0.2* used for the Center channel reduces its output level to that of the Center channel.
I’ve just started to play around with this. I’ll see how it really sounds when my home theater is up and running. Using multiple speakers will definitely be better than 2.0, even if there’s no real surround sound. It might be possible to output in 7.1 using the „-ac“ parameter and specifying 8 channels – not sure. My home processor will be either 11.1 (or maybe 11.2 if I choose to go with dual subwoofers, haven’t purchased it yet).
I’ve bookmarked your page, and will follow up if I figure out anything special.
Hello again, Audacity is open-source software and better isolates the FL, C, FR, and LFE channels (still toying with the SL and SR, trying to find the right mix). For FL and FR you can apply a filter to ‚remove center‘. For C you can apply a filter to ‚isolate center‘. And for LFE, you can apply a Low-Pass filter with an upper boundary of 120hz.
I’ve created only two files so far. More specifically, I started with the Pink Floyd Dark Side Of The Moon side 1 and side 2 video files – extracted the 2.0 audio – upmixed it to 5.1 – created new mp4 files consisting of the original video and the new 5.1 audio – and burned them to DVD.
I’m not 100% happy with the mix, but am learning.
Is there any update to this script to improve LTE level – Bass support