/** * poファイルからmoファイルを作成する * @param string $po_filename 読み込むpoファイルのパス * @param string $mo_filename 出力するmoファイルのパス * @return string output path */ public static function generate_mo($po_filename, $mo_filename = null) { if (!is_file($po_filename)) { throw new InvalidArgumentException($po_filename . ": No such file"); } $file = new File($po_filename); $output_path = empty($mo_filename) ? $file->directory() . $file->oname() . ".mo" : $mo_filename; $po_list = self::po_read($po_filename); $count = sizeof($po_list); $ids = implode("", array_keys($po_list)) . ""; $keyoffset = 28 + 16 * $count; $valueoffset = $keyoffset + strlen($ids); $value_src = ""; $output_src = pack('Lllllll', 0x950412de, 0, $count, 28, 28 + $count * 8, 0, 0); $output_values = array(); foreach ($po_list as $id => $values) { $len = strlen($id); $output_src .= pack("l", $len); $output_src .= pack("l", $keyoffset); $keyoffset += $len + 1; $value = implode("", $values); $len = strlen($value); $value_src .= pack("l", $len); $value_src .= pack("l", $valueoffset); $valueoffset += $len + 1; $output_values[] = $value; } $output_src .= $value_src; $output_src .= $ids; $output_src .= implode("", $output_values) . ""; File::write($output_path, $output_src); return $output_path; }
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); }
<?php /** * 更新を監視してmxmlcする */ include_once dirname(__FILE__) . "/__settings__.php"; import("core.Command"); import("core.File"); import("core.Request"); $req = new Request(); $cmd = new Command(); $cmd->open(File::absolute(def("mxmlc@flex_bin"), "fcsh"), null, work_path("mxmlc_error")); $src = new File(path("flex/src/" . $req->inVars("f", "index.mxml"))); $bin = path("flex/bin/" . $src->oname() . ".swf"); $lib = path("flex/lib/"); $rsl = path("flex/rsl/"); while (true) { $lib_last_update = $src_last_update = $rsl_last_update = $id = 0; $mxmlc = sprintf("mxmlc -output %s --file-specs %s ", $bin, $src); if ($lib_last_update < ($lib_update = File::last_update($lib, true))) { $lib_last_update = $lib_update; $files = array(); foreach (File::ls($lib) as $f) { $files[] = $f->fullname(); } $mxmlc .= "-library-path+=" . implode(",", $files) . " "; } if ($rsl_last_update < ($rsl_update = File::last_update($rsl, true))) { $rsl_last_update = $rsl; $files = array(); foreach (File::ls($rsl) as $f) {