

If you don't have a software that can open a ZIP file, you can download the CAM UnZip utility.ĬAM UnZip is a small freeware utility that allows you to easily extract files from any ZIP file. Then, while passing file path to VideoStream class’s constructor, use “s3://” format as file string.All the utilities and tools in this Web site are compressed in a ZIP file. First, make sure to register ‘streamWrapper’ with your s3 client: You can have s3 service’s file location support on the above class very easily.

The ‘stream()’ method simply stream the predefined amount of data with a customizable buffer size.The buffer size is just to optimize the server memory utilization so that not huge memory is taken in case of concurrent high number of requests. Inside ‘setHeader()’ method, it just validates the range requests and decide how much data to send accordingly. When browser makes range request, it includes and additional header named ‘HTTP_RANGE’.

‘Accept-Ranges’ header is important to tell the browser that server is accepting any byte level request in the given range, so that browser can decide range itself make custom range requests subsequently. However, at this moment, mp4 is the most widely supported format across major browsers, so using this format is very much recommended. You can change it according to your need. In header setting, by default mp4 file’s mime type are given.

The header part is the most important as here you will be communicating with client browser, tell it that you can accept range request and check if browser made range requests or not and decide the amount of data to stream. It can either give it a local path, or even an amazon s3 file location as well(explained later).Īfter calling the ‘start()’ method, it first tries to open the file, then set the proper headers, then stream required contents and finally close the file system handler. The class simply takes the path of the video file as constructor parameter. Understanding the class and HTML5 Streaming logic: To use this class, you will have to write simple code like as below: Here I will try to share my experience and code that will help you to implement PHP HTML5 video streaming easily and efficiently.Ĭheckout The PHP HTML5 Video Streaming Demoįollowing is the simple class, that includes all HTML5 streaming logic and is responsible for perform the main streaming action: In a recent project, I have something similar, where a video was needed to be streamed through PHP to client browser’s HTML5 player. Though it can stream with a given public video file url, sometimes you will need to control the streaming from your server script to provide additional facility like authentication, resume support, sending in partial chunks etc. HTML5 video player is being more and more popular day by day.
