/** * Ask the user is they wish to overwrite an existing file * * @param string $path The path that already exists */ public function doesTheUserWantToOverwriteExistingFile($path) { if (false !== $this->command->confirm("This form validator at:\n" . $path . "\nalready exists: Do you want to overwrite it? (y|N)", false)) { // The user wants to overwrite the file so fire the process again with the force option set to true $this->command->fire(true); exit; } $this->command->error('You have chosen NOT to overwrite the file...Good choice!'); exit; }
protected function __new__($file_path) { $this->cmd = def("arbo.io.FFmpeg@cmd", "/usr/local/bin/ffmpeg"); $info = Command::error(sprintf("%s -i %s", $this->cmd, $file_path)); $file = new File($file_path); $this->name = $file->oname(); $this->ext = $file->ext(); $this->filename = $file_path; $this->framerate = preg_match("/frame rate: .+ -> ?([\\d\\.]+)/", $info, $match) ? (double) $match[1] : null; $this->bitrate = preg_match("/bitrate: (\\d+)/", $info, $match) ? (double) $match[1] : null; $this->duration = preg_match("/Duration: ([\\d\\:\\.]+)/", $info, $match) ? Date::parse_time($match[1]) : null; if (preg_match("/Video: (.+)/", $info, $match)) { $video = explode(",", $match[1]); if (isset($video[0])) { $this->video_codec = trim($video[0]); } if (isset($video[1])) { $this->format = trim($video[1]); } if (isset($video[2])) { list($this->width, $this->height) = explode("x", trim($video[2])); if (preg_match("/(\\d+) .+DAR (\\d+\\:\\d+)/", $this->height, $match)) { list(, $this->height, $this->aspect) = $match; } } if (empty($this->aspect) && isset($video[3])) { $this->aspect = preg_match("/DAR (\\d+\\:\\d+)/", $video[3], $match) ? $match[1] : null; } } if (preg_match("/Audio: (.+)/", $info, $match)) { $audio = explode(",", $match[1]); if (isset($audio[0])) { $this->audio_codec = trim($audio[0]); } if (isset($audio[1])) { $this->samplerate = preg_match("/\\d+/", $audio[1], $match) ? $match[0] : null; } } $this->frame_count = ceil($this->duration * $this->framerate); }