public function getFrame($frame_number = false, $frame_rate = false) { try { $toolkit = new PHPVideoToolkit(PHPVIDEOTOOLKIT_TEMP_DIRECTORY); $tmp_name = $toolkit->unique() . '-%index.jpg'; // extract the frame $toolkit->extractFrame($frame_number, $frame_rate, '%ft'); $toolkit->setOutput(PHPVIDEOTOOLKIT_TEMP_DIRECTORY, $tmp_name, PHPVideoToolkit::OVERWRITE_EXISTING); $result = $this->_toolkit->execute(false, true); // check the image has been outputted if ($result !== PHPVideoToolkit::RESULT_OK) { return false; } $temp_output = array_shift(array_flip($toolkit->getLastOutput())); print_r($temp_output); $gd_img = imagecreatefromjpeg($temp_output); $ffmpeg_frame_time = $toolkit->formatTimecode($frame_number, '%ft', '%hh:%mm:%ss.%ms', $frame_rate); } catch (Exception $e) { echo $e; } return new ffmpeg_frame($gd_img, $ffmpeg_frame_time); }