Add QSV env var

pull/221/head
Varun Patil 2022-11-09 06:21:17 -08:00
parent c10ad711f7
commit 9d5a431c07
2 changed files with 26 additions and 7 deletions

View File

@ -120,9 +120,7 @@ class VideoSetup extends Command
$output->writeln(''); $output->writeln('');
$output->writeln('Do you want to enable transcoding and HLS? [Y/n]'); $output->writeln('Do you want to enable transcoding and HLS? [Y/n]');
$handle = fopen('php://stdin', 'r'); if ('n' === trim(fgets(fopen('php://stdin', 'r')))) {
$line = fgets($handle);
if ('n' === trim($line)) {
$this->config->setSystemValue('memories.no_transcode', true); $this->config->setSystemValue('memories.no_transcode', true);
$output->writeln('<error>Transcoding and HLS are now disabled</error>'); $output->writeln('<error>Transcoding and HLS are now disabled</error>');
@ -136,6 +134,22 @@ class VideoSetup extends Command
$this->config->setSystemValue('memories.no_transcode', false); $this->config->setSystemValue('memories.no_transcode', false);
$output->writeln('Transcoding and HLS are now enabled!'); $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; return 0;
} }
@ -150,9 +164,7 @@ class VideoSetup extends Command
{ {
$output->writeln('Without transcoding, video playback may be slow and limited'); $output->writeln('Without transcoding, video playback may be slow and limited');
$output->writeln('Do you want to disable transcoding and HLS streaming? [y/N]'); $output->writeln('Do you want to disable transcoding and HLS streaming? [y/N]');
$handle = fopen('php://stdin', 'r'); if ('y' !== trim(fgets(fopen('php://stdin', 'r')))) {
$line = fgets($handle);
if ('y' !== trim($line)) {
$output->writeln('Aborting'); $output->writeln('Aborting');
return 1; return 1;

View File

@ -89,11 +89,18 @@ class VideoController extends ApiBase
return new JSONResponse(['message' => 'Transcoder not configured'], Http::STATUS_INTERNAL_SERVER_ERROR); 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 // Check if already running
exec('ps a | grep go-transcode | grep -v grep', $procs); exec('ps a | grep go-transcode | grep -v grep', $procs);
if (0 === \count($procs)) { if (0 === \count($procs)) {
shell_exec("mkdir -p {$tmpDir}/transcoder"); // php func has some weird problems 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 // wait for 2s and try again