예제 #1
0
 /**
  * Returns the raw data provided by ffmpeg about a file.
  *
  * @access public
  * @author Oliver Lillie
  * @param string $file_path 
  * @param boolean $read_from_cache 
  * @return mixed Returns false if no data is returned, otherwise returns the raw data as a string.
  */
 public function getFileRawInformation($file_path, $read_from_cache = true)
 {
     //			convert to realpath
     $real_file_path = $this->_checkMediaFilePath($file_path);
     $cache_key = 'media_parser/' . md5($real_file_path) . '_raw_data';
     if ($read_from_cache === true && ($data = $this->_cacheGet($cache_key, -1)) !== -1) {
         return $data;
     }
     // 			execute the ffmpeg lookup
     $exec = new FfmpegProcess('ffmpeg', $this->_config);
     $raw_data = $exec->setInputPath($real_file_path)->execute()->getBuffer();
     //			check the process for any errors.
     if ($exec->hasError() === true && ($last_line = $exec->getLastLine()) !== 'At least one output file must be specified') {
         throw new FfmpegProcessException('FFmpeg encountered an error when attempting to read `' . $file_path . '`. FFmpeg reported: ' . $last_line, null, $exec);
     }
     // 			check that some data has been obtained
     if (empty($raw_data) === true) {
         // TODO possible error/exception here.
     }
     $this->_cacheSet($cache_key, $raw_data);
     return $raw_data;
 }
예제 #2
0
    /**
     * Returns the raw data provided by ffmpeg about a file.
     *
     * @access public
     * @author Oliver Lillie
     * @param string $file_path 
     * @param boolean $read_from_cache 
     * @return mixed Returns false if no data is returned, otherwise returns the raw data as a string.
     */
    public function getFileRawInformation($file_path, $read_from_cache = true)
    {
        //          convert to realpath
        $real_file_path = $this->_checkMediaFilePath($file_path);
        $cache_key = 'media_parser/' . md5($real_file_path) . '_raw_data';
        if ($read_from_cache === true && ($data = $this->_cacheGet($cache_key, -1)) !== -1) {
            return $data;
        }
        $isWindowsPlatform = defined('PHP_WINDOWS_VERSION_BUILD');
        //          execute the ffmpeg lookup
        $exec = new FfmpegProcess('ffmpeg', $this->_config);
        $exec_cmd = $exec->setInputPath($real_file_path)->addCommand('-af', 'volumedetect')->addCommand('-f', 'NULL');
        if ($isWindowsPlatform) {
            $exec_cmd = $exec_cmd->addCommand('NUL');
        } else {
            $exec_cmd = $exec_cmd->addCommand('/dev/null');
        }
        $raw_data = $exec_cmd->execute()->getBuffer();
        //          check the process for any errors.
        if ($exec->hasError() === true && ($last_line = $exec->getLastLine()) !== 'At least one output file must be specified') {
            throw new FfmpegProcessException('FFmpeg encountered an error when attempting to read `' . $file_path . '`. FFmpeg reported: 
' . $raw_data, null, $exec);
        }
        //          check that some data has been obtained
        if (empty($raw_data) === true) {
            // TODO possible error/exception here.
        }
        $this->_cacheSet($cache_key, $raw_data);
        return $raw_data;
    }
예제 #3
0
 /**
  * Returns the raw data provided by ffmpeg about a file.
  *
  * @access public
  * @author Oliver Lillie
  * @param string $file_path 
  * @param boolean $read_from_cache 
  * @return mixed Returns false if no data is returned, otherwise returns the raw data as a string.
  */
 public function getFileRawInformation($file_path, $read_from_cache = true)
 {
     //			convert to realpath
     $real_file_path = $this->_checkMediaFilePath($file_path);
     $cache_key = 'media_prober/' . md5($real_file_path) . '_raw_data';
     if ($read_from_cache === true && ($data = $this->_cacheGet($cache_key, -1)) !== -1) {
         return $data;
     }
     // 			execute the ffmpeg lookup
     $exec = new FfmpegProcess('ffprobe', $this->_config);
     $raw_data = $exec->setInputPath($real_file_path)->addCommand('-show_streams')->addCommand('-show_format')->execute()->getBuffer();
     //			check the process for any errors.
     if ($exec->hasError() === true) {
         throw new FfmpegProcessException('FFprobe encountered an error when attempting to read `' . $file_path . '`. FFprobe reported: ' . $exec->getLastLine(), null, $exec);
     }
     // 			check that some data has been obtained
     $data = array();
     if (empty($raw_data) === true) {
         // TODO possible error/exception here.
     }
     $this->_cacheSet($cache_key, $data);
     return $data;
 }