Created
October 30, 2025 01:35
-
-
Save rasmusmerzin/a81031b7a0329ac3aa13eb697c31d4c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| [[ -z "$PORT" ]] && PORT=18181 | |
| [[ -z "$SAMPLING" ]] && SAMPLING=44100 | |
| help() { | |
| printf 'Usage: ffstream %s\n' 'receive' 'send <address>' | |
| } | |
| operator=$1 | |
| shift | |
| case "$operator" in | |
| send) | |
| address=$1 | |
| shift | |
| [[ $# -gt 0 ]] && echo "Unused arguments: $@" >&2 | |
| if [[ -z "$address" ]]; then | |
| echo "Destination address is required" >&2 | |
| exit 1 | |
| fi | |
| exec ffmpeg \ | |
| -f pulse \ | |
| -i remote.monitor \ | |
| -ac 2 \ | |
| -acodec pcm_u8 \ | |
| -ar "$SAMPLING" \ | |
| -f u8 \ | |
| "udp://$address:$PORT" | |
| ;; | |
| receive) | |
| [[ $# -gt 0 ]] && echo "Unused arguments: $@" >&2 | |
| exec ffplay \ | |
| -nodisp \ | |
| -acodec pcm_u8 \ | |
| -ar "$((SAMPLING * 2))" \ | |
| -analyzeduration 0 \ | |
| -probesize 32 \ | |
| -f u8 \ | |
| -fflags nobuffer \ | |
| -fflags discardcorrupt \ | |
| -framedrop \ | |
| -strict experimental \ | |
| -sync ext \ | |
| "udp://0.0.0.0:$PORT" #?listen=1 | |
| ;; | |
| *) | |
| help | |
| exit 1 | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment