Download the PHP package kimdongwan121/php-ffmpeg without Composer

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

php-ffmpeg

Build Status

SensioLabsInsight

An Object-Oriented library to convert video/audio files with FFmpeg / AVConv.

Check another amazing repo: PHP FFMpeg extras, you will find lots of Audio/Video formats there.

Your attention please

How this library works:

This library requires a working FFMpeg install. You will need both FFMpeg and FFProbe binaries to use it. Be sure that these binaries can be located with system PATH to get the benefit of the binary detection, otherwise you should have to explicitly give the binaries path on load.

Known issues:

Installation

The recommended way to install PHP-FFMpeg is through Composer.

Basic Usage

Documentation

This documentation is an introduction to discover the API. It's recommended to browse the source code as it is self-documented.

FFMpeg

FFMpeg\FFMpeg is the main object to use to manipulate medias. To build it, use the static FFMpeg\FFMpeg::create:

FFMpeg 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.

Manipulate media

FFMpeg\FFMpeg creates media based on URIs. URIs could be either a pointer to a local filesystem resource, an HTTP resource or any resource supported by FFmpeg.

Note: To list all supported resource type of your FFmpeg build, use the -protocols command:

To open a resource, use the FFMpeg\FFMpeg::open method.

Two types of media can be resolved: FFMpeg\Media\Audio and FFMpeg\Media\Video. A third type, FFMpeg\Media\Frame, is available through videos.

Video

FFMpeg\Media\Video can be transcoded, ie: change codec, isolate audio or video. Frames can be extracted.

Transcoding

You can transcode videos using the FFMpeg\Media\Video:save method. You will pass a FFMpeg\Format\FormatInterface for that.

Please note that audio and video bitrate are set on the format. You can disable the -b:v option by setting the kilo bitrate to 0.

Transcoding progress can be monitored in realtime, see Format documentation below for more information.

Extracting image

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

This code returns a FFMpeg\Media\Frame instance corresponding to the second 42. You can pass any FFMpeg\Coordinate\TimeCode as argument, see dedicated documentation below for more information.

If you want to extract multiple images from the video, you can use the following filter:

By default, this will save the frames as jpg images.

You are able to override this using setFrameFileType to save the frames in another format:

Clip

Cuts the video at a desired point. Use input seeking method. It is faster option than use filter clip.

The clip filter takes two parameters:

On clip you can apply same filters as on video. For example resizing filter.

Generate a waveform

You can generate a waveform of an audio file using the FFMpeg\Media\Audio::waveform method.

This code returns a FFMpeg\Media\Waveform instance. You can optionally pass dimensions as the first two arguments and an array of hex string colors for ffmpeg to use for the waveform, see dedicated documentation below for more information.

The output file MUST use the PNG extension.

If you want to get a waveform from a video, convert it in an audio file first.

Filters

You can apply filters on FFMpeg\Media\Video with the FFMpeg\Media\Video::addFilter method. Video accepts Audio and Video filters.

You can build your own filters and some are bundled in PHP-FFMpeg - they are accessible through the FFMpeg\Media\Video::filters method.

Filters are chainable

Rotate

Rotates a video to a given angle.

The $angle parameter must be one of the following constants :

Resize

Resizes a video to a given size.

The resize filter takes three parameters:

If you want a video in a non-standard ratio, you can use the padding filter to resize your video in the desired size, and wrap it into black bars.

The pad filter takes one parameter:

Don't forget to save it afterwards.

Watermark

Watermark a video with a given image.

The watermark filter takes two parameters:

$watermarkPath, the path to your watermark file. $coordinates, an array defining how you want your watermark positioned. You can use relative positioning as demonstrated above or absolute as such:

Framerate

Changes the frame rate of the video.

The framerate filter takes two parameters:

Synchronize

Synchronizes audio and video.

Some containers may use a delay that results in desynchronized outputs. This filter solves this issue.

Clip

Cuts the video at a desired point.

The clip filter takes two parameters:

Crop

Crops the video based on a width and height(a Point)

It takes two parameters:

Audio

FFMpeg\Media\Audio can be transcoded too, ie: change codec, isolate audio or video. Frames can be extracted.

Transcoding

You can transcode audios using the FFMpeg\Media\Audio:save method. You will pass a FFMpeg\Format\FormatInterface for that.

Please note that audio kilobitrate is set on the audio format.

Transcoding progress can be monitored in realtime, see Format documentation below for more information.

Filters

You can apply filters on FFMpeg\Media\Audio with the FFMpeg\Media\Audio::addFilter method. It only accepts audio filters.

You can build your own filters and some are bundled in PHP-FFMpeg - they are accessible through the FFMpeg\Media\Audio::filters method.

Clipping

Cuts the audio at a desired point.

Metadata

