Youtube livestream help

Hello everyone!

I didn’t think this would be possible at all, but it works, for a few seconds…

I would like to play a youtube livestream within processing. I’ve installed the vlcjvideo library, as well as VideoLAN. The “basic” example, works great, but it is not a youtube video. If I enter a youtube video it will play (at low quality) for a few seconds, but then turn into a series of strange horizontal bars. It looks like it’s starting out in low res, but then switching to hires after about five seconds, and maybe processing can’t handle that. This behavior is present when playing within VLCPlayer as well, but that program handles it without a problem. You used to be able to edit the URL to force a resolution from the start, but that doesn’t seem to work anymore. Can anybody get this to work? Thank you very much!

//A basic example

import VLCJVideo.*;

VLCJVideo video;

void setup() {
  size(640, 360);
  video = new VLCJVideo(this);
  video.openAndPlay("https://www.youtube.com/watch?v=DHUnz4dyb54");
}

void draw() {
  background(0);
  image(video, 0, 0, width, height);
}

So, I have not managed to get this to work through processing code alone, but, I did come up with a workaround that works.

The problem certainly is that the youtube feed always starts out at one resolution, and then switches to a higher one (depending on connection speed I think). This resolution change freaks out processing, which I don’t understand because I would think that defining the width and height would preempt any issues, but that not enough apparently.

So, my workaround is to install GStreamer and run OBS in virtual webcam mode. Then I “connect” to that virtual webcam and it plays without issue.

2 Likes

Cool beans!

Answers my question:

Can you provide details on hardware and software versions?

:)