From 138cb94c7939e3c7c018fb9bc92640548fa6c810 Mon Sep 17 00:00:00 2001 From: cbping <452775680@qq.com> Date: Wed, 29 Aug 2018 15:25:50 +0800 Subject: [PATCH] =?UTF-8?q?doc(*):=E6=96=87=E6=A1=A3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FFMpegPush/Command/Command.php | 103 +++++++- src/FFMpegPush/Command/CommandInterface.php | 7 + src/FFMpegPush/Command/FFMpegCommand.php | 6 + src/FFMpegPush/Command/FFProbeCommand.php | 260 +++++++++++++++++++- src/FFMpegPush/FFProbe/Format.php | 6 + src/FFMpegPush/FFProbe/Stream.php | 6 + 6 files changed, 376 insertions(+), 12 deletions(-) diff --git a/src/FFMpegPush/Command/Command.php b/src/FFMpegPush/Command/Command.php index ab394d5..150fc63 100644 --- a/src/FFMpegPush/Command/Command.php +++ b/src/FFMpegPush/Command/Command.php @@ -1,4 +1,5 @@ + * array(), // 可执行命令,数组类型。只有一个有效,优先级和数组顺序一致 * "timeout"=>"", // 默认一天。如果非法格式,也就是非数字类型,都统一采用默认值 * ) + * + * * @param $logger * @throws ConfigException * @throws ExecutableNotFoundException @@ -60,8 +99,8 @@ public function __construct($config = array(), LoggerInterface $logger = null) $this->config->set('timeout', self::TimeOut); } - $finder = new ExecutableFinder(); - $binary = null; + $finder = new ExecutableFinder(); + $binary = null; $binaries = $this->config->get('binaries'); $binaries = is_array($binaries) ? $binaries : array($binaries); @@ -70,11 +109,11 @@ public function __construct($config = array(), LoggerInterface $logger = null) $binary = $candidate; break; } - if (null !== $binary = $finder->find($candidate)) { + if (null!==$binary = $finder->find($candidate)) { break; } } - if (null === $binary) { + if (null===$binary) { throw new ExecutableNotFoundException(sprintf( 'Executable not found, proposed : %s', implode(', ', $binaries) )); @@ -82,7 +121,7 @@ public function __construct($config = array(), LoggerInterface $logger = null) $this->binary = $binary; - if (null === $logger) { + if (null===$logger) { $logger = new Logger(__NAMESPACE__ . ' logger'); $logger->pushHandler(new NullHandler()); } @@ -90,6 +129,8 @@ public function __construct($config = array(), LoggerInterface $logger = null) } /** + * 初始进程句柄 + * * @param $command * @return Process */ @@ -99,12 +140,14 @@ protected function initProcess($command) $processBuilder = ProcessBuilder::create($command) ->setPrefix($this->binary) ->setTimeout($this->config->get('timeout')); - $this->process = $processBuilder->getProcess(); + $this->process = $processBuilder->getProcess(); } return $this->process; } /** + * 获取底层命令执行进程句柄 + * * @return Process */ public function getProcess() @@ -113,6 +156,8 @@ public function getProcess() } /** + * 添加监听者 + * * @param ListenerInterface $listener * @return $this */ @@ -123,6 +168,8 @@ public function addListener(ListenerInterface $listener) } /** + * 获取所有监听者 + * * @return ListenerInterface[] */ public function getListeners() @@ -131,6 +178,8 @@ public function getListeners() } /** + * 执行命令 + * * @param $command * @return string */ @@ -166,6 +215,8 @@ public function stop() } /** + * 返回监听回调函数体 + * * @param $listeners * @return \Closure */ @@ -178,6 +229,11 @@ private function buildCallback($listeners) }; } + /** + * 获取执行结果代码 + * + * @return int|null + */ public function getExitCode() { if ($this->process) { @@ -186,6 +242,11 @@ public function getExitCode() return null; } + /** + * 获取执行命令具体文本信息 + * + * @return null|string + */ public function getCommandLine() { if ($this->process) { @@ -194,6 +255,11 @@ public function getCommandLine() return null; } + /** + * 获取执行结果代码文本信息 + * + * @return null|string + */ public function getExitCodeText() { if ($this->process) { @@ -202,6 +268,11 @@ public function getExitCodeText() return null; } + /** + * 获取错误输出内容 + * + * @return null|string + */ public function getErrorOutput() { if ($this->process) { @@ -210,6 +281,11 @@ public function getErrorOutput() return null; } + /** + * 获取输出内容 + * + * @return null|string + */ public function getOutput() { if ($this->process) { @@ -218,6 +294,11 @@ public function getOutput() return null; } + /** + * 是否执行成功 + * + * @return bool|null + */ public function isSuccessful() { if ($this->process) { diff --git a/src/FFMpegPush/Command/CommandInterface.php b/src/FFMpegPush/Command/CommandInterface.php index 8047dcf..e15cf71 100644 --- a/src/FFMpegPush/Command/CommandInterface.php +++ b/src/FFMpegPush/Command/CommandInterface.php @@ -1,7 +1,14 @@ name = 'FFProbe'; @@ -29,16 +42,261 @@ public function __construct($configuration = array(), LoggerInterface $logger = $this->dataHandler = new DataHandler(); } + /** + * @param array $configuration + * @param LoggerInterface|null $logger + * @return static + */ public static function create($configuration = array(), LoggerInterface $logger = null) { return new static ($configuration, $logger); } + /** + * 获取多媒体的封装格式 + * + * @param $pathfile + * @return Format|StreamCollection + */ public function format($pathfile) { return $this->probe($pathfile, '-show_format', static::TYPE_FORMAT); } + /** + * 查看多媒体文件中的流信息 + * + * 如图所示,可以看到流的信息: + * + *
+ * + * 属性 + * + * |
+ *
+ * + * 说明 + * + * |
+ *
+ * + * 值 + * + * |
+ *
+ * + * Index + * + * |
+ *
+ * + * 流所在的索引区域 + * + * |
+ *
+ * + * 0 + * + * |
+ *
+ * + * Codec_name + * + * |
+ *
+ * + * 编码名 + * + * |
+ *
+ * + * Mpeg4 + * + * |
+ *
+ * + * Codec_long_name + * + * |
+ *
+ * + * 编码全名 + * + * |
+ *
+ * + * MPEG-4 part 2 + * + * |
+ *
+ * + * profile + * + * |
+ *
+ * + * 编码的profile + * + * |
+ *
+ * + * Simple Profile + * + * |
+ *
+ * + * level + * + * |
+ *
+ * + * 编码的level + * + * |
+ *
+ * + * 1 + * + * |
+ *
+ * + * Has_b_frames + * + * |
+ *
+ * + * 包含B帧信息 + * + * |
+ *
+ * + * 0 + * + * |
+ *
+ * + * Codec_tyoe + * + * |
+ *
+ * + * 编码类型 + * + * |
+ *
+ * + * Video + * + * |
+ *
+ * + * Codec_time_base + * + * |
+ *
+ * + * 编码的时间戳计算基础单位 + * + * |
+ *
+ * + * 1/15 + * + * |
+ *
+ * + * Pix_fmt + * + * |
+ *
+ * + * 图像显示图像色彩格式 + * + * |
+ *
+ * + * Yuv420p + * + * |
+ *
+ * + * Coded_width + * + * |
+ *
+ * + * 图像的宽度 + * + * |
+ *
+ * + * 608 + * + * |
+ *
+ * + * Coded_height + * + * |
+ *
+ * + * 图像的高度 + * + * |
+ *
+ * + * 320 + * + * |
+ *
+ * + * Codec_tag_string + * + * |
+ *
+ * + * 编码的标签数据 + * + * |
+ *
+ * + * Mp4v + * + * |
+ *