rigaya / NVEnc

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

NVEnc Color Space and Raw pipe output #521

Closed dan64 closed 11 months ago

dan64 commented 11 months ago

I'd like to be able to play NVEnc output inside Vapoursynth scripts. There is an hint (using ffmpeg) in the following post: https://forum.doom9.org/showthread.php?p=1925640#post1925640 Willing to adapt this example using NVEnc I need to be able to provide in output a raw video with a given colorspace (in the example provided is yuv420p), in this case I will be able to replace ffmpeg with NVEnc. I tried with the last version "NVEncC (x64) 7.31 (r2580)" using the following command: "NVEncC64.exe --avhw --input Test.mp4 --lossless --output-format raw --output -" but actually the output is compressed as " H.264/AVC Unknown @ Level auto ". To check this I run the following command: "NVEncC64.exe --avhw --input Test.mp4 --lossless --output-format raw --output Test.raw" and the Mediainfo analysis of the output file Test.raw, provides the following information: Video ID : 1 Format: AVC Format/Info : Advanced Video Codec Format profile : High 4:4:4 Predictive@L3 Format settings : CABAC / 3 Ref Frames Format settings, CABAC : Yes Format settings, Reference : 3 frames Codec ID : V_MPEG4/ISO/AVC Duration : 2 min 2 s Bit rate : 9 176 kb/s Width : 720 pixels Height : 300 pixels Display aspect ratio : 2.40:1 Frame rate mode : Constant Frame rate : 25.000 FPS Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 1.699 Stream size: 133 MiB (100%)

that confirm that the output is compressed.

Can you add the option to provided in output a "true" uncompressed raw video with a given colorspace ?

Thank You, Dan

rigaya commented 11 months ago

Raw output from NVEncC is difficult to implement, as it is developed as an encoder.

Also, I'm not being able to get what you need here. Raw pipe output does not need encoding, therefore I don't get the intention of using NVEncC in this purpose. (NVEncC is an encoder)

dan64 commented 11 months ago

You are right, an uncompressed raw output is not necessary for NVEncC if we see it as an encoder only. But with the time, to this encoder has been added a lot of filters. So now NVEncC is not only an encoder, but also a filters suite. In order to have a "preview" of the effect of these filters on output, I was thinking to use the "preview" utility of Vapoursynth "vsedit". To be able to use this utility a need a script that is able to provide in output uncompressed frames from NVEncC. This the main reason of my request. As work around I could pipe the compressed output of NVEncC to ffmepg, but for unknown reason I get the following error: "pipe: Invalid data found when processing input".

rigaya commented 11 months ago

I see what you mean, so you want to use as a filter. I might try adding raw output to NVEncC.

dan64 commented 11 months ago

Many thanks for your understanding, this extension will be very useful for building a preview of NVEnC filters.

rigaya commented 11 months ago

NVEnc 7.32 adds -c raw for raw output.

Additional options for raw output

dan64 commented 11 months ago

I tried to test your changes with the following command: NVEncC64.exe --avhw --input "TestVideo.mp4" -c raw --output-csp yuv420 --output-depth 8 --output-format raw --output - | ffplay.exe -f rawvideo -pixel_format yuv420p -video_size 720x300 -i -

but the output is the following

https://i.ibb.co/Wzc9Mf1/preview-NVEnc-Test-Video-v2.jpg

The colors are not properly shown, what's wrong ?

P.S. The video used for the test is the following: https://filebin.net/7x2grfk1ompmh53w/TestVideo.mp4

dan64 commented 11 months ago

I obtained the same wrong output using ffmpeg: ffmpeg.exe -i "TestVideo.mp4" -vcodec rawvideo -pix_fmt yuv420p -f rawvideo - | ffplay.exe -f rawvideo -pixel_format yuv420p -video_size 720x300 -i - It seems that the problem is on ffplay side.

dan64 commented 11 months ago

Ok, I was able to test successfully the changes in 7.32.

TEST OUTPUT RAW

> NVEncC64.exe --avhw --input "TestVideo.mp4" -c raw --output-csp yuv420 --output-depth 8 --output-format raw --output TestVideo2.yuv.raw > ffplay.exe -f rawvideo -pixel_format yuv420p -video_size 720x300 -i TestVideo2.yuv.raw

TEST OUTPUT Y4M

> NVEncC64.exe --avhw --input "TestVideo.mp4" -c raw --output-csp yuv420 --output-depth 8 --output-format y4m --output TestVideo2.y4m.raw > ffplay.exe -f yuv4mpegpipe -i TestVideo2.yuv.raw

Many thanks Dan