Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BobTheSoftwareDeveloper
Copy link

@BobTheSoftwareDeveloper BobTheSoftwareDeveloper commented Jul 16, 2023

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.

@@ -43,6 +43,12 @@ final _commonDatetimePatterns = [
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

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") {

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.

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

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".

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

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

Copy link
Author

@BobTheSoftwareDeveloper BobTheSoftwareDeveloper left a comment

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
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
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

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
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

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
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

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
Copy link

zxsleebu commented Dec 6, 2023

can you please look into it?

@TheLastGimbus
Copy link
Owner

TheLastGimbus commented Dec 7, 2023

@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
Copy link

Alkanov commented Dec 25, 2023

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
Owner

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

@pzh200707
Copy link

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
Owner

@@ -125,6 +126,7 @@ void main(List<String> arguments) async {
jsonExtractor,
exifExtractor,
if (args['guess-from-name']) guessExtractor,
heicVideoExtractor,
Copy link

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
Copy link

mguzman011 commented May 19, 2024

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
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 🌈

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.

None yet

9 participants