immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
47.33k stars 2.4k forks source link

Some Live Photos are Split (Again) #8503

Closed carloslockward closed 5 months ago

carloslockward commented 6 months ago

The bug

I have found another instance of bug #3228.

I setup Immich and used my phone to upload all the photos locally stored there, then i downloaded all photos from google photos using takeout and then imported them to Immich.

Live photos uploaded from the phone worked flawlessly but when the import from google photos happened an additional video file was added. Photos that where not on the phone but where on the google photos zip file did not become live photos and kept the photo and video file separated.

After reading issue #3228, I verified that all jobs where done and then tried to run metadata job but this did not fix the issue.

Here is an example (I don't mind showing the location since is an old picture and its not very specific):

image image

As you can see both images have metadata and they share the same name(minus the extension), same location and same capture time. So I don't know why they wouldn't merge (perhaps MP4 is not supported?).

The OS that Immich Server is running on

unraid 6.12.9

Version of Immich Server

1.100.0

Version of Immich Mobile App

N/A

Platform with the issue

Your docker-compose.yml content

N/A

Your .env content

N/A

Reproduction steps

1. Set up Immich
2. Back up photos from phone app.
3. Download same photos from google takeout
4. Import downloaded photos from google take out.

Additional information

No response

### Tasks
bo0tzz commented 6 months ago

Google takeout destroys the metadata on the files, which would probably include the information that links live photos. Did you upload the takeout files as is, did you use a tool to rebuild the metadata from the .json files, or did you use immich-go to upload them?

Ynng commented 6 months ago

I'm experiencing what seems to be the same issue #8508

carloslockward commented 6 months ago

@bo0tzz I used Immich-go which, to my understanding, should rebuild metadata from the json files.

Ynng commented 6 months ago

@carloslockward To my understanding, the video is embedded inside the MVIMG jpg already, the separate mp4 file is useless and the culprit of the problem.

If you delete the mp4 file then refresh metadata on the jpg, it should fix itself.

carloslockward commented 6 months ago

@carloslockward To my understanding, the video is embedded inside the MVIMG jpg already, the separate mp4 file is useless and the culprit of the problem.

If you delete the mp4 file then refresh metadata on the jpg, it should fix itself.

@Ynng This worked! I should mention that your PR (#8512) Also worked on making the video invisible(but this is not the ideal solution since this will keep the video on disk which is redundant if its already embedded in the jpg).

So i should probably open an issue on immich-go so that it ignores mp4 files that start with MVIMG since they are not needed.

Ynng commented 6 months ago

@carloslockward To my understanding, the video is embedded inside the MVIMG jpg already, the separate mp4 file is useless and the culprit of the problem.

If you delete the mp4 file then refresh metadata on the jpg, it should fix itself.

@Ynng This worked! I should mention that your PR (#8512) Also worked on making the video invisible(but this is not the ideal solution since this will keep the video on disk which is redundant if its already embedded in the jpg).

So i should probably open an issue on immich-go so that it ignores mp4 files that start with MVIMG since they are not needed.

I'm glad it worked! Regarding the video being redundant, my understanding is that immich relies on the video as a separate asset to work properly.

Regarding fixing immich-go, it's probably best that the cli uploads the mp4 only if a matching jpg is found. If only the motion video mp4 is found it should be uploaded regardless

carloslockward commented 6 months ago

@Ynng I have now found this:

Even with your changes and after refreshing metadata, some of the videos still show up: image

Here is the metadata: image image

I noticed the images with this problem are only the ones taken with my Samsung phone. Pictures taken with the Oneplus do merge properly after importing.

Any idea why?

Also what could be a good way of filtering for .MP4 files that are less than 5s long so i can delete them all in one go.

carloslockward commented 6 months ago

After a little more debugging I found out that the Video in question and the MotionAsset are not the same. Meaning that there are 2 assets that might be candidates for the motion photo. 1 Asset came when I uploaded the photo from the Immich phone app and the other came when I uploaded the full google takeout backup using Immich-go.

This is the function that finds the asset for the live photo.

  findLivePhotoMatch(options: LivePhotoSearchOptions): Promise<AssetEntity | null> {
    const { ownerId, otherAssetId, livePhotoCID, type } = options;

    return this.repository.findOne({
      where: {
        id: Not(otherAssetId),
        ownerId,
        type,
        exifInfo: {
          livePhotoCID,
        },
      },
      relations: {
        exifInfo: true,
      },
    });
  }

As you can see it only finds one (findOne)

I would suggest finding all the assets that match the query, pick the largest one to be the MotionAsset and then delete the other ones.

Ynng commented 6 months ago

I'll take a closer look tonight but gut feeling tells me the code snippet you sent is for apple live photo, which is always stored as 2 separate files.

Regardless of the motion photo format, I believe immich always stores the motion video part as a separate hidden asset.