Can MCEBuddy process an audio stream and then process the output of that process again?

The reason I ask this is that some things need to be done in steps. Most of my audio in recorded movies is AC3 5.1 so I downsample that to stereo AAC and then have all the audio streams also copied as is with the following settings:

ffmpeg-audioac3=-map 0:1 -map 0:1 -map 0:2 -c:a:0 aac -ab 384k -ac 2 -c:a:1 copy -c:a:2 copy

The problem comes in that I also want to use dynamic range compression on the same AAC stereo track but you should not use such processes until the file has been downsampled to stereo first…thus my conundrum. I need to apply the following in ffmepeg:

-af dynaudnorm=f=150

to the stereo AAC audio track AFTER MCEBuddy has created it but do not know if MCEBuddy is capable of doing this and if it is I am not sure how.

Any insight would be greatly appreciated

Create 2 conversion tasks with different profiles and try daisy chaining the conversions as explained here where the output of one conversion feeds into the next one

So if I understand this one way to do what I want it so let my current setup run as is then put the output MKV files back into MCEBuddy and run them as MKV Unprocessed but have the first audio stream, which is now a 2 channel AAC, modified with the dynamic range compression?

Using monitored locations creates too many problems. For me it would be easier to just load the files back into MCEBuddy with the MKV Unprocessed profile tweaked to my needs to just alter audio and have the source files deleted when done. I run 40 or more conversions at a time and I don’t want monitored locations feeding the queue because no matter what you tell me all files are added to the beginning of the queue and I have never been able to stop this from happening.

I’m thinking there might be away to use the custom commands in a profile to do this. I’m not exactly sure how that would look yet or which order it would need to be but let me spend some time looking into this and get back to you.

Okay, here is what I came up with. DISCLAIMER: I could not test this and my ffmpeg knowledge is mediocre at best. But it might be a good starting point for others to chime in and help out.

Add this to the profile you want to normalize the stereo audio.

CustomCommandPath=C:\Windows\System32\cmd.exe
CustomCommandParameters="/c ren "%convertedfile%" %convertedfilename%-1.%convertedext% & "C:\Program Files\MCEBuddy2x\ffmpeg\ffmpeg.exe" -i "%workingpath%\%convertedfilename%-1.%convertedext% -map 0:v -c:v copy -map 0:1 -map 0:2 -map 0:3 -af dynaudnorm=f=150 -c:a:1 copy -c:a:2 copy "%convertedfile%" & del "%workingpath%\%convertedfilename%-1.%convertedext%""
CustomCommandHangPeriod=3600
CustomCommandCritical=false
CustomCommandUISession=false
CustomCommandShowWindow=false
CustomCommandExitCodeCheck=false

Basically how this should work is that after the files has been converted but before it moves it to the destination it will execute CMD with the parameters specified. Let’s break down the parameters:

/c

Run command prompt and exit when done. Don’t worry about this one

ren “%convertedfile%” %convertedfilename%-1.%convertedext%

This renames the converted file in it’s current location (since we are using CustomCommand this will be in the working directory) by adding a -1 to it. We want to rename it so that we can have our new file be what it needs to be after we finish these custom commands and MCEBuddy takes back over.

&

This means basically new command to run. Don’t worry about this. But if you want more commands to run then separate it with an &.

“C:\Program Files\MCEBuddy2x\ffmpeg\ffmpeg.exe” -i “%workingpath%%convertedfilename%-1.%convertedext% -map 0:v -c:v copy -map 0:1 -map 0:2 -map 0:3 -af dynaudnorm=f=150 -c:a:1 copy -c:a:2 copy “%convertedfile%””

The real magic is here and if any tweaks need to be done to the execution it will need to be in here. This should copy the video over as is, apply the normalization to the first audio track and copy the remaining 2 audio track over as is.

del “%workingpath%%convertedfilename%-1.%convertedext%”

Deletes the original file we renamed in the first command. Just some housekeeping.

1 Like

Thanks so much…I’m sorry it took me so long to see this and test it but I just did on a short 5 minute test sample I use for testing profiles and the custom commands ran. Now my only question is how can I verify that the dynamic range compression took place? Oh wait…I can extract the audio from both the source and the converted file and compare them in an audio editor.

EDIT…I will check it in an audio editor when I get time but just listening to the original and converted I can tell a difference in the sound effects not being so overpowering yet still a little louder so it seems this is what I was looking for…THANKS!

That’s great! Glad to help.

Now the only thing I need to figure out to make this perfect is if I can use ffprobe to analyze the audio file first, then let it pick the parameters for both dynamic range compression and then normalization (so all shows/movies have the same standard volume) so if you have any ideas any input would be appreciated.

let me play around with some things and get back to you.

I’ve been playing around with some different methods to do this but none are all that reliable. And due to a user error I wiped the profiles I was using to test so I can’t even provide you with examples. And somehow wiped out all my logs.

There are a couple different workflows I tried. Using precustomcommand to extract the audio separate as stereo, and using a batch file to process it for normalization using ffprobe passing the variables as arguments, run though normal MCEBuddy processing minus that stereo track and then in customcommand reinsert it. This worked about 10% of the time.

I also tried extracting the audio track in precustomcommand as is, process the video through MCEBuddy as stereo only with Volume leveling option enabled and then reinserting the surround tracks. This worked the most often but am not sure if it is giving you the normalization that you want.

Then I also just used no customcommands and processed with the Volume leveling option on which worked 100% of the time but again, not sure if it’s the result you want.

If I can find more free time I’ll play around some more but I’m starting a new job soon and likely won’t be able to for awhile.

Thank you so much for the effort. I’m hoping my friend will give me the method he uses in ffmpeg but he is being difficult as he wants me to use Sickbeard script instead but doesn’t have the time to teach me how to use it.

If I get the information from him then it should be must a matter of using a custom command modification to the one you already provided.

Thanks again.

I found a way to simplify this without having to do any analysis first. I found the following command and settings to use in ffmpeg and there seems to be a consensus that this is the setting to use:

-af loudnorm=I=-16:LRA=11:TP=-1.5

This will do the normalization. I assume that we have to do the dynamic range compression first and then apply this so basically is there a way to run the output of the custom command you created above for the dynamic range compression through another custom command applying this command? Unless there is a better way to do it, I know I have no idea.

I tried playing with it myself but I was unable to daisy chain the two commands together to get it to work properly. I get lost in the syntax. I’m no coder…LOL

Something like this likely.

CustomCommandParameters="/c ren “%convertedfile%” %convertedfilename%-1.%convertedext% & “C:\Program Files\MCEBuddy2x\ffmpeg\ffmpeg.exe” -i “%workingpath%%convertedfilename%-1.%convertedext% -map 0:v -c:v copy -map 0:1 -map 0:2 -map 0:3 -af dynaudnorm=f=150 -c:a:1 copy -c:a:2 copy “%workingpath%%convertedfilename%-2.%convertedext%” & del “%workingpath%%convertedfilename%-1.%convertedext%” & “C:\Program Files\MCEBuddy2x\ffmpeg\ffmpeg.exe” -i “%workingpath%%convertedfilename%-2.%convertedext%” -map 0:v -c:v copy -map 0:1 -map 0:2 -map 0:3 -af loudnorm=I=-16:LRA=11:TP=-1.5 -c:a:1 copy -c:a:2 copy “%convertedfile%” & del “%workingpath%%convertedfilename%-2.%convertedext%””

Awesome, thanks I know you’re busy. I will try that later today or tonight and let you know. Appreciate it.