0

I am trying to execute basic example of php-ffmpeg library in Laravel 5. I have already installed ffmeg on ubuntu and working fine from command line. I am getting following error while running the example.


Error

FatalErrorException in WelcomeController.php line 26: Class 'FFMpeg\FFMpeg\Coordinate\Dimension' not found


My Code

use FFMpeg\FFMpeg;

class WelcomeController extends Controller {

    public function __construct()
    {
        $this->middleware('guest');
    }

    public function index()
    {
        return view('welcome');
    }

    public function video()
    {

        $ffmpeg = FFMpeg::create();

        $video = $ffmpeg->open('test1.mp4');

        $video
            ->filters()
            ->resize(new FFMpeg\Coordinate\Dimension(320, 240))
            ->synchronize();
        $video
            ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(10))
            ->save('frame.jpg');
        $video
            ->save(new FFMpeg\Format\Video\X264(), 'export-x264.mp4')
            ->save(new FFMpeg\Format\Video\WMV(), 'export-wmv.wmv')
            ->save(new FFMpeg\Format\Video\WebM(), 'export-webm.webm');
    }
}

What would be the error?

Nikolay Mihaylov
  • 3,868
  • 8
  • 27
  • 32

1 Answers1

0

Sorry folks I made a silly mistake. I just added extra slashes while calling the functions which I really forgot before. Now its working fine. My Solution is given below.


Solution

use FFMpeg\FFMpeg;

class WelcomeController extends Controller {

    public function __construct()
    {
        $this->middleware('guest');
    }

    public function index()
    {
        return view('welcome');
    }

    public function video()
    {

        $ffmpeg = FFMpeg::create();

        $video = $ffmpeg->open('test1.mp4');

        $video
            ->filters()
            ->resize(new \FFMpeg\Coordinate\Dimension(320, 240))
            ->synchronize();
        $video
            ->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(10))
            ->save('frame.jpg');
        $video
            ->save(new \FFMpeg\Format\Video\X264(), 'export-x264.mp4')
            ->save(new \FFMpeg\Format\Video\WMV(), 'export-wmv.wmv')
            ->save(new \FFMpeg\Format\Video\WebM(), 'export-webm.webm');
    }
}