Skip to content

Instantly share code, notes, and snippets.

@crischutu07
Last active July 28, 2023 11:39
Show Gist options
  • Save crischutu07/704a5e8b19ee3069c64969ea2120ae91 to your computer and use it in GitHub Desktop.
Save crischutu07/704a5e8b19ee3069c64969ea2120ae91 to your computer and use it in GitHub Desktop.
Spectrum with drawtext

Spectrum with drawtext

The bash script below is a code that make audio files or input audio video to be spectrum

#!/usr/bin/env bash
spectrum_mode="combined"
spectrum_slide="scroll"
x=0 # place x coord drawtext
y=0 # place y coord drawtext
file='input.m4a' # input files
text='OneShot - On Little Cat Feet' # drawtext input
echo "$file: $text"
echo "Threads: $(nproc)" # using N threads to encode
echo "executing commands..."
sleep 1
ffmpeg -i $file -filter_complex \
"[0:a]showspectrum=mode=$spectrum_mode:slide=$spectrum_slide:color=fire:scale=log:s=920x720,pad=920:720[ss]; \
[ss]drawtext=fontfile=Monospace.ttf:fontcolor=white:x=$x:y=$y:text='$text':fontsize=30[out]" \
-map "[out]" \
-map 0:a \
-c:v libx264 \
-preset veryfast \
-r 30 \
-c:a copy \
-thread $(nproc) \
output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment