diff --git a/lib/Db/TimelineQueryDays.php b/lib/Db/TimelineQueryDays.php index 8e5c2bb9..2899c2d9 100644 --- a/lib/Db/TimelineQueryDays.php +++ b/lib/Db/TimelineQueryDays.php @@ -102,7 +102,7 @@ trait TimelineQueryDays // We don't actually use m.datetaken here, but postgres // needs that all fields in ORDER BY are also in SELECT // when using DISTINCT on selected fields - $query->select($fileid, 'm.isvideo', 'm.datetaken', 'm.dayid', 'm.w', 'm.h') + $query->select($fileid, 'm.isvideo', 'm.video_duration', 'm.datetaken', 'm.dayid', 'm.w', 'm.h') ->from('memories', 'm') ; @@ -198,11 +198,13 @@ trait TimelineQueryDays // Convert field types $row['fileid'] = (int) $row['fileid']; $row['isvideo'] = (int) $row['isvideo']; + $row['video_duration'] = (int) $row['video_duration']; $row['dayid'] = (int) $row['dayid']; $row['w'] = (int) $row['w']; $row['h'] = (int) $row['h']; if (!$row['isvideo']) { unset($row['isvideo']); + unset($row['video_duration']); } if ($row['categoryid']) { $row['isfavorite'] = 1; diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index bcd9145c..19da9a3a 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -97,6 +97,12 @@ class TimelineWrite $dateTaken = gmdate('Y-m-d H:i:s', $dateTaken); [$w, $h] = Exif::getDimensions($exif); + // Video parameters + $videoDuration = 0; + if ($isvideo) { + $videoDuration = round($exif['Duration'] ?? $exif['TrackDuration'] ?? 0); + } + // Store raw metadata in the database // We need to remove blacklisted fields to prevent leaking info unset($exif['SourceFile'], $exif['FileName'], $exif['ExifToolVersion'], $exif['Directory'], $exif['FileSize'], $exif['FileModifyDate'], $exif['FileAccessDate'], $exif['FileInodeChangeDate'], $exif['FilePermissions']); @@ -124,6 +130,7 @@ class TimelineWrite ->set('datetaken', $query->createNamedParameter($dateTaken, IQueryBuilder::PARAM_STR)) ->set('mtime', $query->createNamedParameter($mtime, IQueryBuilder::PARAM_INT)) ->set('isvideo', $query->createNamedParameter($isvideo, IQueryBuilder::PARAM_INT)) + ->set('video_duration', $query->createNamedParameter($videoDuration, IQueryBuilder::PARAM_INT)) ->set('w', $query->createNamedParameter($w, IQueryBuilder::PARAM_INT)) ->set('h', $query->createNamedParameter($h, IQueryBuilder::PARAM_INT)) ->set('exif', $query->createNamedParameter($exifJson, IQueryBuilder::PARAM_STR)) @@ -141,6 +148,7 @@ class TimelineWrite 'datetaken' => $query->createNamedParameter($dateTaken, IQueryBuilder::PARAM_STR), 'mtime' => $query->createNamedParameter($mtime, IQueryBuilder::PARAM_INT), 'isvideo' => $query->createNamedParameter($isvideo, IQueryBuilder::PARAM_INT), + 'video_duration' => $query->createNamedParameter($videoDuration, IQueryBuilder::PARAM_INT), 'w' => $query->createNamedParameter($w, IQueryBuilder::PARAM_INT), 'h' => $query->createNamedParameter($h, IQueryBuilder::PARAM_INT), 'exif' => $query->createNamedParameter($exifJson, IQueryBuilder::PARAM_STR), diff --git a/lib/Migration/Version400700Date20221110030909.php b/lib/Migration/Version400700Date20221110030909.php new file mode 100644 index 00000000..4420c82b --- /dev/null +++ b/lib/Migration/Version400700Date20221110030909.php @@ -0,0 +1,67 @@ + + * @author Your name + * @license GNU AGPL version 3 or any later version + * + * 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 . + */ + +namespace OCA\Memories\Migration; + +use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Auto-generated migration step: Please modify to your needs! + */ +class Version400700Date20221110030909 extends SimpleMigrationStep +{ + /** + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + */ + public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void + { + } + + /** + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + */ + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper + { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('memories'); + + $table->addColumn('video_duration', Types::INTEGER, [ + 'notnull' => true, + 'default' => 0, + ]); + + return $schema; + } + + /** + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + */ + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void + { + } +} diff --git a/src/components/PsVideo.ts b/src/components/PsVideo.ts index 984a639a..d88d58c0 100644 --- a/src/components/PsVideo.ts +++ b/src/components/PsVideo.ts @@ -184,7 +184,6 @@ class VideoContentSetup { updateRotation(content, val?: number) { const rotation = val ?? Number(content.data.exif?.Rotation); const shouldRotate = content.videojs?.src().includes("m3u8"); - console.log("Video.js: Rotation", rotation, shouldRotate); if (rotation && shouldRotate) { let transform = `rotate(${rotation}deg)`; diff --git a/src/components/frame/Photo.vue b/src/components/frame/Photo.vue index 6cd756e7..e819317b 100644 --- a/src/components/frame/Photo.vue +++ b/src/components/frame/Photo.vue @@ -16,7 +16,13 @@ @click="toggleSelect" /> -