PHP detect if shell_exec() command failed

前端 未结 2 1031
萌比男神i
萌比男神i 2021-01-06 07:47

I\'m running the ffmpeg command within PHP\'s shell_exec() to convert several videos in a list. Is there anyway to detect if an error happened while the video was being conv

2条回答
  •  借酒劲吻你
    2021-01-06 07:55

    Capture the exit code with another system call function like exec:

    exec('ffmpeg ...', $output, $return);
    
    if ($return != 0) {
        // an error occurred
    }
    

    Any decent utility will exit with a code other than 0 on error.

提交回复
热议问题