Receiving Data from a Streaming

0

I have a little problem and I would like your help. I recently had a question and I started to search about it but I did not find anything, I noticed that the video streaming services uses a "wowza" server and for that I wanted to receive the streaming and to be able to replicate using php an example is the url down

  

link

I used this code to try to connect but it 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 do not know if it's possible, I tried to use socket but I could not, could anyone help me with this? I'm sorry if the url is not appropriate but I needed to quote a url for testing.

Thank you!

    
asked by anonymous 11.05.2017 / 06:21

1 answer

0

Daniel, I know this question has been a long time ago, but for historical purposes and other people with similar questions follows my answer.

An 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 / audio). In this way, browsers can consume the stream without having to open TCP / UDP connections as it did in RTMP / RTSP streams via Flash.

So, if you want to cache some of this stream so that your users do not directly hit Wowza (upstream / origin), you could simply put a reverse proxy (NGinx for example) up front, 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 perform the caching and delivery of this stream - but this will generate higher costs, so it needs to be considered well.

I can share some NGinx configuration examples if anyone has an interest in the future.

    
05.01.2018 / 13:44