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

feat(server): only transcode streams that require it #7106

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

mertalev
Copy link
Contributor

Description

Transcoding is currently "all-or-nothing": either both audio and video are transcoded, or neither are. This PR separates the two, meaning that transcoding is done only for the stream that requires it: the other can be copied as-is unless it also needs to be transcoded.

It also refactors the transcode policy code accordingly.

How Has This Been Tested?

Tested that videos are transcoded successfully, that streams that should be transcoded based on a policy have a codec in the command instead of "copy" and that whether a stream is copied is responsive to the policy.

Copy link

cloudflare-workers-and-pages bot commented Feb 14, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5e7cd63
Status: ✅  Deploy successful!
Preview URL: https://b35b7ae2.immich.pages.dev
Branch Preview URL: https://feat-server-copy-stream.immich.pages.dev

View logs

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.

LGTM

@mertalev mertalev merged commit 5ff68d4 into main Feb 14, 2024
25 checks passed
@mertalev mertalev deleted the feat/server-copy-stream branch February 14, 2024 16:24
@mertalev mertalev mentioned this pull request Feb 21, 2024
3 tasks
@mingqlin
Copy link

mingqlin commented Feb 21, 2024

@mertalev "the other can be copied as-is unless it also needs to be transcoded."
why copied as-is? if no transcoding is required, should we not copy the original video into the encoded folder? it is wasted space.

@mertalev
Copy link
Contributor Author

If no transcoding is needed, then it still doesn't transcode. But if the audio stream needs to be transcoded, then the video has to either be transcoded or copied. The previous behavior was that it would always transcode the video, but now it will only transcode the video if it's required based on the transcode policy.

@mertalev
Copy link
Contributor Author

But I do see your point that this can increase space usage quite a bit, especially since the default transcode policy doesn't consider resolution. Hmm...

@mingqlin
Copy link

mingqlin commented Feb 21, 2024

I am ok with storage space usage if it is for a good cause. Think of YouTube, It always pre-transcode video into different qualities (fixed resolution and bitrate), this way its player could play different resolution base on users network speed. Another approach would be like Plex, which transcode real time, it will save a lot of space (no pre-transcoding, cons, it is slower response time when user click on play, it will take seconds to start if not longer)

@mertalev
Copy link
Contributor Author

Another approach would be like Plex, which transcode real time, it will save a lot of space (no pre-transcoding, cons, it is slower response time when user click on play, it will take seconds to start if not longer)

We do want to add real-time transcoding at some point since it's a lot more efficient in terms of space and CPU usage. There are too many things to work on, not enough time haha

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.

3 participants