Skip to content

Instantly share code, notes, and snippets.

@zanculmarktum
Created March 18, 2023 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanculmarktum/59aab7a3916b654d5a8338fdb0fc5c50 to your computer and use it in GitHub Desktop.
Save zanculmarktum/59aab7a3916b654d5a8338fdb0fc5c50 to your computer and use it in GitHub Desktop.
Dynamic WebM resolution
#!/usr/bin/env bash
tmpfile=$(mktemp)
clean_up() {
rm -f "$tmpfile"
}
trap "clean_up" EXIT
trap "clean_up; exit 1" INT TERM
input=apu.jpg
curl -LR -o $input https://0x0.st/H-fV.jpg
width=$(identify -format '%w' $input)
rm -f apu???.webm
j=0
for i in $(seq 10 1 $width); do
j=$(($j + 1))
h=$(printf '%03d' $j)
convert $input -resize ${i}x${i} apu${h}.webm
done
>$tmpfile
for i in $(seq 1 $j); do
echo "file $(pwd)/apu$(printf '%03d' $i).webm" >>$tmpfile
done
for i in $(seq $j -1 1); do
echo "file $(pwd)/apu$(printf '%03d' $i).webm" >>$tmpfile
done
ffmpeg -hide_banner -f concat -safe 0 -i $tmpfile -c copy -y foo.webm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment