Importing Live Internet Video in Processing

Hello @rojele ,

I am sharing my brief exploration into this:

import processing.video.*;

Movie syn;

void setup() {
  size(640,480);
  String[] pageHTML = loadStrings("http://www.skylinewebcams.com/en/webcam/ellada/atiki/athina/ermou-street-syntagma-square.html");
  //printArray(pageHTML);
  
  // "VideoObject","contentUrl":"https://cdn.skylinewebcams.com/video/552.mp4","description" // Looked interesting
  
  String camURLpattern = "(.m3u8)(.*?)(')";
  String[] m = match(join(pageHTML, ""), camURLpattern);
  printArray(m);
 
  //String camURL = "https://hd-auth.skylinewebcams.com/live.m3u8?a=q4rs4qnstdd81cu80oht4l7o43"; //Example and probably expired
  String camURL = "https://hd-auth.skylinewebcams.com/live.m3u8" + m[2]; //https://hd-auth.skylinewebcams.com/live // Found in Chrome > Inspect > Network

  println(camURL);
  
  // I was curious:
  pageHTML = loadStrings(camURL);
  printArray(pageHTML);
  
  //camURL = pageHTML[5];
  
  syn = new Movie(this, camURL);
  syn.play();
}

void draw() 
  {
  if (syn.available()) 
    {
    syn.read();
    }
  image(syn, 0, 0, width, height);
  }

It does not play with Processing.
The link works and is a playlist that will work if opened with VLC player.

Output:

References:

:)

1 Like

H, @glv! Thanks a lot for your investigation and clues. I really appreciate them!
I see you have changed the regex pattern for matching the new circumstances of the html page. I started learning regex since my initial post but I didnā€™t arrive to that point.
I know that Processing has problems playing .m3u8 extensions. I tried yesterday to play other online working .m3u8 sources with .vlc and it worked, while Processing got stuck. I thought I had two problems to solve but now it only remains one.
Iā€™ve been searching for other Processing video libraries but no luck so far. Iā€™m considering to move this project to OF, but it would be a pitty since I have a considerable part already developed.
Thanks again!

1 Like

Try this version of @glv code. Unfortunately, as mentioned earlier, Processing Video filters out https. And the trick of using http in my earlier example doesnā€™t work now. OTOH, we can use a fake URL and then set the real one directly. Works here anyway on Ubuntu 20.04 -

void setup() {
  size(640,480);
  String[] pageHTML = loadStrings("http://www.skylinewebcams.com/en/webcam/ellada/atiki/athina/ermou-street-syntagma-square.html");
  //printArray(pageHTML);
  
  // "VideoObject","contentUrl":"https://cdn.skylinewebcams.com/video/552.mp4","description" // Looked interesting
  
  String camURLpattern = "(.m3u8)(.*?)(')";
  String[] m = match(join(pageHTML, ""), camURLpattern);
  printArray(m);
 
  //String camURL = "https://hd-auth.skylinewebcams.com/live.m3u8?a=q4rs4qnstdd81cu80oht4l7o43"; //Example and probably expired
  String camURL = "https://hd-auth.skylinewebcams.com/live.m3u8" + m[2]; //https://hd-auth.skylinewebcams.com/live // Found in Chrome > Inspect > Network

  println(camURL);
  
  // I was curious:
  pageHTML = loadStrings(camURL);
  printArray(pageHTML);
  
  //camURL = pageHTML[5];
  
  syn = new Movie(this, "http://www.example.com");
  syn.playbin.setURI(java.net.URI.create(camURL));
  syn.play();
}

void draw() 
  {
  if (syn.available()) 
    {
    syn.read();
    }
  image(syn, 0, 0, width, height);
 
2 Likes

Hi, @neilcsmith! Thanks a lot for making it work again in Ubuntu.
Using GStreamer playbin.setfunction(URI) itā€™s a great workaround.

I forgot to mention the point that Iā€™m working in windows and unfortunately itā€™s not playing there, since it seems thereā€™s still a problem with the secure connection.

BaseSrc: [source] : Secure connection setup failed.
BaseSrc: [source] : Internal data stream error.
Element: [typefindelement0] : Stream doesn't contain enough data.

I tried changing camURL to ā€œhttp//ā€¦ā€ and I got

URIDecodeBin: [uridecodebin0] : Your GStreamer installation is missing a plug-in.
Element: [queue2-0] : Internal data stream error.

I got it work in ubuntu using the last version of video library (Release 8 2.0) but I would prefer to make it run on windows, if i have the chance. Any idea about this ā€œSecure connection setup failed.ā€?
A lot of thanks for the efforts inverted.

1 Like

Probably because the bundled libraries for Windows are missing something. Theyā€™re far from a complete GStreamer install. If you can find a way for the Video library to use a system installed Windows GStreamer you might be OK, but Iā€™m not sure thatā€™s possible without changing the code a little. Itā€™s a total mistake IMO that the Video library ships with GStreamer bundled rather than downloading the installer.

The http link doesnā€™t work any more because it seems to be providing text (presumably an error message, but didnā€™t check).

1 Like