1

want to know how the ffmpeg command is executed for taking screenshot in this code. I am not able to figure out when screenshot is created, by which function or by which line it is done.

  $ffmpeg = '/usr/bin/ffmpeg';
        $video  = $sourceUrl;// the input video file
        $thumbId = uniqid();
        $thumbId .= ".jpg";
        // where you'll save the image
        $image = "uploads/$thumbId";
        // default time to get the image
        $second = 1;
        // get the duration and a random place within that
        $cmd = "$ffmpeg -i $video 2>&1";
        if (preg_match('/Duration: ((\d+):(\d+):(\d+))/s', `$cmd`, $time)) {
            $total = ($time[2] * 3600) + ($time[3] * 60) + $time[4];
            $second = rand(1, ($total - 1));
        }

        // get the screenshot
        $cmd = "$ffmpeg -i $video -deinterlace -an -ss $second -t 00:00:01 -r 1 -y -s 120x90 -vcodec mjpeg -f mjpeg $image 2>&1";
        $return = `$cmd`;
        $thumbLink = "";
1
  • @Dan thanks for edit want to write proper spellings . Commented Feb 9, 2011 at 7:11

1 Answer 1

3

This line executes the command which you stored in the variable $cmd:

    $return = `$cmd`;

In PHP, the backtick is the execution operator, and its use is identical to calling shell_exec.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.