vod: add more configuration

Close #450
Close #445
Close #428
Close #297
pull/465/head
Varun Patil 2023-03-09 13:06:08 -08:00
parent ec4db393b3
commit 509ab8402b
3 changed files with 67 additions and 8 deletions

View File

@ -180,6 +180,10 @@ class VideoSetup extends Command
protected function detectFeatures() protected function detectFeatures()
{ {
// Reset the current configuration
$this->config->deleteSystemValue('memories.vod.vaapi');
$this->config->deleteSystemValue('memories.vod.nvenc');
$this->output->writeln("\nStarting ffmpeg feature detection"); $this->output->writeln("\nStarting ffmpeg feature detection");
$this->output->writeln('This may take a while. Please be patient'); $this->output->writeln('This may take a while. Please be patient');
@ -203,6 +207,7 @@ class VideoSetup extends Command
$this->checkCPU(); $this->checkCPU();
$this->checkVAAPI(); $this->checkVAAPI();
$this->checkNVENC();
} finally { } finally {
if (file_exists($this->sampleFile)) { if (file_exists($this->sampleFile)) {
unlink($this->sampleFile); unlink($this->sampleFile);
@ -220,11 +225,15 @@ class VideoSetup extends Command
protected function checkVAAPI() protected function checkVAAPI()
{ {
// Reset current configuration
$this->config->deleteSystemValue('memories.vod.vaapi');
$this->config->deleteSystemValue('memories.vod.vaapi.low_power');
// Check for VAAPI // Check for VAAPI
$this->output->write("\nChecking for VAAPI acceleration (/dev/dri/renderD128) ... "); $this->output->write("\nChecking for VAAPI acceleration (/dev/dri/renderD128) ... ");
if (!file_exists('/dev/dri/renderD128')) { if (!file_exists('/dev/dri/renderD128')) {
$this->output->writeln('NOT FOUND'); $this->output->writeln('NOT FOUND');
$this->config->setSystemValue('memories.vod.vaapi', false); $this->config->deleteSystemValue('memories.vod.vaapi');
return; return;
} }
@ -236,7 +245,7 @@ class VideoSetup extends Command
$this->output->writeln('NO'); $this->output->writeln('NO');
$this->output->writeln('<error>Current user does not have read permissions on /dev/dri/renderD128</error>'); $this->output->writeln('<error>Current user does not have read permissions on /dev/dri/renderD128</error>');
$this->output->writeln('VAAPI will not work. You may need to add your user to the video/render groups'); $this->output->writeln('VAAPI will not work. You may need to add your user to the video/render groups');
$this->config->setSystemValue('memories.vod.vaapi', false); $this->config->deleteSystemValue('memories.vod.vaapi');
return; return;
} }
@ -255,13 +264,13 @@ class VideoSetup extends Command
// Check if passed any test // Check if passed any test
if (!$basic && !$lowPower) { if (!$basic && !$lowPower) {
$this->config->setSystemValue('memories.vod.vaapi', false); $this->config->deleteSystemValue('memories.vod.vaapi');
return; return;
} }
// Everything is good // Everything is good
$this->output->writeln('Do you want to enable VAAPI acceleration? [Y/n]'); $this->output->write('Do you want to enable VAAPI acceleration? [Y/n] ');
if ('n' === trim(fgets(fopen('php://stdin', 'r')))) { if ('n' === trim(fgets(fopen('php://stdin', 'r')))) {
$this->config->setSystemValue('memories.vod.vaapi', false); $this->config->setSystemValue('memories.vod.vaapi', false);
$this->output->writeln('VAAPI is now disabled'); $this->output->writeln('VAAPI is now disabled');
@ -273,6 +282,52 @@ class VideoSetup extends Command
} }
} }
protected function checkNVENC()
{
$this->output->writeln("\nChecking for NVIDIA acceleration with NVENC");
// Reset the current configuration
$this->config->deleteSystemValue('memories.vod.nvenc.temporal_aq');
$this->config->deleteSystemValue('memories.vod.nvenc.scale');
// Basic test
$this->config->setSystemValue('memories.vod.nvenc', true);
// Different scaling methods
$this->config->setSystemValue('memories.vod.nvenc.scale', 'npp');
$withScaleNpp = $this->testResult('NVENC (scale_npp)', true);
$this->config->setSystemValue('memories.vod.nvenc.scale', 'cuda');
$withScaleCuda = $this->testResult('NVENC (scale_cuda)', true);
if (!$withScaleNpp && !$withScaleCuda) {
$this->config->deleteSystemValue('memories.vod.nvenc');
$this->config->deleteSystemValue('memories.vod.nvenc.scale');
$this->output->writeln('NVENC does not seem to be available');
return;
}
if ($withScaleNpp) {
$this->config->setSystemValue('memories.vod.nvenc.scale', 'npp');
} elseif ($withScaleCuda) {
$this->config->setSystemValue('memories.vod.nvenc.scale', 'cuda');
}
// Try with temporal-aq
$this->config->setSystemValue('memories.vod.nvenc.temporal_aq', true);
if (!$this->testResult('NVENC (temporal-aq)', true)) {
$this->config->deleteSystemValue('memories.vod.nvenc.temporal_aq');
}
// Good to go
$this->output->write('Do you want to enable NVENC acceleration? [Y/n] ');
if ('n' === trim(fgets(fopen('php://stdin', 'r')))) {
$this->config->setSystemValue('memories.vod.nvenc', false);
$this->output->writeln('NVENC is now disabled');
} else {
$this->output->writeln('NVENC transcoding is now enabled');
}
}
protected function test(): void protected function test(): void
{ {
$url = \OCA\Memories\Controller\VideoController::getGoVodUrl('test', $this->sampleFile, '360p-000001.ts'); $url = \OCA\Memories\Controller\VideoController::getGoVodUrl('test', $this->sampleFile, '360p-000001.ts');
@ -302,7 +357,7 @@ class VideoSetup extends Command
} }
} }
private function testResult(string $name): bool private function testResult(string $name, bool $minor = false): bool
{ {
$this->output->write("Testing transcoding with {$name} ... "); $this->output->write("Testing transcoding with {$name} ... ");
@ -316,8 +371,10 @@ class VideoSetup extends Command
$msg = $e->getMessage(); $msg = $e->getMessage();
$logFile = $this->logFile; $logFile = $this->logFile;
$this->output->writeln('FAIL'); $this->output->writeln('FAIL');
$this->output->writeln("<error>{$name} transcoding failed with error {$msg}</error>"); if (!$minor) {
$this->output->writeln("Check the log file of go-vod for more details ({$logFile})"); $this->output->writeln("<error>{$name} transcoding failed with error {$msg}</error>");
$this->output->writeln("Check the log file of go-vod for more details ({$logFile})");
}
return false; return false;
} }

View File

@ -402,6 +402,8 @@ class VideoController extends ApiBase
'vaapiLowPower' => $config->getSystemValue('memories.vod.vaapi.low_power', false), 'vaapiLowPower' => $config->getSystemValue('memories.vod.vaapi.low_power', false),
'nvenc' => $config->getSystemValue('memories.vod.nvenc', false), 'nvenc' => $config->getSystemValue('memories.vod.nvenc', false),
'nvencTemporalAQ' => $config->getSystemValue('memories.vod.nvenc.temporal_aq', false),
'nvencScale' => $config->getSystemValue('memories.vod.nvenc.scale', 'npp'),
]; ];
// Write config to file // Write config to file

View File

@ -20,7 +20,7 @@ mv "exiftool-$exifver" exiftool
rm -rf *.zip exiftool/t exiftool/html rm -rf *.zip exiftool/t exiftool/html
chmod 755 exiftool/exiftool chmod 755 exiftool/exiftool
govod="0.0.26" govod="0.0.27"
echo "Getting go-vod $govod" echo "Getting go-vod $govod"
wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-amd64" wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-amd64"
wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-aarch64" wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-aarch64"