Last active
October 17, 2021 13:26
-
-
Save mikeslattery/073d1653446c37172a0d36c0acf28f8d to your computer and use it in GitHub Desktop.
An attempt at an airplay client
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
#!/bin/bash | |
# Screen cast your desktop to Apple TV (airplay). | |
# Usage: airplay-client <server-address> <local-address> | |
# Untested. Likely doesn't work. Airplay V1 only. | |
if [[ "$SERVER_PORT" == "7000" ]]; then | |
# We are the cgi script. | |
echo 'Content-Type: video/h264' | |
echo '' | |
# TODO: figure out the correct video size | |
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 /dev/stdout | |
else | |
server="$1" | |
client="$2" | |
# launch our streaming server | |
mkdir -p cgi-bin | |
ln -sfn "$PWD/$0" cgi-bin/airplay | |
python -m http.server --cgi --bind 0.0.0.0 7000 & | |
trap EXIT ERR INT TERM "kill $!" | |
# Tell the TV to pull down our video | |
body="Content-Location: http://$client:7000/cgi-bin/airplay | |
Start-Position: 0" | |
curl "http://$server:7000/play" \ | |
-v \ | |
-H 'User-Agent: iTunes/10.6 (Macintosh; Intel Mac OS X 10.7.3) AppleWebKit/535.18.5' \ | |
-H "Content-Length: $(wc -c "$body")" \ | |
-h 'Content-Type: text/parameters' \ | |
--data-raw "$body" | |
wait | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
References