More batteries
parent
c41854e141
commit
007a8c3f4f
|
@ -8,7 +8,7 @@
|
||||||
[![Gitter](https://img.shields.io/gitter/room/pulsejet/memories)](https://gitter.im/pulsejet/memories)
|
[![Gitter](https://img.shields.io/gitter/room/pulsejet/memories)](https://gitter.im/pulsejet/memories)
|
||||||
[![GitHub issues](https://img.shields.io/github/issues/pulsejet/memories)](https://github.com/pulsejet/memories/issues)
|
[![GitHub issues](https://img.shields.io/github/issues/pulsejet/memories)](https://github.com/pulsejet/memories/issues)
|
||||||
|
|
||||||
Memories is a batteries-included photo management solution for Nextcloud with advanced features including:
|
Memories is a _batteries-included_ photo management solution for Nextcloud with advanced features including:
|
||||||
|
|
||||||
- **📸 Timeline**: Sort photos and videos by date taken, parsed from Exif data.
|
- **📸 Timeline**: Sort photos and videos by date taken, parsed from Exif data.
|
||||||
- **⏪ Rewind**: Jump to any time in the past instantly and relive your memories.
|
- **⏪ Rewind**: Jump to any time in the past instantly and relive your memories.
|
||||||
|
|
|
@ -46,6 +46,7 @@ Memories is a batteries-included photo management solution for Nextcloud with ad
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<commands>
|
<commands>
|
||||||
<command>OCA\Memories\Command\Index</command>
|
<command>OCA\Memories\Command\Index</command>
|
||||||
|
<command>OCA\Memories\Command\VideoSetup</command>
|
||||||
</commands>
|
</commands>
|
||||||
<navigations>
|
<navigations>
|
||||||
<navigation>
|
<navigation>
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace OCA\Memories\Command;
|
||||||
|
|
||||||
use OC\DB\Connection;
|
use OC\DB\Connection;
|
||||||
use OC\DB\SchemaWrapper;
|
use OC\DB\SchemaWrapper;
|
||||||
use OCA\Files_External\Service\GlobalStoragesService;
|
|
||||||
use OCA\Memories\AppInfo\Application;
|
use OCA\Memories\AppInfo\Application;
|
||||||
use OCA\Memories\Db\TimelineWrite;
|
use OCA\Memories\Db\TimelineWrite;
|
||||||
use OCP\Encryption\IManager;
|
use OCP\Encryption\IManager;
|
||||||
|
@ -38,8 +37,6 @@ use OCP\IDBConnection;
|
||||||
use OCP\IPreview;
|
use OCP\IPreview;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
@ -47,9 +44,6 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
class Index extends Command
|
class Index extends Command
|
||||||
{
|
{
|
||||||
/** @var ?GlobalStoragesService */
|
|
||||||
protected $globalService;
|
|
||||||
|
|
||||||
/** @var int[][] */
|
/** @var int[][] */
|
||||||
protected array $sizes;
|
protected array $sizes;
|
||||||
|
|
||||||
|
@ -78,8 +72,7 @@ class Index extends Command
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IManager $encryptionManager,
|
IManager $encryptionManager,
|
||||||
IDBConnection $connection,
|
IDBConnection $connection,
|
||||||
Connection $connectionForSchema,
|
Connection $connectionForSchema
|
||||||
ContainerInterface $container
|
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
|
@ -91,12 +84,6 @@ class Index extends Command
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->connectionForSchema = $connectionForSchema;
|
$this->connectionForSchema = $connectionForSchema;
|
||||||
$this->timelineWrite = new TimelineWrite($connection, $preview);
|
$this->timelineWrite = new TimelineWrite($connection, $preview);
|
||||||
|
|
||||||
try {
|
|
||||||
$this->globalService = $container->get(GlobalStoragesService::class);
|
|
||||||
} catch (ContainerExceptionInterface $e) {
|
|
||||||
$this->globalService = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function configure(): void
|
protected function configure(): void
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2022, Varun Patil <radialapps@gmail.com>
|
||||||
|
* @author Varun Patil <radialapps@gmail.com>
|
||||||
|
* @license AGPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Memories\Command;
|
||||||
|
|
||||||
|
use OCP\IConfig;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class VideoSetup extends Command
|
||||||
|
{
|
||||||
|
protected IConfig $config;
|
||||||
|
protected OutputInterface $output;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
IConfig $config
|
||||||
|
) {
|
||||||
|
parent::__construct();
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('memories:video-setup')
|
||||||
|
->setDescription('Setup video streaming')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
// Get ffmpeg version
|
||||||
|
$output->writeln('Checking for ffmpeg binary');
|
||||||
|
$ffmpeg = shell_exec('ffmpeg -version');
|
||||||
|
if (false === strpos($ffmpeg, 'ffmpeg version')) {
|
||||||
|
$ffmpeg = null;
|
||||||
|
$output->writeln('<error>ffmpeg is not installed</error>');
|
||||||
|
} else {
|
||||||
|
$output->writeln('ffmpeg is installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get ffprobe version
|
||||||
|
$output->writeln('Checking for ffprobe binary');
|
||||||
|
$ffprobe = shell_exec('ffprobe -version');
|
||||||
|
if (false === strpos($ffprobe, 'ffprobe version')) {
|
||||||
|
$ffprobe = null;
|
||||||
|
$output->writeln('<error>ffprobe is not installed</error>');
|
||||||
|
} else {
|
||||||
|
$output->writeln('ffprobe is installed');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $ffmpeg || null === $ffprobe) {
|
||||||
|
$output->writeln('ffmpeg and ffprobe are required for video transcoding');
|
||||||
|
return $this->suggestDisable($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check go-transcode binary
|
||||||
|
$output->writeln('Checking for go-transcode binary');
|
||||||
|
|
||||||
|
// Detect architecture
|
||||||
|
$arch = \OCA\Memories\Util::getArch();
|
||||||
|
$libc = \OCA\Memories\Util::getLibc();
|
||||||
|
|
||||||
|
if (!$arch || !$libc) {
|
||||||
|
$output->writeln('<error>Compatible go-transcode binary not found</error>');
|
||||||
|
$this->suggestGoTranscode($output);
|
||||||
|
return $this->suggestDisable($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
$goTranscodePath = realpath(__DIR__."/../../exiftool-bin/go-transcode-{$arch}-{$libc}");
|
||||||
|
$output->writeln("Trying go-transcode from $goTranscodePath");
|
||||||
|
|
||||||
|
$goTranscode = shell_exec($goTranscodePath . ' --help');
|
||||||
|
if (!$goTranscode || false === strpos($goTranscode, 'Available Commands')) {
|
||||||
|
$output->writeln('<error>go-transcode could not be run</error>');
|
||||||
|
$this->suggestGoTranscode($output);
|
||||||
|
return $this->suggestDisable($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go transcode is working. Yay!
|
||||||
|
$output->writeln('go-transcode is installed!');
|
||||||
|
$output->writeln('');
|
||||||
|
$output->writeln('You can use transcoding and HLS streaming');
|
||||||
|
$output->writeln('This is recommended for better performance, but not for very slow systems');
|
||||||
|
$output->writeln('For more details see: https://github.com/pulsejet/memories/wiki/Configuration');
|
||||||
|
$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)) {
|
||||||
|
$this->config->setSystemValue('memories.no_transcode', true);
|
||||||
|
$output->writeln('<error>Transcoding and HLS are now disabled</error>');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config->setSystemValue('memories.transcoder', $goTranscodePath);
|
||||||
|
$this->config->setSystemValue('memories.no_transcode', false);
|
||||||
|
$output->writeln('Transcoding and HLS are now enabled!');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function suggestGoTranscode(OutputInterface $output): void
|
||||||
|
{
|
||||||
|
$output->writeln('You may build go-transcode from source');
|
||||||
|
$output->writeln('It can be downloaded from https://github.com/pulsejet/go-transcode');
|
||||||
|
$output->writeln('Once built, point the path to the binary in the config for `memories.transcoder`');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function suggestDisable(OutputInterface $output) {
|
||||||
|
$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)) {
|
||||||
|
$output->writeln('Aborting');
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->config->setSystemValue('memories.no_transcode', true);
|
||||||
|
$output->writeln('<error>Transcoding and HLS are now disabled</error>');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
21
lib/Exif.php
21
lib/Exif.php
|
@ -269,28 +269,13 @@ class Exif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect architecture
|
// Detect architecture
|
||||||
$arch = null;
|
$arch = $noLocal ? null : \OCA\Memories\Util::getArch();
|
||||||
$uname = php_uname('m');
|
$libc = $noLocal ? null : \OCA\Memories\Util::getLibc();
|
||||||
if (false !== stripos($uname, 'aarch64') || false !== stripos($uname, 'arm64')) {
|
|
||||||
$arch = 'aarch64';
|
|
||||||
} elseif (false !== stripos($uname, 'x86_64') || false !== stripos($uname, 'amd64')) {
|
|
||||||
$arch = 'amd64';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect glibc or musl
|
|
||||||
$libc = null;
|
|
||||||
if ($ldd = shell_exec('ldd --version 2>&1')) {
|
|
||||||
if (false !== stripos($ldd, 'musl')) {
|
|
||||||
$libc = 'musl';
|
|
||||||
} elseif (false !== stripos($ldd, 'glibc')) {
|
|
||||||
$libc = 'glibc';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get static binary if available
|
// Get static binary if available
|
||||||
if ($arch && $libc && !$noLocal) {
|
if ($arch && $libc && !$noLocal) {
|
||||||
// get target file path
|
// get target file path
|
||||||
$path = __DIR__."/../exiftool-bin/exiftool-{$arch}-{$libc}";
|
$path = realpath(__DIR__."/../exiftool-bin/exiftool-{$arch}-{$libc}");
|
||||||
|
|
||||||
// check if file exists
|
// check if file exists
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
|
|
33
lib/Util.php
33
lib/Util.php
|
@ -14,6 +14,39 @@ class Util
|
||||||
|
|
||||||
public static $ARCHIVE_FOLDER = '.archive';
|
public static $ARCHIVE_FOLDER = '.archive';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get host CPU architecture (amd64 or aarch64).
|
||||||
|
*/
|
||||||
|
public static function getArch()
|
||||||
|
{
|
||||||
|
$uname = php_uname('m');
|
||||||
|
if (false !== stripos($uname, 'aarch64') || false !== stripos($uname, 'arm64')) {
|
||||||
|
return 'aarch64';
|
||||||
|
}
|
||||||
|
if (false !== stripos($uname, 'x86_64') || false !== stripos($uname, 'amd64')) {
|
||||||
|
return 'amd64';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the libc type for host (glibc or musl).
|
||||||
|
*/
|
||||||
|
public static function getLibc()
|
||||||
|
{
|
||||||
|
if ($ldd = shell_exec('ldd --version 2>&1')) {
|
||||||
|
if (false !== stripos($ldd, 'musl')) {
|
||||||
|
return 'musl';
|
||||||
|
}
|
||||||
|
if (false !== stripos($ldd, 'glibc')) {
|
||||||
|
return 'glibc';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path to the user's configured photos directory.
|
* Get the path to the user's configured photos directory.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,4 +17,11 @@ 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
|
||||||
|
|
||||||
|
gotranscode="v0.0.1"
|
||||||
|
wget -q "https://github.com/pulsejet/go-transcode/releases/download/$gotranscode/go-transcode-amd64-musl"
|
||||||
|
wget -q "https://github.com/pulsejet/go-transcode/releases/download/$gotranscode/go-transcode-amd64-glibc"
|
||||||
|
wget -q "https://github.com/pulsejet/go-transcode/releases/download/$gotranscode/go-transcode-aarch64-musl"
|
||||||
|
wget -q "https://github.com/pulsejet/go-transcode/releases/download/$gotranscode/go-transcode-aarch64-glibc"
|
||||||
|
chmod 755 go-transcode-*
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
Loading…
Reference in New Issue