#!/bin/sh

if [ "$1" = "-h" ] || [ "$#" -ne "1" ]; then
    >&2 echo "Usage: $0 <input.mp4> <output.gif>"
    exit 1
fi

mpv --ytdl-format='bestvideo[height<=?720]+bestaudio/best' "$1" 2>&1 | grep 'ERROR:' | tee /dev/fd/2 | xargs -n1 -d "\n" notify-send