Skip to content

Add iOS Live Photo support and another format for guess_extractor - #224

Open
BobTheSoftwareDeveloper wants to merge 2 commits into
TheLastGimbus:masterfrom
BobTheSoftwareDeveloper:add-iOS-live-photo-support
Open

Add iOS Live Photo support and another format for guess_extractor#224
BobTheSoftwareDeveloper wants to merge 2 commits into
TheLastGimbus:masterfrom
BobTheSoftwareDeveloper:add-iOS-live-photo-support

Conversation

@BobTheSoftwareDeveloper

@BobTheSoftwareDeveloper BobTheSoftwareDeveloper commented Jul 16, 2023

Copy link
Copy Markdown

First of all, great tool! It has made my process of organising the Google Photos export so much nicer for when I upload the backup to S3.

I have tested the changes locally and it was able to add the EXIF date data to the video files successfully.

r'(?<date>(20|19|18)\d{2}_(01|02|03|04|05|06|07|08|09|10|11|12)_[0-3]\d_\d{2}_\d{2}_\d{2})'),
'YYYY_MM_DD_hh_mm_ss',
],
// example: 20190620_184109.jpg

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this format of photos when going through my old photos 20190620_184109.jpg, it seems to be used by older cameras.

final fileNameWithoutExtension = p.basenameWithoutExtension(file.path);

if (fileNameWithoutExtension.startsWith("IMG") &&
p.extension(file.path).toLowerCase() == ".mp4") {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Photo from iPhone with Live Photo enabled when uploading to Google Photos will create three files:

  • IMG_1845.HEIC
  • IMG_1845.MP4
  • IMG_1845.HEIC.json

The .MP4 file always comes in a pair with the .HEIC file when the live photo is enabled, however, there is no JSON file for the video. We can also use the JSON file for the image to set the date for the video. This will ensure that the image and the video are stored in the same directory.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that it doesn't always start with IMG, for example, one of mine is like this:

97E2514D-F5BB-4314-B099-9A5FAE5EEA22.JPG
97E2514D-F5BB-4314-B099-9A5FAE5EEA22.JPG.json
97E2514D-F5BB-4314-B099-9A5FAE5EEA22.MP4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I too see other files. Perhaps instead try to probe whether the img file exists next to it by doing an exists check on the "possibleFileExtensions".

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to andrewchen5678's comment. I had a single file named 51750CEF-B61E-43C7-B4C9-00C19ED09E55 that fit this criteria, so the strict rule of IMG prefix needs rework

"jpg",
"JPEG",
"jpeg"
];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have come across a few situations when the original image in the live photo pair is saved as a .jpg or .jpeg, they seem to use both upper and lower case. I suspect this is either because the HEIC format is disabled or the photo with the live photo feature was sent over iMessage which converted the image into a .jpeg format.

Sample directory of the files:

  • IMG_3984.jpeg
  • IMG_3984.MP4
  • IMG_3984.jpeg.json

and...

  • IMG_7334.JPG
  • IMG_7334.MP4
  • IMG_7334.JPG.json

@BobTheSoftwareDeveloper BobTheSoftwareDeveloper left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done adding comments, requesting for your review :) @TheLastGimbus

@TheLastGimbus

Copy link
Copy Markdown
Owner

Nice! Tho i will need to think more about it, how we should handle it etc, so give me some time to merge it...

@TheLastGimbus

Copy link
Copy Markdown
Owner

So, for now, i'm leaving this waiting for further advancements in metioned discussion...

But, for anyway that wants this NOW, here are nightlies :>

https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/actions/runs/6280579316

@dbrennand

Copy link
Copy Markdown

Hey @TheLastGimbus @BobTheSoftwareDeveloper

Thanks for putting this PR together, I just tested the nightly build and wow! What a difference!

Using the latest version (v3.4.3) gpth shows loads of errors like:

Can't get date on /Volumes/Macintosh HD/Users/user/Downloads/Takeout/Google Photos/.../IMG_8354.MP4

