1

i have already installed the laravel-ffmpeg via composer in my project

composer require pbmedia/laravel-ffmpeg

then i added class to config/app.php file as documentation says

// config/app.php

'providers' => [
    ...
    ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider::class,
    ...
];

'aliases' => [
    ...
    'FFMpeg' => ProtoneMedia\LaravelFFMpeg\Support\FFMpeg::class
    ...
];

then publish this config file

php artisan vendor:publish --provider="ProtoneMedia\LaravelFFMpeg\Support\ServiceProvider"

now my question is to use this package in my project, how should i use this into my controller i saw many post and ques regarding this and i get these

use FFMpeg;
use FFMpeg\FFMpeg;
use Pbmedia\LaravelFFMpeg\FFMpeg;
use ProtoneMedia\LaravelFFMpeg\FFMpeg;
.
.
.

which one is correct, my goal is to trim a video, but which one works for that i am so confused

//config/laravel-ffmpeg.php

<?php

return [
    'ffmpeg' => [
        'binaries' => env('FFMPEG_BINARIES', 'ffmpeg'),
        'threads'  => 12,
    ],

    'ffprobe' => [
        'binaries' => env('FFPROBE_BINARIES', 'ffprobe'),
    ],

    'timeout' => 3600,

    'enable_logging' => true,

    'set_command_and_error_output_on_exception' => false,
];

please help me out, thanks in advance

Vines Villa
  • 27
  • 10
  • Is this in any way related to https://stackoverflow.com/questions/65087821/how-to-use-or-import-ffmpeg-in-a-laravel-controller? If not, what **exactly** is not working with the given code? – Nico Haase Dec 01 '20 at 10:11
  • yes, it's related sir, ok how can i trim a video please show me method i'll try and let you know what error occur then – Vines Villa Dec 01 '20 at 10:18
  • Please share your attempts by editing the question. It should contain all relevant information – Nico Haase Dec 01 '20 at 10:35
  • should i also add something to .env file, and there is no any serviceprovider file in provider – Vines Villa Dec 01 '20 at 10:44
  • Maybe - through `env('FFMPEG_BINARIES', 'ffmpeg')` you try to access something from your `.env` file. If you haven't defined the proper paths to your binaries, that's a good point to start. That's something I've mentioned in the other post already – Nico Haase Dec 01 '20 at 10:57
  • Have your installed FFMPEG on your server? WIthout installing FFMpeg this laravle package will not work. – Rajender Kumar Dec 08 '20 at 05:18

1 Answers1

0

Use below code in your controller above class

use FFMpeg;
use FFMpeg\Coordinate\Dimension;
use FFMpeg\Format\Video\X264;

Open file using FFMpeg in your controller method

$media = FFMpeg::open($file_path);