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


I would like to know the basics about how to create (make) a live stream system… I have a blog script in php where I created a user system and even a friendship system but I would like to add the possibility for each user to create a "kind" of own channel to live stream content (games, reviews, tutorials, etc…) broadcasting to friends on your lists or publicly. I've seen countless scripts on the internet, but they have much more than I need, I'm not looking for anything with filters or my own systems, I'd like to create them to implement in my ready-made script.

Every help is welcome. From simple examples to study tips thank you all have a nice end of the year 🙂


Live-stream (live streaming)

  • As per this answer on SO-en , PHP is not suitable for using "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 be necessary for something to capture the WebCam of the person who transmits the video, save the data in a document and the people who watch are waiting for new bytes to be added to the server , this can be very costly to develop and for the server .

    See an example is Youtube, they do live streams and display videos that are on the server, while the site is on a server optimized for web pages, the videos are on another fully isolated server, which is optimized for streaming videos and it is likely that their "live-stream" is on yet 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 might even be able to use PHP for this, but your server probably won't last a day.

  • And as per SO-en 's answer to record the video with HTML5, you will need to use WebRTC . This enables audio and video streaming.

RTMP Alternative (Requires Flash)

I haven't tested it yet, but the way is this:

Like Youtube, you can separate in two servers one you can use Apache for webpage and the "PHP client" (using port 80) and in Ngnix you will only use for RTMP ( I think the default is port 1935 )

Non-live-stream alternative

But there is the following script to record with PHP (if not in real time) that you can use PHP Webcam Video Recorder

Scroll to Top