Download the PHP package aminyazdanpanah/php-ffmpeg-video-streaming without Composer

On this page you can find all versions of the php package aminyazdanpanah/php-ffmpeg-video-streaming. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
aminyazdanpanah/php-ffmpeg-video-streaming
Rate from 1 - 5
Rated 4.67 based on 3 reviews

Informations about the package php-ffmpeg-video-streaming

📼 PHP FFmpeg Video Streaming

Total Downloads

Overview

This library is a wrapper around PHP-FFMpeg and packages media content for online streaming such as DASH and HLS. You can also use DRM for HLS packaging. There are several options to open a file from a cloud and save files to clouds as well.

Contents

Requirements

  1. This version of the package is only compatible with PHP 7.2 or higher.

  2. To use this package, you need to install the FFmpeg. You will need both FFmpeg and FFProbe binaries to use it.

Installation

Install the package via composer:

Alternatively, add the dependency directly to your composer.json file:

Quickstart

First of all, you need to include the package in your code:

Configuration

This package will autodetect FFmpeg and FFprobe binaries. If you want to give binary paths explicitly, you can pass an array as configuration. A Psr\Logger\LoggerInterface can also be passed to log binary executions.

Opening a Resource

There are several ways to open a resource.

1. From an FFmpeg supported resource

You can pass a local path of video(or a supported resource) to the open method:

See FFmpeg Protocols Documentation for more information about supported resources such as HTTP, FTP, and etc.

For example:

2. From Clouds

You can open a file from a cloud by passing an array of cloud configuration to the openFromCloud method.

Visit this page to see some examples of opening a file from Amazon S3, Google Cloud Storage, Microsoft Azure Storage, and a custom cloud.

3. Capture Webcam or Screen (Live Streaming)

You can pass the name of a supported, connected capture device(i.e. the name of a webcam, camera, screen and etc) to the capture method to stream a live media over network.

To list the supported, connected capture devices, see FFmpeg Capture Webcam and FFmpeg Capture Desktop.

DASH

Dynamic Adaptive Streaming over HTTP (DASH), also known as MPEG-DASH, is an adaptive bitrate streaming technique that enables high-quality streaming of media content over the Internet delivered from conventional HTTP web servers. Learn more

Create DASH files:

Generate representations manually:

See DASH section in the documentation, for more examples.

HLS

HTTP Live Streaming (also known as HLS) is an HTTP-based adaptive bitrate streaming communications protocol implemented by Apple Inc. as part of its QuickTime, Safari, OS X, and iOS software. Client implementations are also available in Microsoft Edge, Firefox, and some versions of Google Chrome. Support is widespread in streaming media servers. Learn more

Create HLS files:

Generate representations manually:

See HLS section in the documentation, for more examples such as Fragmented MP4, live from camera/screen and so on.

Encryption(DRM)

The encryption process requires some kind of secret (key) together with an encryption algorithm. HLS uses AES in cipher block chaining (CBC) mode. This means each block is encrypted using the ciphertext of the preceding block. Learn more

You must specify a path to save a random key to your local machine and also specify an URL(or a path) to access the key on your website(the key you will save must be accessible from your website). You must pass both these parameters to the encryption method:

Single Key

The following code generates a key for all segment files.

Key Rotation

An integer as a "key rotation period" can also be passed to the encryption method (i.e. encryption($save_to, $url, 10)) to use a different key for each set of segments, rotating to a new key after this many segments. For example, if 10 segment files have been generated then it will generate a new key. If you set this value to 1, each segment file will be encrypted with a new encryption key. This can improve security and allows for more flexibility.

See the example for more information.

IMPORTANT: It is very important to protect your key(s) on your website. For example, you can use a token(using a Get or Post HTTP method) to check if the user is eligible to access the key or not. You can also use a session(or cookie) on your website to restrict access to the key(s)(It is highly recommended).

DRM

However FFmpeg supports AES encryption for HLS packaging, which you can encrypt your content, it is not a full DRM solution. If you want to use a full DRM solution, I recommend trying FairPlay Streaming solution which then securely exchange keys, and protect playback on devices.

Besides Apple's FairPlay DRM system, you can also use other DRM systems such as Microsoft's PlayReady and Google's Widevine.

Subtitles

You can add subtitles to a HLS stream using subtitle method.

NOTE: All m3u8 files will be generated using rules based on RFC 8216. Only WebVTT files are acceptable for now.

Transcoding

A format can also extend FFMpeg\Format\ProgressableInterface to get realtime information about the transcoding.

Output From a Terminal:

transcoding

Saving Files

There are several ways to save files.

1. To a Local Path

You can pass a local path to the save method. If there was no directory in the path, then the package auto makes the directory.

It can also be null. The default path to save files is the input path.

NOTE: If you open a file from a cloud and do not pass a path to save the file to your local machine, you will have to pass a local path to the save method.

2. To Clouds

