#!/bin/bash

set -euo pipefail
IFS=$'\n\t'

ffmpeg \
        -y \
        -hide_banner \
        -nostdin \
        -re \
        -loglevel warning \
        -timeout 5 \
        -i ${url} \
        -filter_complex "[0:v] scale=w=640:h=360, fps=25 [scaled];
            [0:a] ebur128=video=1:target=-16:gauge=shortterm:scale=relative:size=640x480[ebur][a1];
            [ebur] fps=25 [v1];
            [v1][scaled] vstack=inputs=2 [out];
            [a1] anullsink" \
        -map "[out]" \
            -c:v libx264 \
            -pix_fmt yuv420p \
            -q:v 2 \
            -keyint_min 0 \
        -an \
        -f rtp rtp://127.0.0.1:${port}