Video compression.

General questions or discussion about HandBrake, Video and/or audio transcoding, trends etc.
Post Reply
Posts: 1
Joined: Sat Feb 13, 2021 11:37 am

Video compression.

Post by skamaroh »

Good afternoon, everyone. Help with this question. What parameters to choose in order to compress the video file to the maximum. But that the video was normal.
Source 1.37 gb
Needed for online cinema. I would be very grateful.
And is it possible to put a logo in this program?
Posts: 12
Joined: Thu Jun 03, 2021 3:22 pm

Re: Video compression.

Post by az2020 »

I was looking for that setting too. Sadly, it's not that easy. There's no one-size-fits all when balancing "maximum" this, and "normal" that. The easiest thing I found is 1) pick a scene in your source. 2) use the "range" at the top right of the screen. Change it from chapters to seconds. Set the range to 2 to 5 minutes. 3) Set the video tab's slider to ultrafast. Then, 4) run it a few times with RF set to 15, 20, 25, 30, 35.

The visual quality will look horrible. But, you can extrapolate the resulting file sizes into megabytes per minute (and then how many minutes your movie is will be the size of the resulting file). This will help you zero in on the RF numbers you want to be in for a certain filesize you want to have. For example, if you'd be happy with your 1.37gb file being 0.5gb, you'll quickly see which RF produces that.

Let's say 20-25 look promising to you for the filesize result. Then slide the preset to veryslow, and run it again at 20, 21, 22, 23, 24, 25. (It's going to run much slower. So, you might want to "add to queue" and run them all when you leave your computer for awhile. You'll still be limited to the 2-5 minute range of sampling. But, it could take 30 minutes this time with the slower (higher quality) preset.).

From what I've seen, the preset speeds don't affect filesize (much). They affect the visual quality. The RF number affects filesize (and quality by implication). It seemed easier to me to find a sane filesize *fast* without regard to visual quality. Then test if a good visual quality can be had at that filesize. If you chase both at the same time, then you can waste a lot of time. Because, ultimately, if the amount of time spend encodig the file doesn't matter to you, then you'll want preset=placebo which takes an enormous amount of time for maximum quality. You don't want to be doing that testing RF numbers when the only thing that really changes much from the RF number is the filesize. To me, I found it easier to get in the ballpark with RF & filesize (forget quality, slide the preset to veryfast, superfast or ultrafast). Get a quick lay of the land that way. Find the RF settings you want to be in for filesize. Then sacrifice time to see what quality you get from that. You might find that you can go higher RF (lower quality), to an even smaller filesize, and still have acceptable visual quality (when preset is veryslow).

When you get to that point (slower encoding for better quality), then you might want to only process a 1-minute range so you can sample things faster, and dial the RF & preset easier.

If you come at it that way, it's not too bad. You can be methodical about it. Once you choose an RF value, then use Placebo and let it run overnight (or two days, whatever it takes). That will give you the best quality without increasing filesize (much, if at all).

If you use h264, you can change the video tab's profile to "high." I recall reading that this tells the encoder to use maximum resources. So, again, you're sacrificing time for better quality. You don't have to use this setting during the "dial it in" phase. It might not be noticeable (like placebo might not be either). But, once you pick an RF which is the teeter-totter between size and quality, then you can let it have as much time as it needs (placebo and profile:high) for even better quality (icing on the cake). Assuming encoding time doesn't matter to you.

There's also h265 which is supposed to produce smaller files and better quality. But, I haven't played with that. It seems a little too new to me. The one or two times I tried it, it seemed very slow. I didn't notice it being better quality relative to filesize. So, I decided to stick with the more established h264. I was getting superb results from that as described above.

Don't forget the audio tab too. If the source audio is ac3, you can shave some filesize by encoding that to aac (and lower the bit rate if sound quality doesn't matter to you. If the source is 192, you may find 160 aac sounds as good. Or, 128. You'd want to do some 1-minute samples with different settings here to see what it looks like. Use the mediainfo program to view the source and result files to make sure the audio and video streams are what you expect them to be.). If there's alternate audio tracks (languages) you don't need, you can omit them to save space.
Posts: 12
Joined: Thu Jun 03, 2021 3:22 pm

Re: Video compression.

Post by az2020 »

