Receiving Data from a Streaming

Asked

Viewed 84 times

0

I’m having a little problem, and I’d like your help. Recently I had a doubt and I started researching about but found nothing, I noticed that the video streaming services uses a server "Wowza" and for that I wanted to receive streaming and be able to replicate using php an example is the url below

http://live-hls.rtvcm.stream.flumotion.com:80/rtvcm/hls-multi/main.m3u8

I used this code to try to connect but was giving error

<?php
$fp = fsockopen("http://live-hls.rtvcm.stream.flumotion.com:80/rtvcm/hls-multi/main.m3u8", 80, $errno, $errstr);

fwrite($fp, "GET request HTTP/1.1\r\nConnection: keep-alive\r\n\r\n");

while (!feof($fp)) {
        echo fgets($fp, 1024);
}
    fclose($fp);
?>

I don’t know if it’s possible, I tried using socket but I couldn’t, could someone help me with that? I’m sorry if the url is not appropriate but I needed to quote a url for testing.

Thank you!

1 answer

0

Daniel, I know that question was a long time ago, but for historical purposes and other people with similar doubts follow my answer.

A HLS stream is nothing more than a series of HTTP (or HTTPS) requests, because the stream is segmented into small parts (example: small 30-second videos/audios). This way, browsers can consume the stream without having to open TCP/UDP connections like in RTMP/RTSP streams via Flash.

So, if you want to cache this stream, so that your users don’t hit Wowza directly (upstream/origin), you could simply put a reverse proxy (Nginx for example) ahead, which would be much more efficient than implementing this proxy in PHP. Another solution that would be much more robust would be to use a CDN to cache and deliver this stream - but this will generate higher costs, so it needs to be considered well.

I can share some examples of Nginx configuration if anyone is interested in the future.

  • If possible, give examples demonstrating the solution given or proving that it works. If not possible, cite references so the user can know how to start.

  • Thank you very much, I thought to do in a language because it makes it possible to scale more easily, this was just a test that I was testing to see the possibility, could you post some example? can be in any language

Browser other questions tagged

You are not signed in. Login or sign up in order to post.