Skip to content

Symfony bundle to provide PHP-FFmpeg as a Symfony service. Forked to support Symfony 5 and Symfony 6

License

Notifications You must be signed in to change notification settings

fmonts/ffmpeg-bundle

 
 

Repository files navigation

Symfony FFmpeg bundle

Latest Stable Version Total Downloads Latest Unstable Version License

This bundle provides a simple wrapper for the PHP_FFmpeg library, exposing the library as a Symfony service.

This fork adds Symfony5, Symfony6 and Symfony7 support and drops legacy Symfony and PHP support

Set up the bundle

  1. Install FFmpeg and find out where the binaries are located. Example on Ubuntu/Debian:
$ sudo apt install ffmpeg
$ whereis ffmpeg
# outputs: ffmpeg: /usr/bin/ffmpeg
$ whereis ffprobe
# outputs: ffmpeg: /usr/bin/ffprobe
  1. Create the required configuration in a yaml file, such as config/packages/dubture_f_fmpeg.yaml:
dubture_f_fmpeg:
  ffmpeg_binary: /usr/bin/ffmpeg
  ffprobe_binary: /usr/bin/ffprobe
  binary_timeout: 300 # Use 0 for infinite
  threads_count: 4
  temporary_directory: /var/ffmpeg-tmp

Note: The temporary_directory key is only used for writing two-pass logs.

  1. Require the bundle with composer:
$ composer require fmonts/ffmpeg-bundle
  1. Add, in services.yaml, under services:
FFMpeg\FFMpeg: '@dubture_ffmpeg.ffmpeg'

Usage

class VideoController extends AbstractController
{
    public function resize(FFMpeg $FFMpeg): Response
    {
        // Open video
        $video = $FFMpeg->open('/your/source/folder/input.avi');
        
        // Resize to 1280x720
        $video
          ->filters()
          ->resize(new Dimension(1280, 720), ResizeFilter::RESIZEMODE_INSET)
          ->synchronize();
        
        // Start transcoding and save video
        $video->save(new X264(), '/your/target/folder/video.mp4');
    }
}

About

Symfony bundle to provide PHP-FFmpeg as a Symfony service. Forked to support Symfony 5 and Symfony 6

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%