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

fix(server): use correct file extension for motion photo videos #8659

Merged

Conversation

lukashass
Copy link
Contributor

@lukashass lukashass commented Apr 9, 2024

Closes #8658

Set originalFileName extension of motion assets to mp4

TODO

  • migration for existing assets

@lukashass lukashass changed the title fix(server): use mp4 file extension for motion photo videos in archive download fix(server): use correct file extension for motion photo videos in archive download Apr 9, 2024
@lukashass lukashass marked this pull request as ready for review April 9, 2024 14:43
@lukashass
Copy link
Contributor Author

@alextran1502 I saw that since #7679 the file extension for the archive download is only taken from originalFileName. Maybe a better fix than this one would be to set the correct extension in that property in the first place 🤔

@danieldietzler
Copy link
Member

Yeah, IMO originalFileName should always have the correct file name.

@lukashass
Copy link
Contributor Author

On the other hand I'm wondering if the video should be downloaded at all, since it seems to still be embedded in the downloaded jpg and thus downloaded twice.

Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

I think we should probably fix the original filename which is wrong, no?

@lukashass
Copy link
Contributor Author

The video is extracted from the jpg on upload, so the filename is kind of correct (since it says "original").

It is a little ambiguous, that's why I'm questioning the download of the separate video altogether 🤔

@lukashass
Copy link
Contributor Author

So from what I'm reading there are motion photo formats which

  • embed the video in the jpg
  • are two separate files from the beginning

This means the correct fix for the issue is to only download a separate video when the jpg does not contain the video, right?

How would we detect that? I could think of two ways:

  • save this information (separate/embedded video) in a new property
  • compare the file extension of originalFileName of video and photo, if the same, do not download the video

@jrasm91 jrasm91 marked this pull request as draft May 8, 2024 03:31
@lukashass lukashass changed the title fix(server): use correct file extension for motion photo videos in archive download fix(server): use correct file extension for motion photo videos May 11, 2024
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

Looks great imo. Once the tests are passing I think we'll be good to go.

server/src/services/metadata.service.ts Show resolved Hide resolved
@lukashass
Copy link
Contributor Author

@jrasm91 I added the originalFileName to the asset stub that is used in the metadata test.

This tripped up another a "storage template move" test because moving uses asset ids (const filename = asset.originalFileName || asset.id;) as a fallback for non-existent originalFileName.

Outside of tests, I don't see how an asset can not have an originalFileName. This feels a little like a bug, but maybe I'm missing something.

Should I just create a new stub to not interfere with other tests?

@jrasm91
Copy link
Contributor

jrasm91 commented May 23, 2024

Should I just create a new stub to not interfere with other tests?

This is fine.

@lukashass lukashass marked this pull request as ready for review May 24, 2024 15:21
@lukashass lukashass requested a review from jrasm91 May 24, 2024 15:33
Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

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

LGTM

@jrasm91 jrasm91 merged commit f197f5d into immich-app:main May 24, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Motion photo video extension is .jpg in archive downloads
5 participants