<?php
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
class HandBrakeService
|
|
{
|
|
public function handleVideos($dir = "/Users/shixuesen/Documents/tmp/秀人旗下《YouWu尤物馆》套图及视频写真-TLoB/")
|
|
{
|
|
$files = scandir($dir);
|
|
foreach ($files as $file) {
|
|
if ($file == "." || $file == "..") {
|
|
continue;
|
|
}
|
|
$subDir = implode("/", [$dir, $file]);
|
|
$isDir = is_dir($subDir);
|
|
if ($isDir) {
|
|
$subFiles = scandir($subDir);
|
|
foreach ($subFiles as $subFile) {
|
|
$subPathFile = implode("/", [$subDir, $subFile]);
|
|
if (is_dir($subPathFile) || $subFile == ".DS_Store") {
|
|
continue;
|
|
}
|
|
if (is_file($subPathFile)) {
|
|
$fileInfo = pathinfo($subPathFile);
|
|
dump("fileInfo", $fileInfo);
|
|
if (ends_with($fileInfo["filename"], "-1")) {
|
|
continue;
|
|
}
|
|
if (is_file($fileInfo["dirname"] . '/' .$fileInfo["filename"] . '-1'. '.' . $fileInfo["extension"])) {
|
|
continue;
|
|
}
|
|
$targetFile = $fileInfo["dirname"] . '/' .$fileInfo["filename"] . '-1'. '.' . $fileInfo["extension"];
|
|
dump("targetFile", [$targetFile]);
|
|
// $result = shell_exec("handBrakeCli -Z 'Very Fast 720p30' -i '". $subPathFile ."' -o '". $targetFile . " && echo 'success'");
|
|
$result = shell_exec("handBrakeCli -Z 'Very Fast 720p30' -i '". $subPathFile ."' -o '". $targetFile . "'");
|
|
dump($result);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
print_r($files);
|
|
}
|
|
|
|
}
|