You know what? I think I can figure out a way to estimate final file size and display it to the user. It’ll only work if “Precision Mode” is off though - that uses “CRF” or “Constant Rate Factor” which basically tells the encoder “be efficient, but make the file as big as it needs to be to look good”. As a result there’s no way to tell how big the file will end up being - the encoder makes the decision on the fly.
With “Precision Mode” off, HISTV has two gears:
- If your file is already small enough (at or below the target bitrate), it uses “CQP” or “Constant Quantisation Parameter” (the QP I/P numbers), which tells the encoder “Use this quality level for every frame, I don’t care how big the file ends up”. It’s fast and consistent - every frame gets the same treatment.
- If your file is too big, it switches to VBR (Variable Bit Rate), which tells the encoder “Stay around this target bitrate, spike up to the peak ceiling on complex scenes, but don’t go over”. It’s how the app actually shrinks files. You can estimate the output size with target mbps * seconds / 8 - so a 60-second clip at 4Mbps lands around 30MB. <- This is the maths I’m thinking about doing to display the estimate to the user.
LiveLM@lemmy.zip 2 months ago
As an inspiration for this, look into Two-Pass encoding
obelisk_complex@piefed.ca 2 months ago
Fun fact - HISTV actually has two-pass encoding! Though, with enough system RAM you can actually look ahead far enough that you can get the benefits of two-pass in just a single pass. I have a bit about this in the README.md:
Two-pass only happens when precision mode is on AND the system has less than 8GB RAM AND the file would be CRF-encoded. Reason being, Precision Mode normally uses CRF with extended lookahead (120-250 frames depending on RAM). Lookahead buffers live in memory. On low-RAM systems that buffer would be too large, so the app falls back to two-pass instead and stores the analysis run in a tempfile on disk. To break down each one:
I went with this architecture to mitigate the biggest problem with two-pass encoding, when there’s enough system RAM to store the lookahead frames: the speed. The quality of single-pass with a 250-frame lookahead is equal to two-pass; 120-frame lookahead is just as fast, and still close enough in quality that it doesn’t really make a difference.
LiveLM@lemmy.zip 2 months ago
Damn, I had no clue about this single-pass look ahead, all this time I’ve been doing two-pass for nothing 😵💫
Thanks!