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):

  • ->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)) – Vikash Pathak May 27 '19 at 13:03
  • missing \ from the package name. – Vikash Pathak May 27 '19 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? –  May 28 '19 at 12:04
  • just to confirm... when you try the code without custom filters...does this work? – Vikash Pathak May 28 '19 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? –  May 28 '19 at 12:09
  • please paste the command that is working for you. – Vikash Pathak May 28 '19 at 12:11

1 Answers1

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']);
Vikash Pathak
  • 3,444
  • 1
  • 18
  • 32
  • or just combine both of custom filters with multiple string. like $filters->custom(' -stream_loop 3 ', ' -c copy '); As per documentation in filter section.. https://github.com/pascalbaljetmedia/laravel-ffmpeg – Vikash Pathak May 28 '19 at 12:23
  • /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. –  May 28 '19 at 12:27
  • remove one filter and try with only one. $filters->custom(' -stream_loop ', 3); – Vikash Pathak May 28 '19 at 12:39
  • the above direct custom also not work properly @vikash –  May 29 '19 at 04:57
  • @vasanth do share the output of this cmd and the cmd that working for you... what is differece b/w both? – Vikash Pathak May 29 '19 at 05:25