Example #1
0
 public function register()
 {
     $this->opo_config = Configuration::load();
     $vs_external_app_config_path = $this->opo_config->get('external_applications');
     $this->opo_external_app_config = Configuration::load($vs_external_app_config_path);
     $this->ops_path_to_ffmpeg = $this->opo_external_app_config->get('ffmpeg_app');
     $this->ops_mediainfo_path = $this->opo_external_app_config->get('mediainfo_app');
     $this->opb_mediainfo_available = caMediaInfoInstalled($this->ops_mediainfo_path);
     $this->opb_ffmpeg_available = caMediaPluginFFfmpegInstalled($this->ops_path_to_ffmpeg);
     $this->info["INSTANCE"] = $this;
     return $this->info;
 }
/**
 * Extract video duration using MediaInfo. This can be used as a fallback to getID3
 * @param string $ps_filepath
 * @param string|null $ps_mediainfo_path
 *
 * @return float|null
 */
function caExtractVideoFileDurationWithMediaInfo($ps_filepath, $ps_mediainfo_path = null)
{
    if (!$ps_mediainfo_path) {
        $ps_mediainfo_path = caGetExternalApplicationPath('mediainfo');
    }
    if (!caMediaInfoInstalled($ps_mediainfo_path)) {
        return null;
    }
    $va_output = array();
    exec($ps_mediainfo_path . ' --Inform="Video;%Duration/String3%" ' . caEscapeShellArg($ps_filepath), $va_output, $vn_return);
    if (!is_array($va_output) || sizeof($va_output) != 1) {
        return null;
    }
    $va_tmp = explode(':', array_shift($va_output));
    if (sizeof($va_tmp) == 3) {
        // should have hours, minutes, seconds
        return round(intval($va_tmp[0]) * 3600 + intval($va_tmp[1]) * 60 + floatval($va_tmp[2]));
    }
    return null;
}
Example #3
0
 /**
  * Returns array of extracted metadata, key'ed by metadata type or empty array if plugin doesn't support metadata extraction
  *
  * @return Array Extracted metadata
  */
 public function getExtractedMetadata()
 {
     // $this->opa_media_metadata might be extracted by mediainfo at this point or it might not
     // so we do it again. all calls are cached anyway so this should be too bad as far as performance
     if (caMediaInfoInstalled()) {
         return caExtractMetadataWithMediaInfo($this->filepath);
     } else {
         return $this->opa_media_metadata;
     }
 }