Page 1 of 1

Resolve Studio h.264/265 encoders SSIM index - And some Bugs

PostPosted: Wed Jan 30, 2019 1:23 pm
by roger.magnusson
Bug report at the end.

Inspired by Bryans great work in mapping the SSIM index of Youtube videos using different source encodes, I thought I'd take a look at the recent additions to h.264 encoders in Resolve v15.

Since v15.2 the Studio version of Resolve for Windows and Linux can use hardware accelerated Nvidia and Intel Quick Sync encoders in addition to Resolve's native software encoder. In older versions of Resolve (like v12) the included encoder wasn't very good and I basically never used it. But even the software encoder seems to have improved a great deal.

I used the crowd_run_2160p50.y4m UHD clip available at https://media.xiph.org/video/derf/ as a reference. Since Resolve can't read that uncompressed format I encoded it to lossless h.264 using -qp 0 in ffmpeg and verified that the SSIM index was 1 = lossless. Using -crf 0 instead of -qp 0 gives an SSIM index slightly below 1 for some reason.

The original file is 8-bit, 4:2:0 according to VLC.

Encode lossless reference file:
Code: Select all
ffmpeg -i crowd_run_2160p50.y4m -c:v libx264 -qp 0 crowd_run_2160p50_reference.mp4
Verify SSIM:
Code: Select all
ffmpeg -i crowd_run_2160p50_reference.mp4 -i crowd_run_2160p50.y4m -lavfi ssim -f null
Using crowd_run_2160p50_reference.mp4 I rendered to h.264 in Resolve using the encoders available to me: Native, Intel Quick Sync and Nvidia. I rendered to all the "Automatic" quality settings: Best, High, Medium, Low, Least. Profile was set to "Auto".

The Intel Quick Sync file was encoded on an Intel NUC using an Intel i5-4250U CPU. A small wonder it can even run Resolve and render UHD files with the built-in GPU. The Nvidia file was encoded on a workstation using a GeForce GTX Titan X (Maxwell architecture).

Results
Apologies for the swedish number format with commas, just think of them as decimal points. :-)

Image

Image

Note that the bit rate is in megabytes per second. Insanely high average bit rate for the "Best" quality setting using the Intel Quick Sync encoder on this clip. SSIM values are high though. Compare these to the .88 that Bryan found when downloading the highest quality encodes from Youtube.

What about macOS?
I also rendered h.264 on a 2018 Mac Mini using the "Automatic" quality setting. For some reason the macOS version of DaVinci Resolve Studio v15.2.3 doesn't have the Best, High, Medium, Low, Least settings that are available in Windows. The SSIM index came out 0,907721 and the average bit rate was 17,82 MB/s. That's a lower average bit rate than the "Least" setting in the Windows version native encoder and of course the image quality suffers.

I haven't tested setting a specific max bit rate.

Nvidia h.265
I've learned that SSIM isn't necessarily a good measure of image quality for encoders that are perceptually optimized. Perhaps that explains the lower SSIM values for the Nvidia h.265 encoder. I assume this might be different in different generations of GPU:s as well.

Image

Encoder Quality setting bugs/incorrect nomenclature

As you can see in the chart above there's something wrong. For Nvidia h.265 the quality settings for Best, High, Medium and Low all output the exact same thing. The same goes for Nvidia h.264 Best and High. I suppose it could be that these settings are for constant quality where the only difference is the time taken, but then it's not consistent.

For VP9 encodes (only in the macOS version of Resolve), the nomenclature of "Best" seems incorrect since all the "Quality" settings produces practically the same quality. It's locked in Constant Quality mode and the only difference is how long the encode takes and to a lesser extent the file size. Best came out 0,972852 (103,56 MB/s) and Least was 0,970022 (106,91 MB/s).

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 2:10 pm
by Dan Sherman
Nice work.

Imo, This further reinforces that you really shouldn't use h.264/5 out of Resolve unless you absolutely need to. You get far better results by exporting a low compression master format out of Resolve, and then using a 3rd party to transcode it to h.264/5.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 2:49 pm
by roger.magnusson
Some third party encoders are better yes, but at least the Resolve h.264 is now a lot better (in Windows) than it used to be. For Youtube it shouldn't be much of an issue unless you really need the smallest possible files.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 3:30 pm
by Jim Simon
Thanks for this, Roger. It's good data.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 3:49 pm
by RCModelReviews
For what it's worth, I noticed that with the NVIDIA H265 encoder, the footage doesn't get pixelated when you drop the bit rate but the motion does become jerky. It seems as if it is giving a preference to quality/sharpness rather than smoothness and motion fidelity. I suspect the exact behavior may differ depending on which drivers or version you're using.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 6:33 pm
by Bryan Worsley
Aha, a fellow number cruncher ! Yes, very nice work Roger.

