Beispiel #1
0
 /** 
  *
  */
 public function writeClip($ps_filepath, $ps_start, $ps_end, $pa_options = null)
 {
     if (!$this->opb_ffmpeg_available) {
         return false;
     }
     $o_tc = new TimecodeParser();
     $vn_start = $vn_end = null;
     if ($o_tc->parse($ps_start)) {
         $vn_start = $o_tc->getSeconds();
     }
     if ($o_tc->parse($ps_end)) {
         $vn_end = $o_tc->getSeconds();
     }
     if (!$vn_start || !$vn_end) {
         return null;
     }
     if ($vn_start >= $vn_end) {
         return null;
     }
     $vn_duration = $vn_end - $vn_start;
     exec($this->ops_path_to_ffmpeg . " -i " . caEscapeShellArg($this->filepath) . " -f mp4 -vcodec libx264 -acodec mp3 -t {$vn_duration}  -y -ss {$vn_start} " . caEscapeShellArg($ps_filepath) . (caGetOSFamily() == OS_POSIX ? " 2> /dev/null" : ""), $va_output, $vn_return);
     if ($vn_return != 0) {
         @unlink($filepath . "." . $ext);
         $this->postError(1610, _t("Error extracting clip from %1 to %2: %3", $ps_start, $ps_end, join("; ", $va_output)), "WLPlugVideo->writeClip()");
         return false;
     }
     return true;
 }
Beispiel #2
0
 /** 
  *
  */
 public function writeClip($ps_filepath, $ps_start, $ps_end, $pa_options = null)
 {
     $o_tc = new TimecodeParser();
     $vn_start = $vn_end = 0;
     if ($o_tc->parse($ps_start)) {
         $vn_start = (double) $o_tc->getSeconds();
     }
     if ($o_tc->parse($ps_end)) {
         $vn_end = (double) $o_tc->getSeconds();
     }
     if ($vn_end == 0) {
         return null;
     }
     if ($vn_start >= $vn_end) {
         return null;
     }
     $vn_duration = $vn_end - $vn_start;
     exec($this->ops_path_to_ffmpeg . " -i " . caEscapeShellArg($this->filepath) . " -f mp3 -t {$vn_duration}  -y -ss {$vn_start} " . caEscapeShellArg($ps_filepath), $va_output, $vn_return);
     if ($vn_return != 0) {
         @unlink($filepath . "." . $ext);
         $this->postError(1610, _t("Error extracting clip from %1 to %2: %3", $ps_start, $ps_end, join("; ", $va_output)), "WLPlugAudio->writeClip()");
         return false;
     }
     return true;
 }
