Skip to content

Commit

Permalink
lp: add support for MVIMG (fix pulsejet#468)
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
  • Loading branch information
pulsejet authored and silopolis committed Apr 13, 2023
1 parent 19a3f85 commit 1620d08
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/Db/LivePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand All @@ -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}";
}
}
}
Expand Down

0 comments on commit 1620d08

Please # to comment.