LycheeOrg / Lychee

A great looking and easy-to-use photo-management-system you can run on your server, to manage and share photos.
https://lycheeorg.github.io/
MIT License
3.34k stars 299 forks source link

[Enhancement] Support new Google motion photos Android 11 #753

Open alex-phillips opened 3 years ago

alex-phillips commented 3 years ago

With Android 11, motion photos are captured and saved differently. Previously, Google motion photos would have metadata specifying there was a 'micro video' embedded as well as the offset (which I believe was the bit offset to split the file on).

  "XMP:MicroVideo": 1,
  "XMP:MicroVideoOffset": 3711617,
  "XMP:MicroVideoPresentationTimestampUs": 1087885,
  "XMP:MicroVideoVersion": 1,

This is no longer the case. The following metadata exists instead:

  "XMP:MotionPhoto": 1,
  "XMP:MotionPhotoVersion": 1,
  "XMP:MotionPhotoPresentationTimestampUs": 466480,

I'm not sure the best way to split out the file now as it no longer gives the offset. I found another script that actually reads the data of the file and splits it when it detects a video header in the file. It seems to work with the older style as well as the newer style, but again, not sure if this is the best solution: https://github.com/ViRb3/google-camera-motion-photo-splitter

alex-phillips commented 3 years ago

A stackoverflow on the subject regarding the mp4 header detection: https://stackoverflow.com/questions/53104989/how-to-extract-the-photo-video-component-of-a-mvimg

tmp-hallenser commented 3 years ago

All we would need is the offset.

Here are my ideas how one could implement it:

  1. Write a php function to which checks if XMP:MotionPhoto is set, determines and returns the offset of the video
  2. Add the call here (https://github.com/LycheeOrg/php-exif/blob/c8c88a385be0de9af051d6cbbe6dc74ba4b2619b/lib/PHPExif/Adapter/Exiftool.php#L159) and write the offset to XMP-GCamera:MicroVideoOffset of the array
viveksamele08 commented 3 years ago

HOw to play the Video With help of the below tags

"XMP:MotionPhoto": 1, "XMP:MotionPhotoVersion": 1, "XMP:MotionPhotoPresentationTimestampUs": 466480,