`showcqt’ with basefreq, and endfreq (crop between A0 and C8)¶
Watch on youtube.com#! /bin/sh
ifn="Air on the G String (from Orchestral Suite no. 3, BWV 1068).mp3"
ifnb="`basename \"${ifn}\" .mp3`"
pref="`basename $0 .sh`"
# cqt -> E0 - D#10
# "myaxis.png": 1920x120 (A0 - C8)
#
# basefreq=27.500
# endfreq=4186.009
# axisfile=myaxis.png
ffmpeg -y -i "${ifn}" -i "myaxis.png" \
-filter_complex "
[0:a]showcqt=s=1920x1080
,crop=1392:1080:88:0,scale=1920:540,setsar=1[b];
[0:a]showcqt=s=1920x1080:basefreq=27.500:endfreq=4186.009
,scale=1920:540,setsar=1,split[t0][t1];
[1:v]loop=loop=-1:size=2,pad=1920:540:0:(oh-ih)/2[ax];
[t0][ax]blend=all_mode=average[t2];
[t2][t1]blend=all_mode=average[t];
[t][b]vstack[v]
" -map '[v]' -map '0:a' -c:a copy \
-shortest "${pref}_${ifnb}.mp4"
If you give “basefreq”, and “endfreq” to showcqt, showcqt wouldn’t render the axis (in most cases). Actually, you can use ‘axisfile’ option, but I’m trying it with “blend” manually.
“myaxis.png” was made by mk_piano_image.py.