Add metadata to audio files. Just pass an array of key=value pairs of all metadata you would like to add. If no arguments are passed into the filter all metadata will be removed from input file. Currently supported data is title, artist, album, artist, composer, track, year, description, artwork

Add artwork to the audio file

NOTE: at present ffmpeg (version 3.2.2) only supports artwork output for .mp3 files

Resample

Resamples an audio file.

The resample filter takes two parameters :

Frame

A frame is an image at a timecode of a video; see documentation above about frame extraction.

You can save frames using the FFMpeg\Media\Frame::save method.

This method has a second optional boolean parameter. Set it to true to get accurate images; it takes more time to execute.

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.

Concatenation

This feature allows you to generate one audio or video file, based on multiple sources.

There are two ways to concatenate videos, depending on the codecs of the sources. If your sources have all been encoded with the same codec, you will want to use the FFMpeg\Media\Concatenate::saveFromSameCodecs which has way better performances. If your sources have been encoded with different codecs, you will want to use the FFMpeg\Media\Concatenate::saveFromDifferentCodecs.

The first function will use the initial codec as the one for the generated file. With the second function, you will be able to choose which codec you want for the generated file.

You also need to pay attention to the fact that, when using the saveFromDifferentCodecs method, your files MUST have video and audio streams.

In both cases, you will have to provide an array of files.

To concatenate videos encoded with the same codec, do as follow:

The boolean parameter of the save function allows you to use the copy parameter which accelerates drastically the generation of the encoded file.

To concatenate videos encoded with the different codec, do as follow:

More details about concatenation in FFMPEG can be found here, here and here.

AdvancedMedia

AdvancedMedia may have multiple inputs and multiple outputs.

This class has been developed primarily to use with -filter_complex.

So, its filters() method accepts only filters that can be used inside -filter_complex command. AdvancedMedia already contains some built-in filters.

Base usage

For example:

This code takes 2 input videos, stacks they horizontally in 1 output video and adds to this new video the audio from the first video. (It is impossible with simple filtergraph that has only 1 input and only 1 output).

Complicated example

A more difficult example of possibilities of the AdvancedMedia. Consider all input videos already have the same resolution and duration. ("xstack" filter has been added in the 4.1 version of the ffmpeg).

This code takes 4 input videos, then the negates the first video, stores result in [v0negate] stream, detects edges in the second video, stores result in [v1edgedetect] stream, horizontally flips the third video, stores result in [v2hflip] stream, vertically flips the fourth video, stores result in [v3vflip] stream, then takes this 4 generated streams ans combine them in one 2x2 collage video. Then saves audios from the original videos into the 4 different formats and saves the generated collage video into the separate file.

As you can see, you can take multiple input sources, perform the complicated processing for them and produce multiple output files in the same time, in the one ffmpeg command.

Just give me a map!

You do not have to use -filter_complex. You can use only -map options. For example, just extract the audio from the video:

Customisation

If you need you can extra customize the result ffmpeg command of the AdvancedMedia:

Formats

A format implements FFMpeg\Format\FormatInterface. To save to a video file, use FFMpeg\Format\VideoInterface, and FFMpeg\Format\AudioInterface for audio files.

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

Predefined formats already provide progress information as events.

The callback provided for the event can be any callable.

Add additional parameters

You can add additional parameters to your encoding requests based on your video format.

The argument of the setAdditionalParameters method is an array.

Add initial parameters

You can also add initial parameters to your encoding requests based on your video format. This can be expecially handy in overriding a default input codec in FFMpeg.

The argument of the setInitialParameters method is an array.

Create your own format

The easiest way to create a format is to extend the abstract FFMpeg\Format\Video\DefaultVideo and FFMpeg\Format\Audio\DefaultAudio. and implement the following methods.

Coordinates

FFMpeg uses many units for time and space coordinates.

FFProbe

FFMpeg\FFProbe is used internally by FFMpeg\FFMpeg to probe medias. You can also use it to extract media metadata.

Validating media files

(since 0.10.0) You can validate media files using PHP-FFMpeg's FFProbe wrapper.

Using with Silex Microframework

The service provider is easy to set up:

Available options are as follow:

License

This project is licensed under the MIT license.

Music: "Favorite Secrets" by Waylon Thornton From the Free Music Archive CC BY NC SA

Music: "Siesta" by Jahzzar From the Free Music Archive CC BY SA


All versions of php-ffmpeg with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.9
alchemy/binary-driver Version ^1.5 || ~2.0.0 || ^5.0
doctrine/cache Version ^1.0
evenement/evenement Version ^3.0 || ^2.0 || ^1.0
neutron/temporary-filesystem Version ^2.1.1 || ^3.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 kimdongwan121/php-ffmpeg contains the following files

Loading the files please wait ....