How to make basic live stream with HTML5 video API and PHP?

5

I would like to know the basics about how to create a live stream system ... I have a blog script in php where I created a system of users and even a friends system but I would like to add the possibility of each user to create a channel "kind" of their own to make live stream of content (games, reviews, tutos, etc ...) transmitting to friends in their lists or publicly. I've noticed a lot of internet scripts out there but they have a lot more than I do not need anything with filters or systems of their own, I'd like to create to implement in my script already done.

Any help is welcome. From simple examples to study tips thankful to everyone good year-end:)

    
asked by anonymous 28.12.2014 / 20:06

2 answers

5

Live-stream (live stream)

  • As stated in SO-en , PHP is not indicated for use of live-stream.

    I'm not going to say that it's impossible to do PHP, but maybe it's a hard way, because it will require something to capture the WebCam of the person transmitting the video, save the data in a document and the people who watch it wait for new bytes are added to the server, this can be very costly to develop and to the server .

    See an example is YouTube, they make live streams and display videos that are on the server, while the youtube.com site is on a server optimized for web pages, the videos are on another totally isolated server, which is optimized for streaming videos and it is likely that their live-stream is on another server (ie 3 servers with different technologies). So the data transmission is not done by a language like "PHP", but probably by a specific technology for transmissions.

    You may even be able to use PHP for this, but your server probably will not last a day.

  • And as per the answer in the SO-en To save your video using HTML5, you'll need to use WebRTC . This enables audio and video streaming.

Alternative RTMP (Flash Required)

I have not tested it yet, but the path is this:

  

As youtube, you can separate on two servers one you can use Apache for Web page and the "PHP client" (using port 80) and in Ngnix you will only use for RTMP ( I think that the default port is 1935)

Alternative not live-stream

However there is the following script to write with PHP (if it is not in real time) you can use PHP Webcam Video Recorder

    
28.12.2014 / 20:48
1

YES, it is possible to make this proposal with PHP.

In fact Youtube (both YouT and other similar platforms) runs thanks to FFmpeg . And this is not to say that it is a server different from the others you use to program (except for scalability and speed, memory, etc.)

So if you're using Linux, study this powerful application (command lines and how to use it) very important, So much so that php has a native library that works with FFmpeg.

In the case of PHP think so, let's talk about your project (or idea): PHP will run on the server, then you will use to convert the files, organize, (read the stream etc) and make available to the user.

But to record, you can not with PHP or Javascript, because they are not connected to the devices of the computer (like the camera for example). So for the user to submit a video you need another question.

So everyone indicated the use of Flash, which until then was the only device that connected the camera and Microphone (do not forget it). But now there's Html5 that can also connect to these devices. Then you can send a video of your users - with Flash or Html5.

It will work, but it's worth researching in that area.

I've done something similar but only one user uploaded video to a PHP server and several user connecting live and watching. With an Adobe application called Adobe Media Live Encoder. It had a version that was free, nowadays it is paid. :

In your case it is a more daring Programming, but it's worth it.

Links: link

- I can not post more links because it's my first time in Stack;)

    
23.06.2016 / 03:04