Best way to handle a folder with multiple audio formats

Ok, so i have a folder full of mkv that i’d like to run through. I’m trying to figure out how to properly handle audio.

My files are a mix of stereo and surround, there is even some mono. My goal is to basically setup a task that will take everything 2 channel and below and use one set of audio settings, while using a different setting for anything above 2 channels. This functionality is already built in to mcebuddy for AC3, but it’s only for AC3 meaning that it ignores DTS etc.

I was thinking of just passing through some formats like AAC, since that’s most likely to be the 2 channel source, but i also happen to have 2 channel eac3, ac3, flac etc. So strictly guessing if the audio is 2 channel based on the encoder will not work. Passing through the 6 channel audio will work just fine for me if the source is ac3 or eac3, but i would not want to pass through DTS. The goal is to shrink the file, and DTS is just a bit too heavy for it.

I remember running across a thread where someone had a cli command that would pass through audio depending on the audio bitrate. Logic of this was that if the audio bitrate is below 200 or so chances are it’s 2 channel and below. Above, chances are it’s 6 etc. Sadly, i didn’t bookmark the thread, and can’t find it for the life of me.

So, i’m looking for help and suggestions. How would you handle a folder like this ?

Here’s an alternative idea using profiles. MCEBuddy profiles has a feature called unsupported combinations. Basically for a profile encoder you can specify unsupported combinations of video, audio and container parameters. If it encounters this combination that encoder is skipped and it moves onto the next one. More details here:

Using this parameter you can approach this in two different ways

  1. Use the first encoder to not handle certain combinations (e.g. handbrake doesn’t handle DTS streams and copies the audio tracks) and then another one to handle the rest (ffmpeg encodes all audio tracks into ac3). An example of this would look like this (just the relevant part of the profile, you need to fill in the rest):

    handbrake-audio=-E copy
    handbrake-audioac3=-E copy
    ffmpeg-audio=-acodec ac3 -ab 384k
    ffmpeg-audioac3=-acodec ac3 -ab 384k

  2. The second approach is using profiles with conversion tasks, you create 2 profiles, specify just one encoder in each profile and for one profile you specify dts as unsupported and for the other one you specify aac,ac3 as unsupported. Create two conversion tasks, each using one of the two profiles created above. Now only the task with the profile which doesn’t support the audio codec will fail and the other one will run

The “fall through” approach was the first thing i looked at right after i posted. It’s interesting, and kind of neat in that it allows you to isolate your settings per format. Unfortunately that’s not really what i need.

My problem is that the same codec/format comes in multiple flavors of channels. With Atmos or DTS it’s pretty much a given that the sound is not going to be 2.0, but with EAC3 or AC3 or even AAC or Flac it could be either a 2.0 or 5.1. So i can fall through the profile order until i hit one for let’s say AAC, but then i have no way of telling if it’s AAC 2.0 or 5.1 etc. Basically, isolating a codec is not really what i need. I need to figure out if the stream is 2.0 or surround, and have mcebuddy auto adjust the settings accordingly.

Mcebuddy does have a built in mechanism for figuring the whole 2.0 vs 5.1 thing, but it only works with AC3. For example, i took the same profile you posted above and changed the ffmpeg-audio to 192, since it’s more suitable then 384 for stereo sound.

handbrake-audio=-E copy
handbrake-audioac3=-E copy
ffmpeg-audio=-acodec ac3 -ab 192k
ffmpeg-audioac3=-acodec ac3 -ab 384k

If i use these settings and feed it an EAC3 5.1 file, it will produce a file with 192k audio. If the output format was set to AAC it would produce 256k audio etc.

Same thing goes for AAC 2.0 vs 5.1 etc. AC3 will work as expected though, since the logic for it, and only for it, is already built in and will produce a 192 2.0 or 384 5.1. Basically, with anything other then AC3 the ffmpeg-audioac3 line/command is completely ignored and has zero effect on the conversion, only ffmpeg-audio line is used by mcebuddy. If you have checked the surround sound box in the gui, mcebuddy will pass a -6ch flag to the ffmpeg-audio line and treat those as your surround settings.
In my example i used 192k for the 2.0 output, and 384 for the 5.1 output. Since AAC is not AC3, mcebuddy will ignore the ffmpeg-audioac3=-acodec ac3 -ab 384k, and will use the ffmpeg-audio=-acodec ac3 -ab 192k settings. If i checked that i want surround in the gui it will pass the -6ch flag and i’ll end up with something like ffmpeg-audio=-acodec ac3 -ab 192k -6ch. If my output is also AAC some kind of an internal failsafe kicks in once the conversion starts that doesn’t allow a 5.1 mix on 192k. It will automatically increase the bitrate to 256 (the minimum for AAC 5.1). So in the end i will end up with a 256k 5.1 file. Not sure if it does the same for other formats.

Ideally, it would be great if the ffmpeg-audioac3 would work as a catch-all setting for all surround not just AC3, while ffmpeg-audio would then handle all the 2.0 mix. But that feature is just not there. Finding a workaround has proven challenging so far.

you could always open a feature request to handle <encoder>-audiodts or similar tags for non ac3 audio.

If -audiodts would work on the same principle as the -audioac3, then it should work, but then i would need one for every format - -audioflac, -audioaac etc, etc, etc.

I think an easier solution would be something along the lines of
ffmpeg-audio <=2ch - 192kb settings
ffmpeg-audio >2ch - 448kb settings

In other words, the check should be by the number of audio channels, not the codec. This way it would be completely irrelevant what the input codec is. Feed it Flac or AAC that has 2 channels, and it will spit out 192k. Give it the same Flac or AAC file that has more then 2 channels, and it will spit out 448kb etc.

As of right now, my go to output codec is EAC3 at 448. It works great for 6 channel, but since mcebuddy doesn’t care if the input has 2 or 6 channel audio it leaves me with 448k stereo audio on files that only have 2.0. 448 for stereo is a waste, and what i’m trying to avoid.

I also realize that this feature is outside the scope of this program. It’s meant to rip commercials and shrink files from a dvr. No dvr, as far as i know, records in eac3 or flac or aac etc, so i would be asking the dev to code/add something that has nothing to do with the main functionality of the program. I feel bad doing this, and wish i can find my own workaround.

1 Like

No need to feel bad, create a feature request and explain the need and suggestions and open it up to a discussion so we can implement the optimal way forward.


Let’s see what happens :slight_smile: