video: create go-vod temp dir (fix #353)

pull/391/head
Varun Patil 2023-01-31 19:31:39 -08:00
parent 883ecb2f29
commit 8ff3bf0f4d
1 changed files with 16 additions and 6 deletions

View File

@ -222,29 +222,39 @@ class VideoController extends ApiBase
} }
// Check for environment variables // Check for environment variables
$env = ''; $env = [];
// QSV with VAAPI // QSV with VAAPI
$vaapi = $this->config->getSystemValue('memories.qsv', false); $vaapi = $this->config->getSystemValue('memories.qsv', false);
if ($vaapi) { if ($vaapi) {
$env .= 'VAAPI=1 '; array_push($env, 'VAAPI=1');
} }
// NVENC // NVENC
$nvenc = $this->config->getSystemValue('memories.nvenc', false); $nvenc = $this->config->getSystemValue('memories.nvenc', false);
if ($nvenc) { if ($nvenc) {
$env .= 'NVENC=1 '; array_push($env, 'NVENC=1');
} }
// Paths // Paths
$ffmpegPath = $this->config->getSystemValue('memories.ffmpeg_path', 'ffmpeg'); $ffmpegPath = $this->config->getSystemValue('memories.ffmpeg_path', 'ffmpeg');
$ffprobePath = $this->config->getSystemValue('memories.ffprobe_path', 'ffprobe'); $ffprobePath = $this->config->getSystemValue('memories.ffprobe_path', 'ffprobe');
$tmpPath = $this->config->getSystemValue('memories.tmp_path', sys_get_temp_dir()); array_push($env, "FFMPEG='{$ffmpegPath}'");
$env .= "FFMPEG='{$ffmpegPath}' FFPROBE='{$ffprobePath}' GOVOD_TEMPDIR='{$tmpPath}/go-vod' "; 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 // Check if already running
$env = implode(' ', $env);
\OCA\Memories\Util::pkill($transcoder); \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 // wait for 1s and try again
sleep(1); sleep(1);