From 8ff3bf0f4ddf3645ab64d3abc2d033666051dabd Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 31 Jan 2023 19:31:39 -0800 Subject: [PATCH] video: create go-vod temp dir (fix #353) --- lib/Controller/VideoController.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/Controller/VideoController.php b/lib/Controller/VideoController.php index 1fd10230..9f26b5fd 100644 --- a/lib/Controller/VideoController.php +++ b/lib/Controller/VideoController.php @@ -222,29 +222,39 @@ class VideoController extends ApiBase } // Check for environment variables - $env = ''; + $env = []; // QSV with VAAPI $vaapi = $this->config->getSystemValue('memories.qsv', false); if ($vaapi) { - $env .= 'VAAPI=1 '; + array_push($env, 'VAAPI=1'); } // NVENC $nvenc = $this->config->getSystemValue('memories.nvenc', false); if ($nvenc) { - $env .= 'NVENC=1 '; + array_push($env, 'NVENC=1'); } // Paths $ffmpegPath = $this->config->getSystemValue('memories.ffmpeg_path', 'ffmpeg'); $ffprobePath = $this->config->getSystemValue('memories.ffprobe_path', 'ffprobe'); - $tmpPath = $this->config->getSystemValue('memories.tmp_path', sys_get_temp_dir()); - $env .= "FFMPEG='{$ffmpegPath}' FFPROBE='{$ffprobePath}' GOVOD_TEMPDIR='{$tmpPath}/go-vod' "; + array_push($env, "FFMPEG='{$ffmpegPath}'"); + array_push($env, "FFPROBE='{$ffprobePath}'"); + + // (Re-)create Temp dir + $instanceId = $this->config->getSystemValue('instanceid', 'default'); + $defaultTmp = sys_get_temp_dir() . '/go-vod/' . $instanceId; + $tmpPath = $this->config->getSystemValue('memories.tmp_path', $defaultTmp); + shell_exec("rm -rf '{$tmpPath}'"); + mkdir($tmpPath, 0755, true); + + array_push($env, "GOVOD_TEMPDIR='{$tmpPath}'"); // Check if already running + $env = implode(' ', $env); \OCA\Memories\Util::pkill($transcoder); - shell_exec("{$env} nohup {$transcoder} > {$tmpPath}/go-vod.log 2>&1 & > /dev/null"); + shell_exec("{$env} nohup {$transcoder} > '{$tmpPath}.log' 2>&1 & > /dev/null"); // wait for 1s and try again sleep(1);