roger.magnusson wrote:Inspired by Bryans great work in mapping the SSIM index of Youtube videos using different source encodes

In turn inspired by Dan's great work:
https://forum.blackmagicdesign.com/viewtopic.php?f=21&t=83493&p=464648#p463787

roger.magnusson wrote:I used the crowd_run_2160p50.y4m UHD clip available at https://media.xiph.org/video/derf/ as a reference. Since Resolve can't read that uncompressed format I encoded it to lossless h.264 using -qp 0 in ffmpeg and verified that the SSIM index was 1 = lossless. Using -crf 0 instead of -qp 0 gives an SSIM index slightly below 1 for some reason.

The original file is 8-bit, 4:2:0 according to VLC.


That's odd. With 8bit 420 input, libx264 should automatically switch -crf 0 to lossless qp 0 encoding with High 4:4:4 Predictive profile. And on testing the same crowd_run_2160p50.y4m download with your script, replacing -qp 0 with -crf 0, it does:

Image

...and it is lossless:

Image

I'm running Zeranoe Windows-64bit Static nightly builds on Win10.

roger.magnusson wrote:Note that the bit rate is in megabytes per second. Insanely high average bit rate for the "Best" quality setting using the Intel Quick Sync encoder on this clip. SSIM values are high though.


It's an uncompressed/high complexity content-so-hard to compress source, so unconstrained bitrates are going to be very high.

roger.magnusson wrote:Compare these to the .88 that Bryan found when downloading the highest quality encodes from Youtube.


Indeed, noting also that the YouTube VP9 encode bitrates are constrained to around 30-32 Mbps.

roger.magnusson wrote:Nvidia h.265
I've learned that SSIM isn't necessarily a good measure of image quality for encoders that are perceptually optimized....


There is that argument. Personally I still find SSIM a very useful tool. In my experience it provides a pretty accurate reflection of what you see at the pixel peeping level and also for picking up fine differences that are beyond visual acuity. Also the differential Y, U, and V scores can identify whether the luma and/or chroma are affected.

Actually there is an FFMPEG implementation of Netflix's VMAF (Video Multi-Method Assessment Fusion) quality metric:

https://ffmpeg.org/ffmpeg-filters.html#libvmaf
https://github.com/Netflix/vmaf

And a VapourSynth plugin too:
https://github.com/HomeOfVapourSynthEvolution/VapourSynth-VMAF

But I've yet to get it working.

roger.magnusson wrote:......Perhaps that explains the lower SSIM values for the Nvidia h.265 encoder.....

No, that definitely does not explain the results obtained with the Nvidia h.265 encoder.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 7:30 pm
by peterjackson
Thanks for your work. I stumbled about the enormous bitrate difference between Intel Quick Sync vs. Nvidia plus the weird quality mapping as well, but never found time to really dig into it or report it.

If we only could get frame serving to FFMPEG all of these would be non-issues. I really like how OBS exposes standard, advanced and FFMPEG in its encoder settings. This is how an encoder interface should be done.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 7:36 pm
by roger.magnusson
Bryan Worsley wrote:That's odd. With 8bit 420 input, libx264 should automatically switch -crf 0 to lossless qp 0 encoding with High 4:4:4 Predictive profile. And on testing the same crowd_run_2160p50.y4m download with your script, replacing -qp 0 with -crf 0, it does

Odd indeed. I did start out with a much older build and changed it during these tests, so that may have been the issue.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 7:38 pm
by roger.magnusson
peterjackson wrote:If we only could get frame serving to FFMPEG all of these would be non-issues.

Yes, frame serving is a no-brainer. I can't understand why they seem so reluctant to implement it.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 7:39 pm
by peterjackson
OBS encoder screens
IMG-20190130-WA0013.jpeg
IMG-20190130-WA0013.jpeg (40.82 KiB) Viewed 10454 times
IMG-20190130-WA0012.jpeg
IMG-20190130-WA0012.jpeg (37.99 KiB) Viewed 10454 times
IMG-20190130-WA0011.jpeg
IMG-20190130-WA0011.jpeg (51.81 KiB) Viewed 10454 times

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Jan 30, 2019 7:41 pm
by peterjackson
Plus OBS is open source, so that could be used as inspiration on how to implement frameserving to FFMPEG plus how to use the Intel and Nvidia encoder SDKs better.

