#!/bin/bash

fps=50
fps=60
w=1280
h=720
c1=d0a7b5
c2=ffcc44

# these generate a blank video
cmd1="ffmpeg -hide_banner -v warning -f lavfi -i color=c=$c1:s=${w}x${h}:r=$fps -pix_fmt yuv420p"
cmd2="-f yuv4mpegpipe -frames:v 1 -"

x1=$((w/2))
y1=$((h/2))
bw=$((w/16))
bh=$((h/16))
x2=$(((w-bw)-x1))
y2=$(((h-bh)-y1))

$cmd1 -vf drawbox=x=$x1:y=$y1:w=$bw:h=$bh:color=$c2:t=fill $cmd2 > /dev/shm/f1.y4m
$cmd1 -vf drawbox=x=$x2:y=$y1:w=$bw:h=$bh:color=$c2:t=fill $cmd2 > /dev/shm/f2.y4m
$cmd1 -vf drawbox=x=$x2:y=$y2:w=$bw:h=$bh:color=$c2:t=fill $cmd2 > /dev/shm/f3.y4m
$cmd1 -vf drawbox=x=$x1:y=$y2:w=$bw:h=$bh:color=$c2:t=fill $cmd2 > /dev/shm/f4.y4m

(head -n 1 /dev/shm/f1.y4m;
  while true; do tail -qn +2 /dev/shm/f{,,,,,,,,}{1..4}.y4m; done) |
ffmpeg -hide_banner -v warning -i - -c yuv4 -f nut - |
mpv -fs --video-unscaled=yes -vo gpu -

stty echo
