ffmpeg-normalize icon indicating copy to clipboard operation
ffmpeg-normalize copied to clipboard

Combining ffmpeg-normalize with ffmpeg pan filer

Open Corruptsmurf opened this issue 1 year ago • 6 comments

I am trying to merge ffmpeg-normalize and my typical surround-to-stereo downmixing script.

My normal script in ffmpeg would look like: ffmpeg -i UTS.mkv -map 0:a:0? -c:a:0 aac_at -aac_at_mode 3 -global_quality:a 14 -filter:a:0 "pan=stereo|FL=1.414*FC+0.707*FL+0.5*FLC+0.5*BL+0.5*SL+0.5*LFE|FR=1.414*FC+0.707*FR+0.5*FRC+0.5*BR+0.5*SR+0.5*LFE,acompressor=ratio=4" -o UTS_aac.mkv

These options take a custom pan of the surround sound channels to generate a dialogue-heavy stereo mix that preserves the LFE channel, then applies the acompressor filter. I thought it would be nice to run normalization on top of that (or at least test it out).

I tried the following syntax: ffmpeg-normalize UTS.mxv --keep-loudness-range-target -c:a aac -e="-aac_at_mode 3 -global_quality:a 14 -filter:a:0 "pan=stereo|FL=1.414*FC+0.707*FL+0.5*FLC+0.5*BL+0.5*SL+0.5*LFE|FR=1.414*FC+0.707*FR+0.5*FRC+0.5*BR+0.5*SR+0.5*LFE,acompressor=ratio=4"" -o UTS_normal.mkv

That resulted in this error:
'FL' is not recognized as an internal or external command, operable program or batch file.

I also tried:
ffmpeg-normalize UTS.mkv --keep-loudness-range-target -c:a aac -e '[ "-aac_at_mode", "3", "-global_quality:a", "14", "-filter:a:0", "pan=stereo|FL=1.414*FC+0.707*FL+0.5*FLC+0.5*BL+0.5*SL+0.5*LFE|FR=1.414*FC+0.707*FR+0.5*FRC+0.5*BR+0.5*SR+0.5*LFE,acompressor=ratio=4" ]' -o UTSnormal.mkv

Which resulted in a different error:
ffmpeg-normalize: error: argument -f/--force: ignored explicit argument 'ilter:a:0,'

My apologies if this is a dumb question; I just can't seem to figure out this syntax and would really appreciate some help.

Thanks.

Corruptsmurf avatar Feb 17 '24 21:02 Corruptsmurf

I also changed the ' ' marks to " " in the second syntax example and ran it again. That resulted in the first error again ('FL' is not recognized...)

Corruptsmurf avatar Feb 17 '24 21:02 Corruptsmurf

Not on a computer right now, so I can only guess, but you're going to want to use the "pre filter" or "post filter" options instead of the "extra" option. You cannot override the entire filter chain, since that is what ffmpeg-normalize will be using for its internal processing.

Regarding the pipe symbol, you may have to escape that with a backslash, since otherwise it may be interpreted as piping the output to another command.

slhck avatar Feb 17 '24 21:02 slhck

See here for some examples of pre filtering: https://github.com/slhck/ffmpeg-normalize/wiki/examples#filters

slhck avatar Feb 17 '24 21:02 slhck

For that, use the --extra-output-options option. The audio channel option in ffmpeg is not a filter, so it needs to be applied to the output file and cannot be used in the pre-filter list of filters.

slhck avatar Feb 25 '24 18:02 slhck

That should be the same. You can downmix in ffmpeg-normalize, too.

slhck avatar Feb 25 '24 20:02 slhck

I would recommend to downmix first just using ffmpeg, then use ffmpeg-normalize to perform normalization on the stereo file.

slhck avatar Feb 26 '24 09:02 slhck