Also it offers lossless h264 with the Nvidia encoder. Also something that would be very helpful to have in Resolve as for footage without much motion Cineform generates orders of magnitudes bigger files for less quality. Think screencast or interviews.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 5:38 am
by Bryan Worsley
Bryan Worsley wrote:
roger.magnusson wrote:I've learned that SSIM isn't necessarily a good measure of image quality for encoders that are perceptually optimized....


There is that argument. Personally I still find SSIM a very useful tool. In my experience it provides a pretty accurate reflection of what you see at the pixel peeping level and also for picking up fine differences that are beyond visual acuity. Also the differential Y, U, and V scores can identify whether the luma and/or chroma are affected.

Actually there is an FFMPEG implementation of Netflix's VMAF (Video Multi-Method Assessment Fusion) quality metric:

https://ffmpeg.org/ffmpeg-filters.html#libvmaf
https://github.com/Netflix/vmaf

And a VapourSynth plugin too:
https://github.com/HomeOfVapourSynthEvolution/VapourSynth-VMAF

But I've yet to get it working.


Unrelated to Resolve per se, but I got the VapourSynth VMAF plugin up and running and ran some tests comparing VMAF and SSIM (libvmaf derived and 'classic' ffmpeg SSIM) applied to x264 and x265 encodes of the CrowdRun clip; I converted the original y4m download to 1080/50p lossless x264 (Intra-frame) for the reference source.

I used the standard vmaf_v0.6.1.pkl model which "is trained to predict the quality of videos displayed on a 1080p HDTV in a living-room-like environment at a viewing distance of three times the screen height":

https://github.com/Netflix/vmaf/blob/master/resource/doc/models.md

Thought the results might be of interest:

https://forum.doom9.org/showthread.php?p=1864770#post1864770

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 6:14 am
by HaveBlue
Well my Studio License arrived. :D I took some existing stuff and regraded just to see how that works and things were smoother. I tried the 264 and 265 render engine. Without hardware encoding, the CPU would max and the GPU usage was about 10% which was probably just the GUI load. This being what the non Studio version provides. Render speed was 6fps 4K Best mode. Using the Nvidia encoder, render speed is at least 60fps. CPU and GPU load were each at about 50%. This is comparable with other NLEs I've used that utilize the GPU. I haven't had a chance to compare the files and quality.

I'll quote the hardware in case I change it later and people want a reference
3.8Ghz Quad core i5, 24GB RAM, SSD and platter drives, GTX 1070 8GB, LG 10bit 4K 32" monitor with two 20" HD monitors

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 5:41 pm
by Jean Claude
Hello Roger,

Interesting: which version of Nvidia drivers?

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 6:31 pm
by roger.magnusson
This was with Nvidia driver v416.94.

Bryan Worsley wrote:Thought the results might be of interest:

https://forum.doom9.org/showthread.php?p=1864770#post1864770

Nice! Hope the library makes its way to the usual ffmpeg builds as well.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 6:41 pm
by Jean Claude
roger.magnusson wrote:This was with Nvidia driver v416.94..


Hello,
I will do a test as soon as I could: check if the driver has an influence (download source in progress ...) :)

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 6:45 pm
by roger.magnusson
Would also be interesting to know if newer cards behave differently. I use two GeForce GTX Titan X cards (12GB Maxwell).

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 05, 2019 6:47 pm
by Jean Claude
Yes. Here Maxwell and Pascal... :?:

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Mon Feb 11, 2019 4:59 am
by Bryan Worsley
roger.magnusson wrote:
Bryan Worsley wrote:Thought the results might be of interest:

https://forum.doom9.org/showthread.php?p=1864770#post1864770

Nice! Hope the library makes its way to the usual ffmpeg builds as well.


Parallel series at 4K using the VMAF 'model' that aims to "predict the subjective quality of video displayed on a 4KTV and viewed from the distance of 1.5 times the height of the display device (1.5H)"

https://forum.doom9.org/showthread.php?p=1865316#post1865316

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Mon Feb 11, 2019 5:02 pm
by Jean Claude
A question for Ffmpeg experts:
(tested from several versions of Ffmpeg)

When I use the command :
Code: Select all
ffmpeg -i crowd_run_2160p50.y4m -c:v libx264 -crf 0 j:\x264_crowd_run_2160p50_reference.mp4

Next :
Code: Select all
ffmpeg -i j:\x264_crowd_run_2160p50_reference.mp4 -i crowd_run_2160p50.y4m -lavfi ssim=ssim_prores.log -f null -

the result is:
Code: Select all
[Parsed_ssim_0 @ 00000144e984ee80] SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)


ALL 1.000000 (inf) suggests that there is an exact transfer without noise?
it seems improbable to me.

