ffmpeg combining both -af and -filter_complex filters (use left track to create mono only track *and* normalise audio)
I have lossless video captures of videotapes that I'm going to convert to FFV1 and FLAC. For a select few tapes, in the process, I also need to convert the audio to mono (only the left track exists as the original recording is mono, but the capture device always records in stereo) and I need to normalise the audio in a way that just adjusts the volume uniformly (nothing like compression or anything else that would distort the sound beyond what's absolutely necessary) as the camcorder is quite quiet and there was no way to adjust the capture devices audio levels.
So far I've determined that I need these two filters:
Remove right channel to create mono recording with only left track:
-filter_complex "[0:a]channelsplit=channel_layout=stereo:channels=FL[left]" -map "[left]"
Normalise audio:
-af loudnorm=I=-16:LRA=11:TP=-1.5
However, I'm unable to determine how to combine these two filters. I've tried:
ffmpeg -i "input.avi" -filter_complex "[0:a]channelsplit=channel_layout=stereo:channels=FL[left]" -map "[left]", loudnorm=I=-16:LRA=11:TP=-1.5" -c:v ffv1 -level 3 -slicecrc 1 -c:a flac -compression_level 12 "output.mkv"
which yields:
loudnorm=I=-16:LRA=11:TP=-1.5 -c:v ffv1 -level 3 -slicecrc 1 -c:a flac -compression_level 12 output.mkv: Invalid argument
How do I combine these two filters?
When chaining simple filters (single input an output), we can simply use comma (,
) between the chained filters.
The comma syntax, means that the output of the first filter is the input of the next filter: "[0:a]channelsplit=channel_layout=stereo:channels=FL,loudnorm=I=-16:LRA=11:TP=-1.5[left]"
We also have to map the video using -map 0:v
.
Full command line:
ffmpeg -i input.avi -filter_complex "[0:a]channelsplit=channel_layout=stereo:channels=FL,loudnorm=I=-16:LRA=11:TP=-1.5[left]" -map "[left]" -map 0:v -c:v ffv1 -coder 1 -context 1 -g 1 -slices 24 -slicecrc 1 -c:a flac -compression_level 12 output.mkv
Note: My answer refers the correctness of the syntax, and not the correctness of the audio filters and parameters (my knowledge of audio is quite limited).