1

In laravel using php-ffmpeg want to convert video and do some changes on it, like watermark, change size and etc... I ran a test:

    $format = new X264;
    $ffmpeg = FFMpeg::create();
    $video = $ffmpeg->open(public_path()."/videos/file.mp4");
    $output = public_path().'/videos/'.time().'.mp4';
    $video->save($format, $output);

And it is working good, but I want to add a watermark then added this:

     $watermarkPath = public_path().'/videos/watermark.png';
     $video ->filters() ->watermark($watermarkPath, array( 'position' => 'relative', 'bottom' => 50, 'right' => 50, ));

But now I didn't get any output and also got error:

FFMpeg\Exception\RuntimeException: Encoding failed in file D:\Workshop\x\New Version\x-api\vendor\php-ffmpeg\php-ffmpeg\src\FFMpeg\Media\AbstractVideo.php on line 116

#0 D:\Workshop\x\New Version\x-api\app\Http\Controllers\AdsController.php(497): FFMpeg\Media\AbstractVideo->save(Object(FFMpeg\Format\Video\X264), 'D:\Workshop\Nob...')

Any idea?

Jack The Baker
  • 1,781
  • 1
  • 20
  • 51

1 Answers1

0
  • check your watermark file path.
  • check watermark positioning:
    The watermark positioning parameters you've provided might be causing the issue. Ensure that the values you're using for 'bottom' and 'right' are appropriate for your video's dimensions. If the watermark is positioned outside the video frame, it could lead to encoding failures.
  • downgrade or upgrade the php-ffmpeg version (recommend ^0.6.1)
Hiro Doublin
  • 1
  • 2
  • 13