Best Video Settings for Youtube, VMAF analysis
TLDR Use H265, 4k, 60mbit for 24-30fps. 120mbit for 60fps.
What file should we provide You Tube in order to get the best quality possible on its site?
It is well known that YT does not host the actual file we send it, it recompresses it and hosts these new, lower quality files. What can we do to get the best treatment from this recompression?
YT provides this guidance on;
https://support.google.com/youtube/answer/1722171?hl=en
h264, 40mb for 4k 24fps, 60mb for 4k 60fps
VMAF was developed by Netflix as improvement to PSNR/SIMM video quality metric. You feed it the original file and the 'distorted' one and it calculates a quality metric between the two, 100 being perfect, 0 being horrible.
https://github.com/Netflix/vmaf
Methodology
1 Test file. I originally used an existing 45 sec travel video I shot on my R5. It was low noise, slow and didn't show significant differences in metrics.
So I decided to create a 'worst case' for compression quality by slamming together a bunch of stock footage and adding grain. it is at 300% speed so I can get 24 and 60fps from original 24fps files. 5 sec duration, VMAF is slow to run.
I exported this from Resolve at 4k, DNxHR HQ at 24 and 60fps. This is the 'Master'.
2 Handbrake. I ran the Master though Handbrake, X265, Slow, CBR. Tune=None, Profile=auto, level=auto.
I selected various bitrates. And also did 1080p downscale as well. One 60mb test using h264 to compare to h265.
3 Upload I uploaded these 15 files to my YT account. It is a account I use regularly for a couple years. It has 150 followers, so if YT algorithm did give better treatment to 'big accounts' I am unable to test that. Let the 'HQ processing' complete.
4 YT-DLP Use YT-DLP to download the 4k files from YT. (1080p for those test files).
5 VMAF ffmpeg -i distorted.mov -i Reference.mov -lavfi libvmaf=n_threads=12:model_path="..../vmaf_4k_v0.6.1.json" -f null -
Note; VMAF requires resolutions to match. Score is the 4k file from YT against the 4k DNxHR master. And 1080p YT files against that 1080p DNxHR (downres'd from the 4k master)
6 Profit Blue bars are bitrates of files YT provided back, right scale. Orange is VMAF score, left scale
Results
A) YT Bitrate. YT appears to target the following bitrates, none of my test could significantly improve on this;
4k 24fps = 20mbit
1080p 24fps = 2.5mbit
4k 60fps = 30mbit.
YT actually seems waste space and took the 4mbit file I sent it and hosts it back to 15mbit. 8mbit to 18mbit.
B) 1080p sucks, never use it. Upscale to 4k if you shoot 1080p. 2.5mbit is not enough. test '2k up 4k dnxhr HQ' is dnxhr file I chopped from 4k to 1080p. Then upscaled to 4k (all with shutter encoder).
The VMAF score of the 1080p file upscaled to 4k (rated against original 4k DNxHR file) is 92%. Vs 54% for the 1080p DNxHR file (rated against the 1080p DNxHR file sent to YT)
C) DNxHR (and assumably ProRes?) uploads to YT result in no higher quality than h265. The 60mbit 4k 24fps file and the DNxHR (680mbit) file have essentially the same 20mbit result and 90% score. Save your bandwidth.
D) H265 is better than H264 With a sample size of 1, the 60mbit files have same 20mbit result at YT, but 90% VMAF for H265 vs 85% for H264.
E) Use H265, 4k, 60mbit for 24-30fps. 120mbit for 60fps.
Discussion
Sample size of one for h264 is not enough. but I see no reason to no use 265.
60fps should get more tests, 120mbit at 79% VMAF isn't great. It does seem like 60fps is never going to be as good as 24fps. YT only gives it 30mbit, when you would need 50mbit to match the bytes per frame it gives to 24fps.
My tests above do not distinguish between the quality lost in Handbrake and the quality lost in YT. I did test this as well, VMAF of the 120mb file sent to YT vs the 19mbit file it returned is 89% (this same file tested 88.4% vs dnxhr master). The 2mbit file sent vs the 17mbit file returned is 98%. So for high bitrate files, all the quality loss happens on YT's end. For low bitrate files (garbage in), YT actually do not reduce the quality further (garbage out).
I used the 4k VMAF test library against the 1080p files, in my one spot check, I got basically the same # when using the HD library, do I didn't bother switching back and forth.