You can save your files to a cloud by passing an array of cloud configuration to the save method.

A path can also be passed to save a copy of files to your local machine.

Visit this page to see some examples of saving files to Amazon S3, Google Cloud Storage, Microsoft Azure Storage, and a custom cloud.

NOTE: This option(Save To Clouds) is only valid for VOD (it does not support live streaming).

Schema: The relation is one-to-many

3. To a Server Instantly

You can pass a URL(or a supported resource like FTP) to live method to upload all the segments files to the HTTP server(or other protocols) using the HTTP PUT method and update the manifest files every refresh times.

NOTE: In the HLS format, you must upload the master playlist to the server manually. (Upload the /var/www/stream/live-master-manifest.m3u8 file to the http://YOUR-WEBSITE.COM)

See FFmpeg Protocols Documentation for more information.

Metadata

You can get information from multimedia streams and the video file using the following code.

See the example for more information.

Conversion

You can convert your stream to a file or to another stream protocols. You should pass a manifest of the stream to the open method:

1. HLS To DASH

2. DASH To HLS

3. Stream(DASH or HLS) To File

Other Advanced Features

You can easily use other advanced features in the PHP-FFMpeg library. In fact, when you open a file with the open method(or openFromCloud), it holds the Media object that belongs to the PHP-FFMpeg.

Extracting image

You can extract a frame at any timecode using the FFMpeg\Media\Video::frame method.

NOTE: You can use the image as a video's poster.

Gif

A gif is an animated image extracted from a sequence of the video.

You can save gif files using the FFMpeg\Media\Gif::save method.

This method has a third optional boolean parameter, which is the duration of the animation. If you don't set it, you will get a fixed gif image.

NOTE: You can use the gif as a video's thumbnail.

To see more examples, visit the PHP-FFMpeg Documentation page.

Asynchronous Task Execution

The packaging process might take a while and it is recommended to run it in the background(or in a cloud e.g. AWS). There are some libraries that you can use for this use case.

NOTE: You can also create a script and run it in your cronjob.

Several Open Source Players

You can use these libraries to play your streams.

FAQs

I created stream files and now what should I pass to a player? You must pass a master playlist(manifest) URL(e.x. https://www.hadronepoch.org/?"PATH TO STREAM DIRECTORY"/dash-stream.mpd or /PATH_TO_STREAM_DIRECTORY/hls-stream.m3u8 ) to a player. See the demo page of these players for more information(hls.js Demo, dash.js Demo, videojs Demo and etc).

My player does not show the quality selector button to change the video quality? Some Players do not have an embedded quality selector button to change this option and you should install(or add) the plugin for this use case. For example, if you are using Videojs to play your stream, you can install videojs-hls-quality-selector to show the quality selector. For adding a plugin to other players, you can easily Google it!

I uploaded my stream files to a cloud but it does not play on my website? If you save your stream content to a cloud(i.e. Amazon S3), make sure your contents are PUBLIC. If they are not, you must change the access control.

Does IOS support the DASH stream? No, IOS does not have native support for DASH. Although there are some libraries such as Viblast and MPEGDASH-iOS-Player to support this technique, I have never tested them. So maybe some of them will not work properly.

See this page for more FAQs.

Support Us

We greatly appreciate your support in our efforts to contribute to open-source projects. If you're able to, we kindly ask that you take a moment to check out the available options for assisting us. Your help would enable us to maintain our commitment to producing exceptional results. Thank you for your support.

1. purchasing a service or product

Our company offers a range of products and services, including video streaming, video-on-demand, video conferencing, and an HR assistance application. If you wish to purchase any of these offerings, kindly direct your inquiries to our email address at [email protected]. We will be updating our website with further details in the near future.

2. sponsoring the project or org

Thank you for considering the option of sponsoring our organization. Your generous donations will greatly assist us in our efforts to enhance and expand our existing libraries, as well as build new ones. There are several options available for sponsorship, including clicking on the provided link or utilizing alternative methods such as crypto, Patreon, Open Collective, and ko-fi. Your support is greatly appreciated and will help us to continue our mission of providing valuable resources to the community.

3. Star and Share

If you find this project to be of value, kindly consider starring it and sharing it with those in your network who may benefit from this type of software. Your support would be greatly appreciated and would help to increase visibility and accessibility of this project.

Thank you for your consideration.

Contributing and Reporting Bugs

I'd love your help in improving, correcting, adding to the specification. Please file an issue or submit a pull request.

Credits

License

The MIT License (MIT). See License File for more information.


All versions of php-ffmpeg-video-streaming with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
php-ffmpeg/php-ffmpeg Version ^0.15 || 0.16 || 0.17 || 0.18 || 0.19 || ^1.0 || ^1.1
symfony/filesystem Version ^4.0 || ^5.0 || ^6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aminyazdanpanah/php-ffmpeg-video-streaming contains the following files

Loading the files please wait ....