ffmpeg – Check difference between channels in stereo audio and extract one of them
I have a recording device that produces “almost mono” files – where the left and right audio track differ by negligible amounts.
This answer tells me how to extract the left channel.
ffmpeg -i in.flac -af 'pan=mono|c0=c0' out.flac
This answer shows how much the channels differ:
ffmpeg -i in.flac -filter_complex "stereotools=phasel=1[tmp];[tmp]pan=1c|c0=0.5*c0+0.5*c1,volumedetect" -f null /dev/null
Example output:
[Parsed_volumedetect_2 @ 0x7fc11920d500] n_samples: 125219672
[Parsed_volumedetect_2 @ 0x7fc11920d500] mean_volume: -91.0 dB
[Parsed_volumedetect_2 @ 0x7fc11920d500] max_volume: -50.8 dB
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_50db: 1
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_51db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_52db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_53db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_54db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_55db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_56db: 1
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_57db: 0
...
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_89db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_90db: 0
[Parsed_volumedetect_2 @ 0x7fc11920d500] histogram_91db: 125219661
(A bit wordy, but it shows well enough that the max difference is pretty quiet and almost all samples are identical.)
I’m not comfortable with changing the filter commands at all. Is there a way to convert to mono and check the “mono-ness” without reading the file twice?
Read more here: Source link