Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NVEnc Color Space and Raw pipe output #521

Closed
dan64 opened this issue Oct 1, 2023 · 8 comments
Closed

NVEnc Color Space and Raw pipe output #521

dan64 opened this issue Oct 1, 2023 · 8 comments

Comments

@dan64
Copy link

dan64 commented Oct 1, 2023

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
Copy link
Owner

rigaya commented Oct 2, 2023

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
Copy link
Author

dan64 commented Oct 2, 2023

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
Copy link
Owner

rigaya commented Oct 5, 2023

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

@dan64
Copy link
Author

dan64 commented Oct 5, 2023

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

@rigaya
Copy link
Owner

rigaya commented Oct 7, 2023

NVEnc 7.32 adds -c raw for raw output.

Additional options for raw output

  • -f, --output-format <string>

    • y4m (default)
      output in y4m format
    • raw
      output in raw format
  • --output-depth <int>
    8, 10, 12, 14, 16 is available. (default:8)

  • --output-csp <string>

    • yuv420 (default)
    • yuv444

    yuv422 will never be available, please convert from yuv444 if necessary.

@dan64
Copy link
Author

dan64 commented Oct 7, 2023

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
Copy link
Author

dan64 commented Oct 7, 2023

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
Copy link
Author

dan64 commented Oct 7, 2023

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

@dan64 dan64 closed this as completed Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants