rigaya / NVEnc

NVENCによる高速エンコードの性能実験
https://rigaya34589.blog.fc2.com/blog-category-17.html
Other
1.03k stars 108 forks source link

Parameter issues,... (--vpp-subburn and --fps) #560

Open Selur opened 4 months ago

Selur commented 4 months ago

I wanted to try the '--vpp-subburn' option using:

NVEncC --avhw  -i "G:\TestClips&Co\files\5000frames.mp4" --fps 25.000 --codec av1 --sar 1:1 --output-depth 10 --vbr 0 --vbr-quality 23.00 --aq --aq-strength 5 --aq-temporal --gop-len 0 --ref 7 --multiref-l0 3 --multiref-l1 3 --bframes 3 --bref-mode auto --mv-precision Q-pel --preset quality --colorrange limited --colormatrix bt470bg --vpp-resize cubic --output-res 640x480 --vpp-gauss disabled --cuda-schedule sync --vpp-subburn filename="G:\TestClips&Co\files\Subtitles\TITLE_1_0_lang_en.idx" --output "J:\tmp\5000frames_1_2024-02-26@17_20_55_2410_01.av1"
--------------------------------------------------------------------------------
J:\tmp\5000frames_1_2024-02-26@17_20_55_2410_01.av1
--------------------------------------------------------------------------------
avcuvid: Unknown input option: framerate=25/1, ignored.
NVEncC (x64) 7.41 (r2681) by rigaya, Jan 22 2024 13:02:15 (VC 1929/Win)
OS Version     Windows 11 x64 (22631) [UTF-8]
CPU            AMD Ryzen 9 7950X 16-Core Processor [5.52GHz] (16C/32T)
GPU            #0: NVIDIA GeForce RTX 4080 (9728 cores, 2505 MHz)[PCIe4x16][551.61]
NVENC / CUDA   NVENC API 12.1, CUDA 12.4, schedule mode: sync
Input Buffers  CUDA, 20 frames
Input Info     avcuvid: H.265/HEVC, 640x480, 25/1 fps
AVSync         vfr
Vpp Filters    cspconv(p010 -> yv12(16bit))
               subburn: G:\TestClips&Co\files\Subtitles\TITLE_1_0_lang_en.idx, scale x0.00
               cspconv(yv12(16bit) -> p010)
Output Info    AV1 main 10bit @ Level auto
               640x480p 1:1 25.000fps (25/1fps)
Encoder Preset quality
Rate Control   VBR
Multipass      none
Bitrate        0 kbps (Max: 0 kbps)
Target Quality 23.00
Initial QP     I:20  P:23  B:25
QP range       I:0-255  P:0-255  B:0-255
QP Offset      cb:0  cr:0
VBV buf size   auto
Split Enc Mode auto
Lookahead      off
GOP length     250 frames
B frames       3 frames [ref mode: middle]
Ref frames     7 frames, MultiRef L0:auto L1:auto
AQ             on (spatial, temporal, strength 5)
Part size      max auto / min auto
Tile num       columns auto / rows auto
TemporalLayers max 1
Refs           forward auto, backward auto
VUI            matrix:bt470bg,range:limited
Others         mv:Q-pel
resize: Invalid parameter.

fails. removing the:

 --vpp-subburn filename="G:\TestClips&Co\files\Subtitles\TITLE_1_0_lang_en.idx"

part and only calling:

NVEncC --avhw  -i "G:\TestClips&Co\files\5000frames.mp4" --fps 25.000 --codec av1 --sar 1:1 --output-depth 10 --vbr 0 --vbr-quality 23.00 --aq --aq-strength 5 --aq-temporal --gop-len 0 --ref 7 --multiref-l0 3 --multiref-l1 3 --bframes 3 --bref-mode auto --mv-precision Q-pel --preset quality --colorrange limited --colormatrix bt470bg --vpp-resize auto --output-res 640x480 --vpp-gauss disabled --cuda-schedule sync --output "J:\tmp\5000frames_1_2024-02-26@17_20_55_2410_01.av1"
--------------------------------------------------------------------------------
J:\tmp\5000frames_1_2024-02-26@17_20_55_2410_01.av1
--------------------------------------------------------------------------------
avcuvid: Unknown input option: framerate=25/1, ignored.
NVEncC (x64) 7.41 (r2681) by rigaya, Jan 22 2024 13:02:15 (VC 1929/Win)
OS Version     Windows 11 x64 (22631) [UTF-8]
CPU            AMD Ryzen 9 7950X 16-Core Processor [5.52GHz] (16C/32T)
GPU            #0: NVIDIA GeForce RTX 4080 (9728 cores, 2505 MHz)[PCIe4x16][551.61]
NVENC / CUDA   NVENC API 12.1, CUDA 12.4, schedule mode: sync
Input Buffers  CUDA, 20 frames
Input Info     avcuvid: H.265/HEVC, 640x480, 25/1 fps
AVSync         vfr
Vpp Filters    copyDtoD
Output Info    AV1 main 10bit @ Level auto
               640x480p 1:1 25.000fps (25/1fps)
Encoder Preset quality
Rate Control   VBR
Multipass      none
Bitrate        0 kbps (Max: 0 kbps)
Target Quality 23.00
Initial QP     I:20  P:23  B:25
QP range       I:0-255  P:0-255  B:0-255
QP Offset      cb:0  cr:0
VBV buf size   auto
Split Enc Mode auto
Lookahead      off
GOP length     250 frames
B frames       3 frames [ref mode: middle]
Ref frames     7 frames, MultiRef L0:auto L1:auto
AQ             on (spatial, temporal, strength 5)
Part size      max auto / min auto
Tile num       columns auto / rows auto
TemporalLayers max 1
Refs           forward auto, backward auto
VUI            matrix:bt470bg,range:limited
Others         mv:Q-pel

encoded 5000 frames, 1785.08 fps, 20.91 kbps, 0.50 MB
encode time 0:00:02, CPU: 0.2%, GPU: 66.7%, VE: 44.3%, VD: 19.0%, GPUClock: 2685MHz, VEClock: 2125MHz
frame type IDR   20
frame type I     20,  total size  0.01 MB
frame type P   1260,  total size  0.01 MB
frame type B   3720,  total size  0.48 MB

works.

So my guess is that: a. I'm not properly using the '--vpp-subburn' option and the error message is not really helping. b. "--fps" is broken, independent whether I use --fps <int/int> or --fps <float> I see:

avcuvid: Unknown input option: framerate=FRACTION, ignored

Cu Selur

Selur commented 4 months ago

using:

NVEncC --avhw  -i "G:\TestClips&Co\files\5000frames.mp4" --fps 25.000 --codec av1 --sar 1:1 --output-depth 10 --vbr 0 --vbr-quality 23.00 --aq --aq-strength 5 --aq-temporal --gop-len 0 --ref 7 --multiref-l0 3 --multiref-l1 3 --bframes 3 --bref-mode auto --mv-precision Q-pel --preset quality --colorrange limited --colormatrix bt470bg --vpp-resize auto --output-res 640x480 --vpp-gauss disabled --cuda-schedule sync --vpp-subburn filename="G:\TestClips&Co\files\Subtitles\japanese_utf-8.srt" --output "J:\tmp\5000frames_1_2024-02-26@17_46_56_7710_01.av1"

does work. (fps still gets ignored) Okay, --vppsubburn does work and simply throws unusable warnings if non-supported subtitles types are used. => would be nice if you could look into --fps and add some additional info to --vpp-subburn what formats are supported.

rigaya commented 4 months ago

I'm not sure without the exact subtitle file, but also I suppose it was not supported subtitle file.

Supported formats can be checked by --check-formats, and codecs by --check-codecs. (Unfortunately, it is now mixed up with audios and subtitles, might be better to separate them if I can in the future).

--fps only exists to set fps for raw formats which does not have framerate information in its file, and --fps is only a bitrate calculation hint for other readers including --avhw. I have changed the documentation.

Selur commented 4 months ago

Thanks for clearing that up, I'll check --check-formats and --check-codecs.

--fps only exists to set fps for raw formats which does not have framerate information in its file, and --fps is only a bitrate calculation hint for other readers including --avhw. I have changed the documentation.

Okay, in my opinion, that is unexpected, shouldn't this always overwrite the input frame rate when set? So that if you want to encode 25fps content at 50fps (just increasing the, maybe wrong, video playback speed) it could be done with this.

rigaya commented 4 months ago

Actually, I cannot come up of overwriting framerate being useful, as it easily causes audio-video desync.

NVEnc had many reports of audio-video desync in the past, especially in VFR videos but fps set. (Removing --fps might do, but there were many reports in the past...)

To avoid these cases, NVEnc now tries to maintain the original timestamp (by some offset) as much as possible, thus reducing this kind of audio-video sync errors.