VLC has always been a great piece of software, but one place where is really shines is on iOS/tvOS since it allows you to play pretty much any video file, and you can send that file over curl.

While this probably also works for iOS, this example will focus on the use case of downloading a YouTube video, stripping it of sponsored content and passing it on to VLC on an Apple TV. It’s not that difficult, but you do need yt-dlp, ffmpeg and curl:

#!/bin/bash
/usr/bin/yt-dlp $1 -o output.mkv \
--sponsorblock-remove all \
--force-overwrites \
--merge-output-format mkv \
--embed-subs \
&& /usr/bin/curl -i \
-X POST 'http://appletv.local/upload.json' \
--form file='@output.mkv'

This will:

  • Run yt-dlp to download the video at the url passed as the argument to the script ($1)

    • Remove any sponsored content
    • Overwrite the output.mkv file if it already exists
    • Change the container to mkv
    • Embed any subtitles found
  • Send a POST request to VLC using --form to send the binary contents of the file as file.

    Having this script executable as tovlc in /usr/bin for example will allow you to then run things like:

    $ tovlc https://www.youtube.com/watch?v=foeov6Ahi4Y
    

    Note: I tried having yt-dlp passing the output to stdout with -o - followed by a pipe to curl with --form file='@-', while this should work in theory I couldn’t get it to work, so the above will require enough disk space to store the file before sending it to VLC.

    Additional reading