Skip to content

Instantly share code, notes, and snippets.

@keunwoochoi
Created July 18, 2019 23:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keunwoochoi/7162309499a50afcca9e0133bd63bb6a to your computer and use it in GitHub Desktop.
Save keunwoochoi/7162309499a50afcca9e0133bd63bb6a to your computer and use it in GitHub Desktop.
Generate a video with scrolling over the spectrogram of the input audio.
# This is a simplified script of https://gist.github.com/keunwoochoi/f0ea2c49355fc21e93dad88d210efcdd
# Usage: 1. Modify the font path in the line with [ss].
# In my case, I copied and pasted CircularSpAraTTBlack.ttf to the same folder.
# 2. Put the wav file in the same folder, say, audio_file.wav
# 3. run $./spectrogram_scrolling_video.sh audio_file.wav
# 4. You'll see audio_file.mkv in the same folder!
#
# Based on example here https://trac.ffmpeg.org/wiki/Encode/YouTube
text=$(basename $1 .wav)
ffmpeg -i $1 -filter_complex \
"[0:a]showspectrum=mode=combined:color=intensity:scale=log:s=1280x720,pad=1280:720[ss]; \
[ss]drawtext=fontfile=CircularSpAraTTBlack.ttf:fontcolor=white:x=10:y=10:text=$text[out]" \
-map "[out]" -map 0:a -c:v libx264 -preset fast -crf 18 -c:a copy $text.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment