Encoding many videos with ffmpeg, handbrake, and nvencc

Published

November 28, 2025

I was working figure out the best combination of settings for ffmpeg, handbrake, and nvencc to encode a large number of videos. I wanted to compare the quality and file size of each encoding method. The Just Video.mkv below is the video uncompressed. What I found was that nvencc was the fastest and could be controlled to have similar quality to ffmpeg and handbrake at a fraction of the time.

Code
import pandas as pd

df = pd.read_excel("comparison-of-encodings.xlsx")
df
Table 1: Comparison of encodings
Relative path Date Size Compression Ratio Encoder library Time to Encode Codec level preset Qualtiy/crf cqp AQ Lookahead b frames b ref mode
0 test20.mkv 2022-12-05 00:06:50 165178477 30.907239 handbrake x265 01:02:32 h.265 auto slow 28.0 NaN NaN 25.0 4.0 NaN
1 test21.mkv 2022-12-05 00:20:50 217591441 23.462369 handbrake x264 00:13:58 h.264 3.1 medium 28.0 NaN NaN NaN NaN NaN
2 test10.mkv 2022-12-04 20:27:04 353531237 14.440621 nvencc nvencc 00:02:31 h.265 auto P7 NaN 20:28:28 on 32.0 0.0 disabled
3 test01.mkv 2022-12-04 19:37:40 357186733 14.292834 nvencc nvencc 00:01:51 h.265 auto P1 NaN 1 day, 0:28:28 off 32.0 0.0 disabled
4 test08.mkv 2022-12-05 11:25:08 357499168 14.280343 nvencc nvencc 00:02:06 h.265 auto P4 NaN 20:28:28 on 32.0 0.0 disabled
5 test09.mkv 2022-12-04 20:23:55 372688029 13.698349 nvencc nvencc 00:02:09 h.265 auto P1 NaN 20:28:28 on 32.0 0.0 disabled
6 test17.mkv 2022-12-04 21:07:59 407170602 12.538259 nvencc nvencc 00:02:00 h.264 auto P4 NaN 20:28:28 off 0.0 3.0 disabled
7 test13.mkv 2022-12-04 20:44:10 414758133 12.308886 nvencc nvencc 00:02:12 h.264 auto P4 NaN 20:28:28 on 32.0 3.0 disabled
8 test14.mkv 2022-12-04 20:58:13 415904717 12.274952 nvencc nvencc 00:02:54 h.264 auto P7 NaN 20:28:28 on 32.0 3.0 disabled
9 test22.mkv 2022-12-05 00:25:16 427046059 11.954707 handbrake nvenc_h264 00:04:24 h.264 auto medium 28.0 NaN NaN NaN NaN NaN
10 test16.mkv 2022-12-04 21:05:11 428304164 11.919591 nvencc nvencc 00:02:13 h.s64 auto P4 NaN 20:28:28 on 32.0 3.0 each
11 test15.mkv 2022-12-04 21:02:10 431311989 11.836468 nvencc nvencc 00:02:18 h.264 auto P4 NaN 20:28:28 on 32.0 4.0 disabled
12 test18.mkv 2022-12-04 22:45:10 453180456 11.265293 handbrake x265 01:28:14.200000 h.265 auto slow 20.0 NaN NaN 25.0 4.0 NaN
13 test23.mkv 2022-12-05 00:30:16 473814634 10.774700 handbrake nvenc_h265 00:04:58 h.265 auto medium 28.0 NaN NaN NaN NaN NaN
14 test24.mkv NaT 476862830 10.705826 handbrake nvenc_h265 00:05:19 h.265 auto medium 28.0 NaN NaN NaN NaN NaN
15 test22_2.mkv NaT 485119066 10.523624 ffmpeg h264_nvenc 00:02:13 h.264 NaN medium 28.0 NaN NaN NaN NaN NaN
16 test19.mkv 2022-12-04 23:04:16 591502476 8.630920 handbrake x264 00:19:05 h.264 3.1 medium 20.0 NaN NaN NaN NaN NaN
17 test11.mkv 2022-12-04 20:30:02 615034372 8.300692 nvencc nvencc 00:02:00 h.264 auto P4 NaN 20:23:25 off 0.0 3.0 disabled
18 test05.mkv 2022-12-04 20:06:13 634038978 8.051888 nvencc nvencc 00:02:25 h.265 auto P7 NaN 20:23:25 off 0.0 0.0 disabled
19 test12.mkv 2022-12-04 20:33:41 635505228 8.033310 nvencc nvencc 00:02:12 h.264 auto P4 NaN 20:23:25 on 32.0 3.0 disabled
20 test06.mkv 2022-12-04 20:09:54 640328575 7.972798 nvencc nvencc 00:02:13 h.265 auto P4 NaN 20:23:25 off 32.0 0.0 disabled
21 test02.mkv 2022-12-04 19:46:37 642378626 7.947354 nvencc nvencc 00:01:50 h.265 auto P4 NaN 20:23:25 off 0.0 0.0 disabled
22 test03.mkv 2022-12-04 19:49:09 642378626 7.947354 nvencc nvencc 00:01:50 h.265 auto P4 NaN 20:23:25 off 0.0 0.0 disabled
23 test04.mkv 2022-12-04 20:01:42 673475955 7.580390 nvencc nvencc 00:01:49 h.265 auto P1 NaN 20:23:25 off 0.0 0.0 disabled
24 test07.mkv 2022-12-04 20:15:22 678693704 7.522113 nvencc nvencc 00:02:07 h.265 auto P4 NaN 20:23:25 on 32.0 0.0 disabled
25 Just Video.mkv 2022-12-20 10:50:46 5105210612 1.000000 NaN NaN - - - - NaN - - NaN NaN NaN

Ultimately, this is the command I used to encode many videos with nvencc:

NVEncC64.exe -i "inputfile" --video-metadata copy  --metadata copy --video-metadata \
title="title" --chapter-copy -c hevc --cqp 28 --bref-mode disabled --preset quality \
--tier high --lookahead 32 --aq --aq-strength 0 --level auto --colormatrix auto \
--transfer auto --colorprim auto --output-depth 8 --multipass None --mv-precision Auto \
--chromaloc auto --colorrange auto --avsync cfr  --audio-metadata 1?language=eng \
--audio-stream 1?:stereo --audio-codec 1?ac3 --audio-bitrate 1?160  --audio-metadata 1?clear \
--audio-metadata 1?title="Stereo" --audio-metadata 1?handler="Stereo" --sub-copy 1 \
--sub-disposition 1?default --sub-metadata  1?language='eng' -m default_mode:infer_no_subs 
-o "outputfile"

The main thing that drives nvencc quality is the --cqp parameter. Lower values give better quality but larger file sizes. Higher values give lower quality but smaller file sizes. I found that --cqp 28 gave a good balance of quality and file size. The video looks very similar to the original uncompressed video, but the file size is much smaller. Other configuration corresponds to subtitles, audio tracks, and color settings.