Beispiel #3
0
 public function &writePreviews($ps_filepath, $pa_options)
 {
     if (!(bool) $this->opo_config->get("video_preview_generate_frames")) {
         return false;
     }
     if (!isset($pa_options['outputDirectory']) || !$pa_options['outputDirectory'] || !file_exists($pa_options['outputDirectory'])) {
         if (!($vs_tmp_dir = $this->opo_config->get("taskqueue_tmp_directory"))) {
             // no dir
             return false;
         }
     } else {
         $vs_tmp_dir = $pa_options['outputDirectory'];
     }
     $o_tc = new TimecodeParser();
     if (($vn_min_number_of_frames = $pa_options['minNumberOfFrames']) < 1) {
         $vn_min_number_of_frames = 0;
     }
     if (($vn_max_number_of_frames = $pa_options['maxNumberOfFrames']) < 1) {
         $vn_max_number_of_frames = 100;
     }
     $vn_duration = $this->properties["duration"];
     if (!($vn_frame_interval = $o_tc->parse($pa_options['frameInterval']) ? $o_tc->getSeconds() : 0)) {
         $vn_frame_interval = 30;
     }
     if (!($vn_start_at = $o_tc->parse($pa_options['startAtTime']) ? $o_tc->getSeconds() : 0)) {
         $vn_start_at = 0;
     }
     if (!($vn_end_at = $o_tc->parse($pa_options['endAtTime']) ? $o_tc->getSeconds() : 0)) {
         $vn_end_at = 0;
     }
     if (($vn_previewed_duration = $vn_duration - $vn_start_at - $vn_end_at) < 0) {
         $vn_previewed_duration = $vn_duration;
         $vn_start_at = $vn_end_at = 0;
     }
     if ($vn_frame_interval > $vn_previewed_duration) {
         $vn_frame_interval = $vn_previewed_duration;
     }
     $vn_preview_width = isset($pa_options['width']) && (int) $pa_options['width'] > 0 ? (int) $pa_options['width'] : 320;
     $vn_preview_height = isset($pa_options['height']) && (int) $pa_options['height'] > 0 ? (int) $pa_options['height'] : 320;
     $vn_s = $vn_start_at;
     $vn_e = $vn_duration - $vn_end_at;
     $vn_num_frames = $vn_previewed_duration / $vn_frame_interval;
     if ($vn_num_frames < $vn_min_number_of_frames) {
         $vn_frame_interval = $vn_previewed_duration / $vn_min_number_of_frames;
         $vn_num_frames = $vn_min_number_of_frames;
         $vn_previewed_duration = $vn_num_frames * $vn_frame_interval;
     }
     if ($vn_num_frames > $vn_max_number_of_frames) {
         $vn_frame_interval = $vn_previewed_duration / $vn_max_number_of_frames;
         $vn_num_frames = $vn_max_number_of_frames;
         $vn_previewed_duration = $vn_num_frames * $vn_frame_interval;
     }
     $vs_freq = 1 / $vn_frame_interval;
     $vs_output_file_prefix = tempnam($vs_tmp_dir, 'caQuicktimeVRPreview');
     $vs_output_file = $vs_output_file_prefix . '%05d.jpg';
     exec($this->ops_path_to_ffmpeg . " -i " . caEscapeShellArg($this->filepath) . " -f image2 -r " . $vs_freq . " -ss {$vn_s} -t {$vn_previewed_duration} -s " . $vn_preview_width . "x" . $vn_preview_height . " -y " . caEscapeShellArg($vs_output_file), $va_output, $vn_return);
     $vn_i = 1;
     $va_files = array();
     while (file_exists($vs_output_file_prefix . sprintf("%05d", $vn_i) . '.jpg')) {
         // add frame to list
         $va_files['' . sprintf("%4.2f", ($vn_i - 1) * $vn_frame_interval + $vn_s) . 's'] = $vs_output_file_prefix . sprintf("%05d", $vn_i) . '.jpg';
         $vn_i++;
     }
     if (!sizeof($va_files)) {
         $this->postError(1610, _t("Couldn't not write video preview frames to tmp directory (%1)", $vs_tmp_dir), "WLPlugQuicktimeVR->write()");
     }
     @unlink($vs_output_file_prefix);
     return $va_files;
 }
Beispiel #4
0
 /** 
  *
  */
 public function writeClip($ps_filepath, $ps_start, $ps_end, $pa_options = null)
 {
     if (!caMediaPluginFFmpegInstalled()) {
         return false;
     }
     $o_tc = new TimecodeParser();
     $vn_start = $vn_end = null;
     if ($o_tc->parse($ps_start)) {
         $vn_start = $o_tc->getSeconds();
     }
     if ($o_tc->parse($ps_end)) {
         $vn_end = $o_tc->getSeconds();
     }
     if (!$vn_start || !$vn_end) {
         return null;
     }
     if ($vn_start >= $vn_end) {
         return null;
     }
     $vn_duration = $vn_end - $vn_start;
     exec(caGetExternalApplicationPath('ffmpeg') . " -i " . caEscapeShellArg($this->filepath) . " -f mp4 -vcodec libx264 -acodec mp3 -t {$vn_duration}  -y -ss {$vn_start} " . caEscapeShellArg($ps_filepath) . (caIsPOSIX() ? " 2> /dev/null" : ""), $va_output, $vn_return);
     if ($vn_return != 0) {
         @unlink($ps_filepath);
         $this->postError(1610, _t("Error extracting clip from %1 to %2: %3", $ps_start, $ps_end, join("; ", $va_output)), "WLPlugVideo->writeClip()");
         return false;
     }
     return true;
 }