The last column in a normal LOG file, according to doc. of Ffmpeg is the DB.
What is best: the lowest. But 1.00000 (inf) => (?)

Bug or normal?

Thank's :(

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Mon Feb 11, 2019 6:02 pm
by roger.magnusson
An SSIM index of 1 is confirmation that there is absolutely no difference. This is exactly what you should expect with -crf 0 which is lossless. A file like that can't be played on as many players though. It doesn't work in the free version of Resolve for Windows for example.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Mon Feb 11, 2019 6:08 pm
by Jean Claude
OK, Merci

Works with Studio Version
I continue the ASAP tests. :)

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Mon Feb 11, 2019 8:19 pm
by Bryan Worsley
Jean Claude wrote:
Code: Select all
ffmpeg -i crowd_run_2160p50.y4m -c:v libx264 -crf 0 j:\x264_crowd_run_2160p50_reference.mp4


With 8-bit 420 sources that command encodes lossless x264; the encoder automatically defaults to qp 0 and 'High 4:4:4 Predictive' profile.

Jean Claude wrote:....the result is:
Code: Select all
[Parsed_ssim_0 @ 00000144e984ee80] SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)


ALL 1.000000 (inf) suggests that there is an exact transfer without noise?
it seems improbable to me.

That result confirms the encode to be lossless by SSIM analysis.

Jean Claude wrote:The last column in a normal LOG file, according to doc. of Ffmpeg is the DB.
What is best: the lowest. But 1.00000 (inf) => (?)

Bug or normal?

The result in brackets is the SSIM result as a db representation - (Inf) implies 'Infinite' i.e. absolute. Quite normal. A lossless PSNR score is also reported as Inf

Edit:
roger.magnusson wrote:An SSIM index of 1 is confirmation that there is absolutely no difference. This is exactly what you should expect with -crf 0 which is lossless. A file like that can't be played on as many players though. It doesn't work in the free version of Resolve for Windows for example.


Sorry Roger, I see you beat me to it.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 12, 2019 7:11 am
by HaveBlue
I shoot xavc in Slog2. I think Sony xavc is 420. Is it best to match the time line to this or go with more subsampling in the timeline?

Sent from my XT1710-02 using Tapatalk

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 12, 2019 7:30 am
by Uli Plank
The timeline only cares for fps and resolution. Its colorspace is huge and any incoming video is converted anyway.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Tue Feb 12, 2019 9:44 pm
by HaveBlue
Danke, then nothing to worry about there. Sometimes hard to visualize where the bottlenecks are when transcoding and editing.

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Feb 13, 2019 3:15 am
by Uli Plank
Typical bottlenecks:
– Not enough GPU power for complex grading trees and demanding filters.
– Not enough VRAM for high-resolution formats.
– No hardware decoding for H.264/265.
– Not enough CPU power for Red RAW.
– Not enough data throughput and CPU power for DNG sequences.
– Not enough RAM for Fusion.

Did I forget any?

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Feb 13, 2019 3:26 am
by HaveBlue
Oh I was referring to loss of quality when rendering. For instance expanding Slog into a color space that can't hold all the info and then losing it or rendering to a color space or format where info is lost. I found the discussion on ssim interesting for analyzing output quality.

Sent from my XT1710-02 using Tapatalk

Re: Resolve Studio h.264/265 encoders SSIM index - And some

PostPosted: Wed Feb 20, 2019 7:15 pm
by Bryan Worsley
Bryan Worsley wrote:
roger.magnusson wrote:
Bryan Worsley wrote:Thought the results might be of interest:

https://forum.doom9.org/showthread.php?p=1864770#post1864770

Nice! Hope the library makes its way to the usual ffmpeg builds as well.


Parallel series at 4K using the VMAF 'model' that aims to "predict the subjective quality of video displayed on a 4KTV and viewed from the distance of 1.5 times the height of the display device (1.5H)"

https://forum.doom9.org/showthread.php?p=1865316#post1865316


Totally unrelated to Resolve, but of possible interest to folks using the FFMPEG SSIM (and PSNR) quality metrics:

https://forum.doom9.org/showthread.php?t=176101

It was a spin-off from that first test series looking at VMAF and gives some insight into the way FFMPEG derives the SSIM scores.

https://forum.doom9.org/showthread.php?p=1866162#post1866162

Thank goodness for people who can read and make sense of code. In principle, it's somewhat akin to the 'Fast SSIM' metric in the MSU VQA tool:

http://www.compression.ru/video/quality_measure/info.html#ssim

The study also included comparisons with other quality metrics - GMSD, MDSI and Butteraugli - as implemented in VapourSynth.