PHP detect if shell_exec() command failed

前端 未结 2 1032
萌比男神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:47
    $return=shell_exec('ffmpeg ...');
    
    if ($return) { //look at what it returns do what you will with the data
    
    }
    
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题