1

I'm using PHP-FFMpeg in a Laravel 5.2 application to stabilize videos with the help of VidStab. I have all the dependencies and everything installed correctly and I can follow the directions on the VidStab repo to stabilize my videos via the command line.

My question is how could I do this nicely (the Laravel way) from within PHP? I know I can add a custom filter to the Video object like this:

$video = $ffmpeg->open('shaky_video.mp4');
$video->addFilter(new CustomFilter('vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform.trf'));

But how can I execute this command without the need for $video-save(), which I think is designed to output a video/audio file and not the trf analysis file?

I suppose I could just run a PHP exec() command, but I would like to keep this as much object oriented PHP as I can. Any suggestions?

Thanks in advance!


I've tried this (added -f null - to filter and then tried running save() to execute the command), but it still creates the mp4 file instead of the trf file:

$video = $ffmpeg->open('shaky_video.mp4');
$video->addFilter(new CustomFilter('vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform.trf -f null -'));
$video->save(new X264(), 'stabilized.mp4');
Emii Khaos
  • 9,983
  • 3
  • 34
  • 57
JasonJensenDev
  • 2,377
  • 21
  • 30
  • You need your output format to be `-f null -` This will discard any file output ffmpeg generates. – Gyan Feb 19 '16 at 05:08
  • Thanks for the suggestion Mulvya. I tried adding the `-f null -` to the custom filter and then added `$video->save(new X264(), 'stabilized.mp4')`, but it looks like it still output the mp4 instead of the trf file. Any other suggestions? – JasonJensenDev Feb 19 '16 at 05:38
  • The `-f null -` goes in the save, not the filter. No filename needed. – Gyan Feb 19 '16 at 05:41
  • I've tried adding the `-f null -` in the `save` method, but any way I've tried throws an error. Could you please show me the complete `$video->save()` command? – JasonJensenDev Feb 19 '16 at 05:47
  • 1
    Sorry, not a PHP coder. I guess save opens a file for writing. The equivalent command is `ffmpeg -i input -vf vidstabdetect -f null -`. So maybe skip the save and use just the open and filter. – Gyan Feb 19 '16 at 06:02
  • Haha... thanks for the help, Mulvya. From what I can tell, the way that PHP-FFMpeg works is that it doesn't actually run any commands until you execute the save() method. Everything else that leads up to that is simply adding to the Video object. So it seems like the best thing to do is simply use an exec command to run the exact command I want. It's just not as OOP or Laravelish. Thanks again! – JasonJensenDev Feb 19 '16 at 06:05

0 Answers0