1#!/bin/sh -e
2set -x
3
4python3 - "$HOME/t/gruvbox.ppm" <<'PY'
5import sys
6import subprocess
7
8colors = eval(
9 "[" + subprocess.check_output(["termgruv"], text=True) + "]"
10)
11
12with open(sys.argv[1], "wb") as f:
13 f.write(b"P6\n16 16\n255\n")
14 for color in colors:
15 f.write(bytes(color) * 16)
16PY
17
18F="${F:--vf scale=1024:768}"
19ffmpeg -y -i "$1" $F "$1.new.png"
20
21ffmpeg -y \
22 -i "$1.new.png" \
23 -i "$HOME/t/gruvbox.ppm" \
24 -filter_complex "[0:v][1:v]paletteuse=dither=sierra2_4a" \
25 "$2" && rm "$1.new.png"
26