It occurred to me that when I say there's not much difference in output filesize between presets ultrafast to placebo, I'm just stating my own impression from recently using Handbrake for the first time. I decided to do a quick test[1] using RF=30 for comparison:

Code: Select all

Preset - processing time - size per minute
ultrafast  -  0:58 - 7.38mb 
superfast  -  0:58 - 4.24mb
veryfast   -  1:03 - 3.66mb
medium     -  1:39 - 4.22mb
slow       -  1:57 - 4.24mb
veryslow   -  5:34 - 4.06mb
placebo    - 20:30 - 4.20mb
[Note: For quick comparison to RF=20: superfast produced 24.30mb per minute in 1:16 minutes. Veryslow produced 18.04mb per minute in 9:58 minutes.]

Not counting the extreme "ultrafast", the remaining RF=30 tests averaged 4.1mb per minute. (The extreme "ultrafast" doesn't follow that pattern. It came out 80% higher. Wasn't faster either.).

So, that illustrates how you can quickly (especially if you use only a 5-minute range) find the filesize to expect from different RF values. The you know what RF range you might want to be in. (use "superfast" not "ultrafast" for that quick targeting of RF values. Don't pay attention to what the video looks like. It will look better when you use veryslow. All you're doing is getting some expectation of filesize results)

Once you have a sample of different RF values @ superfast (the filesizes you think are compressed to the level you'd like to have): then you can spend more time sampling a 1-minute veryslow (with RF values that are + or - 2.). You can focus on the quality that way. The veryslow will run longer. But, the shorter 1-minute length will make up for that. You won't have to spend a lot of time to sample around a filesize-range, and see how the quality looks at different RF values.

After you dial that visual quality in, you could do 5- or 10-minute samples before committing to a very long encode of the full move at placebo & h264 profile high processing. (That sample could take an hour or two if your computer isn't as fast as mine. You could queue 3-4 samples of +/- 1RF increments and do one more preview this way -- before committing to what could be a 2-day encode of the entire movie.).

To me, this was the most painless way to approach it. Otherwise you're sliding different things around, "what about this? what about this? what if...". It's frustrating. If you start with superfast you you won't waste time encoding when you don't need to. You can quickly assess the filesize you're going to get (at different RFs.). Then work on the RFs at veryslow (higher quality) and dial in the visual quality relative to the acceptable filesize. If you try to do both at once, it's maddening. You'll spend a lot of time guessing (not knowing what's contributing what).

Like I said: once you arrive at a veryslow RF value (quality and filesize you like), then run that RF value at placebo & h264 profile high. These two settings will throw everything the computer has at it. It will take 5 times longer than veryslow did. But, in theory you'll get slightly better quality than you settled for with your pragmatic experimenting. It's like, "aim low" first, then "aim high" with the final (full) run. Who cares how long it takes? It's only going to run once. You'll know you've done your due-diligence and erred on the side of the highest quality you could get for that filesize.

This all assumes that the amount of time spent encoding doesn't matter. You want best visual quality and most compression (smallest filesize). If the amount of time encoding the full movie does matter, then maybe you want to do veryslow. The amount of improvement between veryslow and placebo isn't much (if any). I think that's why it's called "placebo." Anyone who would endure this much more encoding time is getting a placebo effect. But, it could help. If you can let it run that long, do it. It won't hurt.

As I typed this post: I ran the RF30 & placebo sample again with h264 profile: high. It took 21:34 minutes. The filesize came out 4.26mb per minute. (A little slower and larger output file. than profile: main, the default). Presumably an increase in quality. (These are things you can quickly sample with a 1-minute range.).

Computer: Ryzen 5 3500u quad core laptop with 16g memory.
Source file: 5-minute sample from DVD rip. Video: mpeg-2. Audio: ac3 192bps. 720x480
Output file: video: h264. Audio: aac 160bps. 720x480

Handbrake's preset: Official>Gen>Fast 480p30
- I only changed the following defaults:
Video tab>framerate>same as source
Dimensions tab>no autocrop (all sides 0),
.... tick/untick storage geometry's optimal for source (to pickup any change in the cropping. Mine automatically crops 10px from the left side. That leads to having a strange mirror bar on the ride side. If I tell it no cropping, and make sure the storage geometry is 720x480, everything's fine.).
Veteran User
Posts: 4019
Joined: Wed May 04, 2011 11:06 pm

Re: Video compression.

Post by rollin_eng »

Post Reply