From 1620d08852f11e2b668e3441a5626871d8b07ce5 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 29 Mar 2023 16:58:34 -0700 Subject: [PATCH] lp: add support for MVIMG (fix #468) Signed-off-by: Varun Patil --- lib/Db/LivePhoto.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/Db/LivePhoto.php b/lib/Db/LivePhoto.php index 7267c7bca..cabf32e27 100644 --- a/lib/Db/LivePhoto.php +++ b/lib/Db/LivePhoto.php @@ -39,6 +39,23 @@ public function getLivePhotoId(File &$file, array &$exif) return 'self__embeddedvideo'; } + // Google MVIMG + if (\array_key_exists('MicroVideoOffset', $exif) && ($videoLength = $exif['MicroVideoOffset']) > 0) { + // As explained in the following issue, + // https://github.com/pulsejet/memories/issues/468 + // + // MicroVideoOffset is the length of the video in bytes + // and the video is located at the end of the file. + // + // Note that we could have just used "self__trailer" here, + // since exiftool can extract the video from the trailer, + // but explicitly specifying the offset is much faster because + // we don't need to spawn exiftool to read the video file. + $videoOffset = $file->getSize() - $videoLength; + + return "self__traileroffset={$videoOffset}"; + } + // Google JPEG and Samsung HEIC (Apple?) if (\array_key_exists('MotionPhoto', $exif)) { if ('image/jpeg' === $exif['MIMEType']) { @@ -65,7 +82,7 @@ public function getLivePhotoId(File &$file, array &$exif) if (\is_int($videoLength) && $videoLength > 0) { $videoOffset = $file->getSize() - $videoLength; - return 'self__traileroffset='.((string) $videoOffset); + return "self__traileroffset={$videoOffset}"; } } }