Search code examples
ffmpeg

ffmpeg detect if stereo channels are actually mono


Can I detect (with ffmpeg or something similar) if the 2 channels, left and right, of a stereo file are actually the same and the file is therefore mono?

pseudo-code:

left_channel = read_left_channel_from(file)
right_channel = read_right_channel_from(file)
return left_channel.equals(right_channel)

Solution

  • Invert the phase of one channel, then downmix to mono and volumedetect if there’s anything:

    -filter_complex "stereotools=phasel=1[tmp];[tmp]pan=1c|c0=0.5*c0+0.5*c1,volumedetect"