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 option to choose output codec #21

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

christianselig
Copy link
Contributor

To optionally reduce file size of outputted upscaled file this PR lets the user choose the codec (hevc, h264, or prores) via the --codec argument. Default is hevc if not specified (happy to change this if suboptimal, but I tested a 4K -> 8K upscale that was originally h264 and outputted as hevc, and it played back without any dropped frames on my MacBook Pro M1 Pro, MacBook Air M1, and iPhone 15 Pro).

Going from h264 to hevc and upscaling by 2x results in about double the file size, versus about 25x for ProRes.

To make things less complicated with this change I also made it so it doesn't try to keep ProRes codec like it did before (they can just choose that if they want), and it forces ProRes if greater than 14.5K resolution as that's when it starts instantly failing to convert for anything other than ProRes.

Copy link
Owner

@finnvoor finnvoor left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

let convertToProRes = (outputSize.width * outputSize.height) > (3840 * 2160) &&
!(formatDescription?.videoCodecType?.isProRes ?? false)
// Through anecdotal tests anything beyond 14.5K fails to encode for anything other than ProRes
let convertToProRes = (outputSize.width * outputSize.height) > (14500 * 8156)
Copy link
Owner

Choose a reason for hiding this comment

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

This is probably limited by the h264/hevc profile used and could be actually determined somehow, but hardcoded works fine for now

@finnvoor finnvoor merged commit b4ead0f into finnvoor:main Jul 16, 2024
2 checks passed
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.

2 participants