/** * Saves any changes to the media file to the given save path. * IMPORTANT! This save does NOT block PHP execution, meaning that once called, the PHP interpretter * will IMMEDIATELY continue. PHP will continue, in all likelyhood, exit before the ffmpeg has * completed the transcoding of any output. * * If you need to monitor the output for completion or processing then you can supplied a progress handler to * return information about the process. * * @access public * @author Oliver Lillie * @param string $save_path * @param Format $output_format * @param string $overwrite * @return boolean If the command is sent without error then true is returned, otherwise false. * The last error message is set to Media->last_error_message. A full list of error messages is * available through Media->error_messages. */ public function saveNonBlocking($save_path = null, Format $output_format = null, $overwrite = self::OVERWRITE_FAIL, ProgressHandlerAbstract &$progress_handler = null) { // check to see if the blocking mode has already been set to true. If it has we cannot save // non-blocking and must trigger error. if ($this->_blocking === true) { throw new \LogicException('The blocking mode has been enabled by a function that you have enabled, or a Format that you have supplied. As a result you cannot use saveNonBlocking() and must use the blocking save method save() instead.'); } // set the non blocking of the exec process $this->_blocking = false; // set the progress handler if ($progress_handler !== null) { // because only certain types of handlers are compatible with non blocking saves we need to check for compatibility. if ($progress_handler->getNonBlockingCompatibilityStatus() === false) { throw new \LogicException('The progress handler given is not compatible with a non blocking save. This typically means that you have supplied a callback function in the constructor of the progress handler. Any progress handler with a supplied callback blocks PHP. Instead you should call $handler->probe() after the saveNonBlocking function call to get the progress of the encode.'); } } return $this->save($save_path, $output_format, $overwrite, $progress_handler); }
public function attachFfmpegProcess(FfmpegProcess $process, $temp_directory) { parent::attachFfmpegProcess($process, $temp_directory); $this->_progress_file = tempnam($this->_config->temp_directory, 'phpvideotoolkit_progress_'); $this->_ffmpeg_process->addCommand('-progress', $this->_progress_file); }
public function attachFfmpegProcess(FfmpegProcess $process, Config $config = null) { parent::attachFfmpegProcess($process, $config); $this->_progress_file = tempnam($this->_config->temp_directory, 'phpvideotoolkit_progress_' . time() . '_'); $this->_input = $this->_ffmpeg_process->getAllInput(); $this->_output = $this->_ffmpeg_process->getAllOutput(); $this->_ffmpeg_process->addCommand('-progress', $this->_progress_file); }