diff --git a/lib/Command/VideoSetup.php b/lib/Command/VideoSetup.php index e7daefd7..752858c9 100644 --- a/lib/Command/VideoSetup.php +++ b/lib/Command/VideoSetup.php @@ -120,9 +120,7 @@ class VideoSetup extends Command $output->writeln(''); $output->writeln('Do you want to enable transcoding and HLS? [Y/n]'); - $handle = fopen('php://stdin', 'r'); - $line = fgets($handle); - if ('n' === trim($line)) { + if ('n' === trim(fgets(fopen('php://stdin', 'r')))) { $this->config->setSystemValue('memories.no_transcode', true); $output->writeln('Transcoding and HLS are now disabled'); @@ -136,6 +134,22 @@ class VideoSetup extends Command $this->config->setSystemValue('memories.no_transcode', false); $output->writeln('Transcoding and HLS are now enabled!'); + // Check for VAAPI + $output->writeln("\nChecking for QSV (/dev/dri/renderD128)"); + if (file_exists('/dev/dri/renderD128')) { + $output->writeln('QSV is available. Do you want to enable it? [Y/n]'); + + if ('n' === trim(fgets(fopen('php://stdin', 'r')))) { + $this->config->setSystemValue('memories.qsv', false); + $output->writeln('QSV is now disabled'); + } else { + $this->config->setSystemValue('memories.qsv', true); + } + } else { + $output->writeln('QSV is not available'); + $this->config->setSystemValue('memories.qsv', false); + } + return 0; } @@ -150,9 +164,7 @@ class VideoSetup extends Command { $output->writeln('Without transcoding, video playback may be slow and limited'); $output->writeln('Do you want to disable transcoding and HLS streaming? [y/N]'); - $handle = fopen('php://stdin', 'r'); - $line = fgets($handle); - if ('y' !== trim($line)) { + if ('y' !== trim(fgets(fopen('php://stdin', 'r')))) { $output->writeln('Aborting'); return 1; diff --git a/lib/Controller/VideoController.php b/lib/Controller/VideoController.php index 28f7b7d0..f1332cef 100644 --- a/lib/Controller/VideoController.php +++ b/lib/Controller/VideoController.php @@ -89,11 +89,18 @@ class VideoController extends ApiBase return new JSONResponse(['message' => 'Transcoder not configured'], Http::STATUS_INTERNAL_SERVER_ERROR); } + // Check for environment variables + $vaapi = $this->config->getSystemValue('memories.qsv', false); + $env = ''; + if ($vaapi) { + $env .= 'VAAPI=1 '; + } + // Check if already running exec('ps a | grep go-transcode | grep -v grep', $procs); if (0 === \count($procs)) { shell_exec("mkdir -p {$tmpDir}/transcoder"); // php func has some weird problems - shell_exec("nohup {$transcoder} serve --config {$tConfig} > {$tmpDir}/transcoder/run.log 2>&1 & > /dev/null"); + shell_exec("{$env} nohup {$transcoder} serve --config {$tConfig} > {$tmpDir}/transcoder/run.log 2>&1 & > /dev/null"); } // wait for 2s and try again