And the summary output shows gpth failing to find metadata for many files:

Couldn't find date for 1997 photos/videos :/

Whereas, using the nightly build with this PR included:

Finding duplicates...
Guessing dates from files : █████████████████....................... 5285/12187  
Can't get date on /Volumes/Macintosh HD/Users/user/Downloads/Takeout/Google Photos/Photos from 2019/moments_09_19_8_20_51 pm.MP4
Guessing dates from files : ███████████████████████████████████████. 12186/12187  
Finding albums (this may take some time, dont worry :) ...
Moving photos to output folder : ████████████████████████████████████████ 12187/12187  
========================================
DONE! FREEEEEDOOOOM!!!
Skipped 3 duplicates
Couldn't find date for 1 photos/videos :/

Only 1 file failed 👍🏻 😃

@TheLastGimbus

Copy link
Copy Markdown
Owner

Only 1 file failed

We're leaving not even one! @dbrennand Could you try to find other files related to this one (og photo and json)?

@dbrennand

Copy link
Copy Markdown

Only 1 file failed

We're leaving not even one! @dbrennand Could you try to find other files related to this one (og photo and json)?

I can have a look, what am I looking for exactly in the JSON?

@TheLastGimbus

Copy link
Copy Markdown
Owner

You're just looking for the json, and it's filename 👍👍

I just want to figure out why gpth didn't find it - it does so by filenames purely

@dbrennand

Copy link
Copy Markdown

You're just looking for the json, and it's filename 👍👍

I just want to figure out why gpth didn't find it - it does so by filenames purely

@TheLastGimbus - I'm not sure why it failed... 🤔 So for this live photo, the three files are named:

  • moments_09_19_8_20_51 pm.JPG
  • moments_09_19_8_20_51 pm.MP4
  • moments_09_19_8_20_51 pm.JPG.json

title value in the JSON is:

{
  "title": "moments_09_19_8_20_51 pm.JPG",
}

@zxsleebu

zxsleebu commented Dec 6, 2023

Copy link
Copy Markdown

can you please look into it?

@TheLastGimbus

TheLastGimbus commented Dec 7, 2023

Copy link
Copy Markdown
Owner

@zxsleebu I'm gonna be honest - right now, no.

And I can't really point when, but like a month from now at least. If you need your takeout with this, use @BobTheSoftwareDeveloper fork - nightlies are still here: https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/actions/runs/6280579316

It will even help to test it if you used it. I just don't have the time right now to make 10000% sure it all works (and potentially add all cool features above) and list it on the official repo

@Alkanov

Alkanov commented Dec 25, 2023

Copy link
Copy Markdown

can you please re-build https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/actions/runs/6280579316

Edit: nvm I forked it and ran it myself. I can confirm I went from 3.5k "Can't get date on...." to only 40 - everything else worked fine. Thanks

@TheLastGimbus

Copy link
Copy Markdown
Owner

https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/actions/runs/7358237528

@pzh200707

Copy link
Copy Markdown

https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/actions/runs/7358237528

I have met the same problem. Latest release is on Sep 23, 2023. The rebuild has expired. Can we have a new release?

@TheLastGimbus

Copy link
Copy Markdown
Owner

Comment thread bin/gpth.dart
jsonExtractor,
exifExtractor,
if (args['guess-from-name']) guessExtractor,
heicVideoExtractor,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this extractor perhaps come before the guessExtractor? If it exits quickly when conditions are not met, it should be safe.

@mguzman011

mguzman011 commented May 19, 2024

Copy link
Copy Markdown

Any chance of being able to add RAW file support? Seems like some .dng and .cr2 files I had weren't transferred over.

Not the worst, since it seems like the EXIF data has been kept intact, but adds another step to the process.

Edit: Seems like .cr2 files were transferred over fine. What caused me issues were ~3mb "CR2" files that were actually jpgs, but labeled CR2 thanks to Google Photos. Renaming the files as JPG brought back all of their EXIF data and I could organize accordingly.

