@ -6,19 +6,22 @@ namespace App\Services;
class HandBrakeService
class HandBrakeService
{
{
public function handleVideos ( $dir = " /Users/shixuesen/Documents/tmp/福利姬 软软趴在床单上-铃木美咲(Misaki Suzuki) 合集-TLoB/ " )
public function handleVideos ( $dir = " N: \\ v \\ 91麻豆国产原创剧情片 \\ " )
{
{
setlocale ( LC_ALL , [ 'zh_CN.gbk' , 'zh_CN.gb2312' , 'zh_CN.gb18030' ]);
$files = scandir ( $dir );
$files = scandir ( $dir );
// $files = array_slice($files, 128);
foreach ( $files as $file ) {
foreach ( $files as $file ) {
if ( $file == " . " || $file == " .. " ) {
if ( $file == " . " || $file == " .. " ) {
continue ;
continue ;
}
}
$subDir = implode ( " / " , [ $dir , $file ]);
$subDir = implode ( " \\ " , [ $dir , $file ]);
$isDir = is_dir ( $subDir );
$isDir = is_dir ( $subDir );
if ( $isDir ) {
if ( $isDir ) {
$subFiles = scandir ( $subDir );
$subFiles = scandir ( $subDir );
foreach ( $subFiles as $subFile ) {
foreach ( $subFiles as $subFile ) {
$subPathFile = implode ( " / " , [ $subDir , $subFile ]);
$subPathFile = implode ( " \\ " , [ $subDir , $subFile ]);
if ( is_dir ( $subPathFile ) || $subFile == " .DS_Store " ) {
if ( is_dir ( $subPathFile ) || $subFile == " .DS_Store " ) {
continue ;
continue ;
}
}
@ -32,13 +35,17 @@ class HandBrakeService
if ( ends_with ( $fileInfo [ " filename " ], " -1 " )) {
if ( ends_with ( $fileInfo [ " filename " ], " -1 " )) {
continue ;
continue ;
}
}
if ( is_file ( $fileInfo [ " dirname " ] . '/' . $fileInfo [ " filename " ] . '-1' . '.' . $fileInfo [ " extension " ])) {
$subPathFileArr = explode ( " . " . $fileInfo [ " extension " ], $subPathFile );
if ( is_file ( $subPathFileArr [ 0 ] . '-1' . '.' . $fileInfo [ " extension " ])) {
unlink ( $subPathFile );
continue ;
continue ;
}
}
$targetFile = $fileInfo [ " dirname " ] . '/' . $fileInfo [ " filename " ] . '-1' . '.' . $fileInfo [ " extension " ];
dump ( " targetFile " , [ $targetFile ]);
$targetFile = $subPathFileArr [ 0 ] . '-1' . '.' . $fileInfo [ " extension " ];
// $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 . " && echo 'success'");
$result = shell_exec ( " handBrakeCli -Z 'Very Fast 720p30' -i ' " . $subPathFile . " ' -o ' " . $targetFile . " ' " );
// dump("D:\Software\HandBrakeCLI-1.3.3-win-x86_64\HandBrakeCLI.exe -Z \"Very Fast 720p30\" -i '". $subPathFile ."' -o '". $targetFile . "'");exit;
file_put_contents ( " video.ps1 " , iconv ( 'UTF-8' , 'GBK' , " D: \ Software \ HandBrakeCLI-1.3.3-win-x86_64 \ HandBrakeCLI.exe -Z \" Very Fast 720p30 \" -i ' " . $subPathFile . " ' -o ' " . $targetFile . " ' " ));
// $result = shell_exec("D:\Software\HandBrakeCLI-1.3.3-win-x86_64\HandBrakeCLI.exe -Z \"Very Fast 720p30\" -i '". $subPathFile ."' -o '". $targetFile . "");
$result = shell_exec ( 'powershell.exe -executionpolicy bypass -NoProfile -File ".\video.ps1"' );
dump ( $result );
dump ( $result );
}
}