Skip to content

Instantly share code, notes, and snippets.

@skorotkiewicz
Last active February 28, 2026 00:08
Show Gist options
  • Select an option

  • Save skorotkiewicz/1b7715cffb9756576ad7a4a3faee4491 to your computer and use it in GitHub Desktop.

Select an option

Save skorotkiewicz/1b7715cffb9756576ad7a4a3faee4491 to your computer and use it in GitHub Desktop.
video music with ffmpeg
#!/bin/bash
# Format text with word wrap (35 characters per line for vertical)
fold -w 35 -s original_credits.txt > credits.txt
# Get audio duration
DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 audio.wav)
# Create vertical video with scrolling credits
ffmpeg -f lavfi -i color=c=black:s=1080x1920:d=$DURATION \
-i audio.wav \
-vf "drawtext=fontfile=/usr/share/fonts/noto/NotoSans-Regular.ttf:\
fontsize=36:\
fontcolor=white:\
x=(w-tw)/2:\
y=h-((h+th)*(t/$DURATION)):\
textfile=credits.txt:\
line_spacing=10" \
-c:v libx264 -c:a aac -pix_fmt yuv420p -shortest output.mp4
#!/bin/bash
# Format text with word wrap (60 characters per line)
fold -w 60 -s original_credits.txt > credits.txt
# Get audio duration
DURATION=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 audio.wav)
# Create video with scrolling credits
ffmpeg -f lavfi -i color=c=black:s=1920x1080:d=$DURATION \
-i audio.wav \
-vf "drawtext=fontfile=/usr/share/fonts/noto/NotoSans-Regular.ttf:\
fontsize=36:\
fontcolor=white:\
x=(w-tw)/2:\
y=h-((h+th)*(t/$DURATION)):\
textfile=credits.txt:\
line_spacing=10" \
-c:v libx264 -c:a aac -pix_fmt yuv420p -shortest output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment