0

I have a collection of a few video URLs, and what I am trying to do is add a watermark to all the videos using a for loop, in a laravel

inside the loop, this is my FFmpeg code.

shell_exec('ffmpeg -y -i MY_VIDEO_PATH_HERE -i WATER_MARK_IMAGE_URL -filter_complex "overlay=18:H-h-30" -strict -2 -codec:a copy "MY_PATH_TO_STORE_VIDEO"');

All this code is done using a queue/job from the laravel.

My Problem is, If the above command is getting failed and not able to add the watermark

it does not move the next video to start adding the watermark, instead of it terminate the process and try to add the watermark again for the same video.

What I want is loop should continue for the next video instead of terminating the script.

Any solution?

Punit Gajjar
  • 4,937
  • 7
  • 35
  • 70

1 Answers1

0

The output from the executed command or NULL if an error occurred or the command produces no output.

https://www.php.net/manual/en/function.shell-exec.php

Therefore, theoretically you could try something like this in your loop:

$result = shell_exec('ffmpeg -y -i MY_VIDEO_PATH_HERE -i WATER_MARK_IMAGE_URL -filter_complex "overlay=18:H-h-30" -strict -2 -codec:a copy "MY_PATH_TO_STORE_VIDEO"');

if (null === $result) {
    // possibly also mark video as processed here if need be?

    continue; // skip current loop iteration
}
delboy1978uk
  • 12,118
  • 2
  • 21
  • 39