Controlling your VLC with your IRC

A couple years ago me and a group of geographically disperate friends held our weekly ''Joffrey Hate Hour'': the day after Game of Thrones aired we'd all ahem track down a copy, and watch together with live IRC commentary. Like twitch, but for old people.

We learned quickly, getting 6 or 7 to stop and start local videos in unison is pretty challenging. I set off to build a solution in the form of an IRC bot. Each viewer would load the bot into the channel, and once everyone was ready, we could issue the start command all the IRC bots would recieve it at roughly the same time.

I started work on a VLC interface plugin that would accept commands via IRC, but didn't finish it before losing interest in Game of Thrones. Recently, I had the idea to do something similar: control a "radio station" in IRC. Users would be able to queue up songs for everyone in the channel to listen to. Like turntable.fm, but for old people. This could be done in the way I originally envisioned, everyone running their own VLC instance and pasting youtube links into IRC, however asking every user to compile and/or install my plugin is inconvenient (hey VLC people, looking for a contribution?). Fortunately, you can run a single VLC instance and expose an http stream for everyone.

With this in mind, I unearthed my old VLC plugin code, spruced up the build script, sorted out a couple of bugs and added some playlist commands that would be necessary for this new use-case. The http stream works basically as you'd expect, even when moving between tracks.

16:52 *** vlcboat JOIN
16:52 <wcummings> !status
16:52 <vlcboat> State: Stopped
16:55 <wcummings> !enqueue
16:55 <vlcboat> Enqueued
16:56 <wcummings> !play
16:56 <vlcboat> Playing



Unfortunately, the only way I've worked out to build this is by building all of VLC with it. This isn't ideal, and hopefully I'll have out-of-tree compilation or some way to distribute binaries worked out at some point.

vlc-irc-rc sources and build instructions.

Starting a http server

vlc -I ircrc --server chat.freenode.org --channel '#bottesting123123' --nick vlcboat --sout-keep --sout '#standard{access=http,mux=ogg,dst=:8080}' --novideo -vv


Since the player is "remote" to the users, youtube URLs seem like the easiest way to feed songs into the "radio". VLC includes a youtube plugin, but as you might expect, it is often out-of-date. youtube-dl is more likely to be up-to-date, since its the whole point of the project, and it includes a nice update mechanism (youtube-dl -U).

There's a partially broken VLC plugin for youtube-dl. Youtube-dl json output (-j flag) will include many formats (and many URLs), so I modified the plugin to use -f bestaudio and -g, to select a single format and spit out the URL. This grabs a URL, which is an improvement, but VLC cannot always play it.

local file = assert(io.popen('youtube-dl -f bestaudio --prefer-insecure -g '..url, 'r'))  --run youtube-dl in json mode
local output = trim1(file:read('*all'))
if output then
  return { { path = output; } }

The Future

TODO Make youtube URLs work more reliably

The solution here might be to have youtube-dl handle transcoding.

TODO Make youtube playlists work

There are some youtube playlist plugins out there, maybe investigate those? Otherwise whatever bespoke youtube-dl based solution I cook up will have to support playlists.