@TheLastGimbus

Copy link
Copy Markdown
Owner

Seems like some .dng and .cr2 files I had weren't transferred over.

I will look at it when i will take care of this project some day 🌈

@safareli

safareli commented Jan 7, 2025

Copy link
Copy Markdown

I tried to use this branch changes and it worked very well. the only thing you user should be aware of is to do merge of the takeout properly. as it could be that for example video part is in another takeout and photo is in another. or photo is in one takeout while json file in another. what I did to make sure takeouts are merged properly is to use rsync on macos

rsync -a ./Takeout/ merged/
rsync -a ./Takeout\ 2/ merged/
rsync -a ./Takeout\ 3/ merged/
rsync -a ./Takeout\ 4/ merged/

and with this way of merging there were no more unknown dates folder in the output

@brandisf

Copy link
Copy Markdown

Hi, thanks for the great tool. Could you build a new release for this branch? Ran into errors with 8k out of 30k Photos ending in the date-unknown folder. Seems like it is due to the iOS live Photo Problem with MP4's not having corresponding jsons. Thank you

@mureev

mureev commented Feb 8, 2025

Copy link
Copy Markdown

Sure guys

https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/actions/runs/8510134630

Can you trigger new nightly build? ty

@trmfreitas

Copy link
Copy Markdown

I added support for live photos MP4 file.
https://github.com/trmfreitas/GooglePhotosTakeoutHelper

@Tomred214

Copy link
Copy Markdown

I added support for live photos MP4 file. https://github.com/trmfreitas/GooglePhotosTakeoutHelper

Hi! Is it possible for you to build a release for this? It's totally ok if not
Thank you!

@trmfreitas

trmfreitas commented May 26, 2025

Copy link
Copy Markdown

I added support for live photos MP4 file. https://github.com/trmfreitas/GooglePhotosTakeoutHelper

Hi! Is it possible for you to build a release for this? It's totally ok if not Thank you!

Ok, I will do it.
Does this help?
https://github.com/trmfreitas/GooglePhotosTakeoutHelper/actions/runs/15254627571

@aiastia

aiastia commented Jun 24, 2025

Copy link
Copy Markdown

I added support for live photos MP4 file. https://github.com/trmfreitas/GooglePhotosTakeoutHelper

Hi! Is it possible for you to build a release for this? It's totally ok if not Thank you!

Ok, I will do it. Does this help? https://github.com/trmfreitas/GooglePhotosTakeoutHelper/actions/runs/15254627571

Hi, he worked, but he still said that there were some anomalies, but for example, the Wacheee version is much better. The Wacheee version has more than 8,000. The date cannot be obtained. At present, these with (1) have some problems. ,


** Guessing dates from files: ██........................................ 2302/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0013(1).MP4
Guessing dates from files: ██........................................ 2338/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0028(1).MP4
Guessing dates from files : ██........................................ 2348/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0023(1).MP4
Guessing dates from files: ██........................................ 2351/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0018(1).MP4
Guessing dates from files : ██........................................ 2355/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0020(1).MP4
Guessing dates from files: ██........................................ 2361/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0019(1).MP4
Guessing dates from files : ██........................................ 2722/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0031(1).MP4
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_0030(1).MP4
Guessing dates from files: ███........................................ 3541/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1116(1).MP4
Guessing dates from files: ███........................................ 3563/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1109(1).MP4
Guessing dates from files : ███........................................ 3565/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1108(1).MP4
Guessing dates from files: ███........................................ 3647/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1034(1).MP4
Guessing dates from files: ███........................................ 3654/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1013(1).MP4
Guessing dates from files: ███........................................ 3663/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1012(1).MP4
Guessing dates from files: ███........................................ 3880/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2019/IMG_1011(1).MP4
Guessing dates from files : ████........................ 4952/41415
Can't get date on /volume5/macOS/photo/Takeout/Google Photos/Photos from 2021/IMG_0108(1).MP4

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.