Use the return of the mkdir
function itself to verify that the folder has been created. Ex:
<?php
$folderClip = "clip";
$folderVideos = "~/Videos"
/**
* Tenta criar a pasta, caso a pasta seja criada
* retorna 'true' e então executa a função 'exec'
* caso contrário, "pula" o código.
*/
if (mkdir($pasta, 0777, true)) {
exec("ffmpeg -i {$folderVideos}/papa_mike.mp4 -vframes 1 {$folderClip}/papa_mike.png", $output, $return);
}
Note: If your file is in the project root, it is not necessary to pass the current folder.