H265 (NVENC) lossless output

NVENC h265 has as lossless flag, a mode where no quantization happens, but search algorithms used to find exact matches for pixels continues to happen. So yes this is lossless compression.

My suggestion: Topaz gives us the possibility to output h265 losslessly by simply introducing a lossless checkbox that can be selected , this tells the encoder the following command:

preset=lossless

Yes it’s that easy. It seems to be NVENC 265 lossless encoding is a bit more efficient than FFV1 , file size is a least 10% smaller than FFV1
:slightly_smiling_face:

x265 codec has a lossless flag too, for example Handbrake. Simply write “lossless” into the Advanced Option field. When lossless flag is set, Quality settings have no effect.

Edit: Take care you have enough free storage space when doing lossless :wink:
Handbrake_x265_lossless

1 Like

H264 also has this feature.
PS I didn’t know it was more efficient than FFV1! I like that codec, so that’s impressive.

It seems x264 has no lossless flag, but I’m not sure. For sure x265 has one. There are several forum threads around when you set x264 and CRF=0 Avisynth, Handbrake… the result is real lossless or not, for me it’s not clear, the thing is does quantization happen.

Back to NVENC, my 265 lossles encodes, gets up to 20% smaller than same files FFV1 encoded. NVENC-265 was much faster than FFV1, when you have an usable GPU.

If Topaz gives us a NVENC-265 lossless option for sure output files gets very large, for example when you do 4k upscale. But user is king, they could warn us, ideally by checking whether there is enough storage available on the selected target volume. A predicted file size pre-calc of lossless encodes is easy because they can use constant factor multiplied by resolution and fps

Definitely would be nice. I was using 120M CBR h264 for a while and that is pretty close, but definitely wastes disk space. Now I am just using high quality h265 for 4K and ProRes HQ for 1080p or less. I know ffmpeg does lossless h265 with lossless=1 and h264 with CRF=0 but I am not positive if it is compatible with the nvenc encoder.

I tried to add NVENC h.265 lossless compression to TVAI (not too complex to do) but found that it compresses worse than FFV1, even with the best preset (p7). Difference is like 10-15%. Key point here is NVENC, because with x265 situation changes to opposite, but it is not possible to add x265 as compressor to TVAI, at least not so easy. Maybe NVENC HEVC could give some small improvement in speed when the FFV-on-CPU is the limiting factor, but in my system there was no difference, because video processing is limiting speed, not video compressing.

I know it’s a old thread. I don’t know what TVAI lossless h265 does when it comes to compression, may be it does fast run and compression is bader as it could be.

Now I did some tests converting FFV1 lossless with Handbrake into h264 NVEnc with CFR setting 0 and I wrote “lossless” into the Handbrake command field, I don’t know this has some effect or not. My FFV1 testfile source is 136 GB in size and the generated h264 NVEnc was only 16.6 GB, this was my first suprise.

What I expected was that the quality of the 16.6 GB file would not be identical and is not really lossless, compared to the 136 GB FFV1 file…but I was surprised again, I cant find any difference.

So if it is the case fast gpu based h264 NVEnc with Quantification set to zero delivers simillar results as the monster sized FFV1 then this is very interesting!

Here is a compare of a zoomed segment, left is FFV1 on the right is h265 NVEnc h264 CFR=0, maybe my eyes can’t see it and difference is there, for me it looks simillar and it keeps grain. You must download the image, because google drive does compression.

One key difference is that the lossless h264 files take a lot more decompression to work with. They’re not great for video editors.

lossless h264 works great in Davinci Resolve.
lossless h265 worked not so good and had slightly color-shift in Davinci if I used rgb I guess.

You can try this ffmpeg command to test.
ffmpeg.exe -i “input.mov” -pix_fmt rgb24 -c:v libx264rgb -preset slow -crf 0 “output_h264.mov”

but Topaz does not know the encoder libx264rgb.
I mostly used ffv1 with 4:4:4-10bit because 4:4:4-8bit has less color than rgb-8bit.
or I compress it afterwards with ffmpeg to lossless h264rgb

now I have included the ffv1-rgb8 to the the video-encoder.json to save a bit of space.
{
“id”: “ffv1-8bit-rgb”,
“encoder”: “FFV1”,
“profile”: “8-bit rgb”,
“allowsAlpha”: 0,
“ffmpegOpts”: “-level 3 -c:v ffv1 -pix_fmt bgr0 -coder 1 -slices 8 -slicecrc 1 -g 1”,
“ext”: [
“mkv”,
“mov”,
“avi”
]
},

1 Like

I can immediately see that there is less noise in the image on the right, for example in the face. So it is not lossless.

1 Like

yes you’re right, now I also can see it. I really need a better monitor..or new eyes :grinning_face_with_smiling_eyes: So set NvEnc h264 to CFR=0 into handbrake produces no lossless