1

I wanna create custom command using php-ffmpeg/laravel-ffmpeg?

$customFilter = ['-stream_loop 3'];
$customFilter1 = ['-c copy'];
\FFMpeg::fromDisk($this->data['input_disk'])
    ->open($this->data['input'])
    ->addFilter(function ($filters) {
            $filters->custom($customFilter);
            $filters->custom($customFilter1);
     })
    ->export()
    ->toDisk($this->data['output_disk'])
    ->inFormat(new \FFMpeg\Format\Video\X264('libmp3lame', 'libx264'))
    ->save($this->data['output']);

local.ERROR: Encoding failed {"exception":"[object] (FFMpeg\Exception\RuntimeException(code: 0):

6
  • ->addFilter(new FFMpeg\Filters\Audio\SimpleFilter($customFilter)) ->addFilter(new FFMpeg\Filters\Audio\SimpleFilter($customFilter1)) should be ->addFilter(new \FFMpeg\Filters\Audio\SimpleFilter($customFilter)) ->addFilter(new \FFMpeg\Filters\Audio\SimpleFilter($customFilter1)) Commented May 27, 2019 at 13:03
  • missing \ from the package name. Commented May 27, 2019 at 13:04
  • i have added the \ but still the same error occurs. Is there any other way to process the custom filters in php-ffmpeg? Commented May 28, 2019 at 12:04
  • just to confirm... when you try the code without custom filters...does this work? Commented May 28, 2019 at 12:06
  • Hi @VikashPathak i need a loop video/ repeat video with multiple times, when am trying in cmd it is working but in the laravel-ffmpeg i dont know how to set the custom filters for loop the video, Can you please give an idea? Commented May 28, 2019 at 12:09

1 Answer 1

1

Please try if this could help to you. As per the fix given here...use string start/end with space instead of array.

https://github.com/PHP-FFMpeg/PHP-FFMpeg/issues/381#issuecomment-314150217

$customFilter = ' -stream_loop 3 ';
$customFilter1 = ' -c copy ';
\FFMpeg::fromDisk($this->data['input_disk'])
    ->open($this->data['input'])
    ->addFilter(function ($filters) {
            $filters->custom($customFilter);
            $filters->custom($customFilter1);
     })
    ->export()
    ->toDisk($this->data['output_disk'])
    ->inFormat(new \FFMpeg\Format\Video\X264('libmp3lame', 'libx264'))
    ->save($this->data['output']);
Sign up to request clarification or add additional context in comments.

5 Comments

or just combine both of custom filters with multiple string. like $filters->custom(' -stream_loop 3 ', ' -c copy '); As per documentation in filter section.. github.com/pascalbaljetmedia/laravel-ffmpeg
/usr/bin/ffmpeg' '-y' '-i' '/tmp/laravel-ffmpega8wlU2' '-threads' '12' '-vcodec' 'libx264' '-acodec' 'libmp3lame' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-vf' '[in]-stream_loop 3[out]' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5ced2891df501t4ckr/pass-5ced2891eddea' '/tmp/laravel-ffmpegBdgpn7.mp4' This is the command returned with error.
remove one filter and try with only one. $filters->custom(' -stream_loop ', 3);
the above direct custom also not work properly @vikash
@vasanth do share the output of this cmd and the cmd that working for you... what is differece b/w both?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.