Created
May 10, 2025 00:52
-
-
Save cefqrn/e7682329884369b9de82bb760c1469d4 to your computer and use it in GitHub Desktop.
expanding webm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/bash | |
dir="$(mktemp -d -t piston)" | |
cleanup() { | |
rm -rf "$dir" | |
} | |
trap cleanup EXIT | |
times=() | |
i=0 | |
add() { | |
t=$1 | |
shift 1 | |
times[i]=$t | |
ffmpeg -loglevel error "$@" -c:v libvpx-vp9 -t "$t" "$dir/$((i++)).webm" | |
} | |
addn() { | |
# initial frame is 160x160 | |
add "$1" -i "frames/$2.png" -vf "pad=iw+40*$2:ih:color=#00000000" | |
} | |
addn 0.9 0 | |
for j in {0..4}; do | |
addn 0.02 "$j" | |
done | |
addn 0.9 4 | |
for j in {4..0}; do | |
addn 0.02 "$j" | |
done | |
addn 1 0 | |
# create a list of files for the next step | |
for ((j=0; j < i; ++j)); do | |
echo "file '$dir/$j.webm'" >> "$dir/paths.txt" | |
echo duration "${times[j]}" >> "$dir/paths.txt" | |
done | |
# make audio | |
ffmpeg -loglevel error -i piston_in.ogg -i piston_out.ogg -lavfi "[0]adelay=900[a];[1]adelay=1900[b];[a][b]amix=2:normalize=0" -y "$dir/audio_out.ogg" | |
# merge everything | |
ffmpeg -loglevel error -f concat -safe 0 -i "$dir/paths.txt" -i "$dir/audio_out.ogg" -c copy -y SPOILER_piston.webm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment