Download the PHP package tbritz/ffmphp without Composer

On this page you can find all versions of the php package tbritz/ffmphp. 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?

Informations about the package ffmphp

Build Status

FFmphp

A simple, clean, and elegant way to run FFmpeg from your php applications.

Installation

You will need a working install of FFmpeg (and FFprobe) in your system (https://www.ffmpeg.org/download.html).

This library can be installed via composer:

As long as ffmpeg and ffprobe are available from your system's PATH variable, this library should use them automatically. If not, you can configure FFmphp before using it:

These settings will be applied to all FFmphp calls for the remainder of the script execution.

Basic Usage

Video Transcoding

Getting started is easy. Converting a video can be as simple as this command:

FFmpeg will guess the output type based on the extension.

Most of the time, however, you will give save() the name of an OutputFormat:

For the rest of the document we will use php's ::class syntax instead of providing the fully qualified class name of the format. Here is what the previous example looks like when it is rewritten:

Extracting Audio Tracks from Video

Working with audio formats is just as easy:

Saving Thumbnails

Saving a video poster, or thumbnail image, works the same way:

Saving Tiled/Mosaic Images

You guessed it:

Save Multiple Files with One Command

You can add an arbitrary number of outputs with one command. For example:

The above command would run FFmpeg once and create 5 files.

Note: This is only provided as an example. Although the code may be more readable and make it easier to reason about the overall progress (or failures) during conversion, actual memory usage of FFmpeg increases for every output stream. In many cases the number of outputs you can chain on a single command instance will be limited by the available system memory and the resolution of your video streams.

Advanced Usage

Output Formats

The best way to keep your project organized is to create an OutputFormat class for every type of file that you will save. An output format includes codecs, bitrate, container, resolution, and more. Don't worry, it's actually much simpler than it sounds!

To make it easier to start writing code, these formats are included:

You are welcome to use these classes in your own application, however in most cases it is better to use them only as a reference, and instead create your own formats which are tuned to the unique requirements of your application.

You can either create your class from scratch, or you may extend another format. Your class must implement the FFmphp\Formats\OutputFormat interface, which has one method: build().

For example, you may wish to create a format which is specifically tuned for animation content by extending the existing MP4 class:

Or perhaps you want more control over the default encoder options. Here is an another complete example, this time creating a new MP4 format from scratch:

To use your output format, simply reference it in save():

Getting the Command

If you want to inspect the command that will be run (without running it), you can use the toCommand() method:

Which will return a string like this:

Conditionally Adding Output Streams

You may want to add some output formats only when certain conditions are met. You can use when() for those situations. For example, you might want to create a 1080p version of a video only when the source resolution was high enough:

The second parameter of when() accepts a function that will only be applied when the first argument is true.

Adding Encoder Options

The third parameter of save() accepts an associative array of options that will be added to the output. In some cases this may be more convenient than creating a new class for each output type.

The third argument can also be a closure, if you need more control:

Using this feature excessively will make your code harder to read, which is why it is recommended instead to have a class for every type of output.

The Progress Callback

The run() method accepts an optional callback function, which will be run approximately once every second for as long as FFmpeg is running. The function will receive the current time position of the input as reported by FFmpeg, formatted like 00:00:00.00.

For example:

Raw Commands

The raw() method is perfect if you need more control, have complicated filters, or already know FFmpeg and just want the convenience of the php integration. The raw() method takes an array of arguments to be passed to FFmpeg.


All versions of ffmphp with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3
symfony/process Version ^4.2|^5.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 tbritz/ffmphp contains the following files

Loading the files please wait ....