Skip to content

Instantly share code, notes, and snippets.

@beveradb
Created August 4, 2025 06:00
Show Gist options
  • Select an option

  • Save beveradb/e9cd02fb06997b1aabb60c8741bcc67b to your computer and use it in GitHub Desktop.

Select an option

Save beveradb/e9cd02fb06997b1aabb60c8741bcc67b to your computer and use it in GitHub Desktop.
Play and stop youtube video on remote computer hooked up to screen
# Downloads and plays a video using VLC with optimized hardware acceleration
nomadplay() {
# 1. Check if a URL was provided
if [[ -z "$1" ]]; then
echo "Usage: nomadplay <youtube_url>"
return 1
fi
# 2. Send the command block to the remote PC
echo "๐Ÿš€ Sending command to karaoke PC (using VLC with HW Accel)..."
ssh nomadlocal bash << EOF
export DISPLAY=:0
exec &> ~/nomadplay.log
echo '---'
echo "Command received at: \$(date)"
echo "URL: $1"
echo 'Stopping any previous video...'
killall vlc
sleep 0.5
echo 'Downloading video with best audio...'
yt-dlp -f 'bestvideo[height<=720]+bestaudio/best' --force-overwrites --merge-output-format mkv -o '/tmp/karaoke_video.mkv' "$1"
echo 'Starting playback with VLC...'
# --avcodec-hw vaapi: Explicitly tells VLC to use the correct hardware acceleration method
nohup cvlc --fullscreen --play-and-exit --avcodec-hw vaapi /tmp/karaoke_video.mkv &
echo 'Launch command sent. Script finished.'
EOF
# 3. Wait and retrieve the remote log for confirmation
sleep 1
echo
echo "--- ๐Ÿ“ Remote Log from nomad-karaoke ---"
ssh nomadlocal "tail -n 10 ~/nomadplay.log"
echo "-----------------------------------------"
}
# Updated stop function
nomadstop() {
ssh nomadlocal "killall vlc"
echo "Playback stop command sent to karaoke PC."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment