vonhoro / Automate-encoding

A big script an utilities to automatize encoding
MIT License
0 stars 1 forks source link

[Feature Request] Automatic computation of bframes #6

Open Motophan opened 3 years ago

Motophan commented 3 years ago

This is specifically the --bframes [6-16] flag and we can compute this after running the crf test.

This setting determines the maximum number of bframes x264 is allowed to use in a row. This does not mean it will use them all, as x264 will decide during encoding what is optimal. This setting is merely a maximum to cut off x264 for speed purposes.

The best setting for this would be to just leave it out and use the default Placebo of --bframes 16, which is the maximum and lets x264 have free reign over how many bframes to use. However, this can cause encodes to become time consuming, especially for slower computers.

After the CRF test encode there will be a line that looks like this: x264 [info]: consecutive B-frames: 0.5% 1.1% 3.6% 24.0% 14.4% 43.3% 4.0% 3.4% 1.1% 1.4% 0.5% 0.9% 0.3% 0.3% 0.2% 0.9% 0.1%

There are 17 values listed. Each one represents a specific number of consecutive b-frames, from 0 to 16. Each value shows the percentage of total frames that were able to make use of that number of consecutive b-frames. From these numbers choose the largest number of bframes whose percentage is >= 1.0%. In the above example, use --bframes 9.

This is a LOW priority feature, as all this does is reduce encoding time. --bframes 16 is totally acceptable.

vonhoro commented 3 years ago

Do you mean the value closer to 1% but bigger or the biggest number?

Motophan commented 3 years ago

This is not critical, its the grouping of numbers.

x264 [info]: consecutive B-frames: 0.5% 1.1% 3.6% 24.0% 14.4% 43.3% 4.0% 3.4% 1.1% 1.4% 0.5% 0.9% 0.3% 0.3% 0.2% 0.9% 0.1%

when it says this, it means 0.5% (0) bframes (I frame next to I frame) 1.1% (1) 3.6% (2) 24.0% (3) 14.4% (4) 43.3% (5) 4.0% (6) 3.4% (7) 1.1% (8) 1.4% (9) 0.5% (10) 0.9% (11) 0.3% (12) 0.3% (13) 0.2% (14) 0.9% (15) 0.1% (16)

1.4% (9) -> this is the max bframes we should tell x264 to look for, as there are very few cases it would try to use over this. (all the higher number of bframes are less than 1%)

By sending x264 the flag --bframes 9 it will not attempt (and waste cpu cycles) looking to see if it should use 10+ bframes in a row. This speeds up the encode a little, but not much. Its nice to have but if coding this is hard, skip it and hardcode --bframes 16. The encodes will just take more cpu power than they need.