Skip to content

Instantly share code, notes, and snippets.

@MaZderMind
Created December 24, 2017 23:23
Show Gist options
  • Save MaZderMind/261257c3c6670dcb1bbc2d39c0559b87 to your computer and use it in GitHub Desktop.
Save MaZderMind/261257c3c6670dcb1bbc2d39c0559b87 to your computer and use it in GitHub Desktop.
Generate a 4-track-stereo-testfile which helps to distinctively check audio channel mapping.
#!/bin/sh
# Generate a 4-track-stereo-testfile which helps to distinctively check audio channel mapping.
# Each stereo-pair contains the same phase-correct frequency on each ear
# (increasing frequency from lower to higher pairs), with brown noise overlayed
# on the right ear.
#
# When channels are swapped, the frequency on the left and on the right ear
# don't match which can be easily detected.
#
# When L/R is swapped, the noise will be on the wrong ear.
#
# When a complete stereo-pair is swapped, the frequencies won't be increasing
# but jump up and down between adjacient channels.
#
# Pre-Generated testfiles might be found on https://c3voc.mazdermind.de/testfiles/multichannel-audio-testfiles/
ffmpeg -y \
-f lavfi -i "anoisesrc=color=brown:duration=3600:amplitude=0.1" \
-f lavfi -i "sine=frequency=330:duration=3600" \
-f lavfi -i "sine=frequency=440:duration=3600" \
-f lavfi -i "sine=frequency=550:duration=3600" \
-f lavfi -i "sine=frequency=660:duration=3600" \
-filter_complex '
[0:a] asplit=4 [n1][n2][n3][n4];
[1:a] asplit=2 [al][ax];
[ax][n1] amix=inputs=2, aformat=channel_layouts=mono [ar];
[al][ar] amerge=inputs=2 [a];
[2:a] asplit=2 [bl][bx];
[bx][n2] amix=inputs=2, aformat=channel_layouts=mono [br];
[bl][br] amerge=inputs=2 [b];
[3:a] asplit=2 [cl][cx];
[cx][n3] amix=inputs=2, aformat=channel_layouts=mono [cr];
[cl][cr] amerge=inputs=2 [c];
[4:a] asplit=2 [dl][dx];
[dx][n4] amix=inputs=2, aformat=channel_layouts=mono [dr];
[dl][dr] amerge=inputs=2 [d]
' -c:a aac -ar 48000 -ac 2 -map '[a]' -map '[b]' -map '[c]' -map '[d]' multi-channel-testfile-48000.m4a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment