rigaya / NVEnc

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

Deprecation Warning: yuvj444p Pixel Format & Issues with image2 Output #619

Open Aesthermortis opened 3 weeks ago

Aesthermortis commented 3 weeks ago

Deprecation of yuvj444p Pixel Format

Recent versions of ffmpeg have deprecated the yuvj444p pixel format. This format, which represents full-range YUV 4:4:4 video, is now considered outdated. The recommended approach is to use yuv444p and specify the color range (full or limited) using the -color_range option in ffmpeg.

Since NVEncC64 currently uses yuvj444p, this could lead to compatibility issues with updated ffmpeg workflows. It would be beneficial to update the encoder to output yuv444p and include the appropriate color range metadata.

Issues with image2 Output in NVEncC64

While trying to extract frames using the image2 output option in NVEncC64, I encountered issues where the generated image files were impossible to view with standard image viewers. To work around this, I had to use a pipe with ffmpeg to process and view the frames correctly.

It seems that the image2 output may be generating images in a format or manner that is not fully compatible with common image viewers.

NVEncC64.exe --avhw -i "!input_file!" --video-streamid 0 --cqp 0 --output-csp yuv444 --colorrange full --colormatrix bt709 --colorprim bt709 --transfer bt709 --vpp-colorspace hdr2sdr=hable,source_peak=1000.0,ldr_nits=100.0 --trim 21400:21400,118776:118776 -o - | ffmpeg -y -hide_banner -i - -pix_fmt rgba -compression_level 1 "!frames_folder!\%~n1_%%04d.png"

rigaya commented 3 weeks ago

yuvj444p

Since NVEncC64 currently uses yuvj444p

Although NVEncC might show input as yuvj444p, both AV_PIX_FMT_YUVJ444P and AV_PIX_FMT_YUV444P is mapped to NV_ENC_BUFFER_FORMAT_YUV444 and treated the same, so there should be no problem here.

Furthermore, we already have --colorrange auto, which enables us to copy characteristic from input file, therefore, --colorrange full can be copied if required.

image2 Output Unfortunately, the only format NVEncC supports for image2 output is AVIF format. For others, please use ffmpeg, or pipe to ffmpeg as you have done.

When using image2 output in ffmpeg, the codec (-c:v) shall be rawvideo, mjpeg, png, jpeg or other image codecs (depending on your image format).

However, NVEncC does not support conversion for most of these image formats. As NVEncC is developed to be hw video encoder, and to concentrate on that region, it only supports H.264, HEVC and AV1 video hardware encoding (no jpeg, png or other image codecs), and none of the other video/image codecs are supported for encoding.

As a result, only codec supported by image2 seems to be AV1(AVIF). (image2 seems to not support HEIC)

Creating AVIF images by NVEncC can be done by below. Here, to ensure not use B,P Frames which is not allowed in images, -b 0 --gop-len 1 is added.

x64\NVEncC64.exe -i input -c av1 -f image2 -o output_%06d.avif -b 0 --gop-len 1


When piping to ffmpeg, you can skip encoding by following. (NVEncC -c raw is actually in y4m format).

x64\NVEncC64.exe -i sakura_op.mpg --output-csp yuv444 -c raw -o - | x64\ffmpeg -y -f yuv4mpegpipe -i - -pix_fmt rgba -compressionlevel 1 F:\temp\test%06d.png