1 (edited by damienbt 01-06-2021 15:47:07)

Topic: SVP encode HDR10 with hardware acceleration

Hi there,

as far as I understand it is now possible to encode HDR videos. However the HDR metadata isn't getting through while using nvidia HEVC encoding.
Would it be possible to update SVP transcoder to get to use NVEncC instead instead of ffmpeg, as NVEncC handles passthrough of HDR10 metadata
Software encoding takes ages, so I really would like to make it work through nvidia hw encoding

Otherwise this is a great piece of software : 4K HDR plays OK now with most players (mpv/vlc and directshow players), please keep doing a great job!

Regards,
Damien

Re: SVP encode HDR10 with hardware acceleration

> as far as I understand it is now possible to encode HDR videos

only after HDR->SDR conversion

> Would it be possible to update SVP transcoder to get to use NVEncC instead instead of ffmpeg

SVP doesn't use ffmpeg directly but via the mpv's interface (cause we want to pass a video through the Vapoursynth filter)

Re: SVP encode HDR10 with hardware acceleration

Ok thank you Chainik.
The recent progress made using avisynth let us play HDR videos through directshow players, any chance that it may be adapted to the chain MPV/vapoursynth ?

FYI I was one of the ffdshow developers, I tried recently to get it back to the code in order to adapt colorspace conversion to 10bits but there is too much old code to adapt, especially the mmx intrinsics on which rely the colorespace converters (to be upgraded to SSE2 intrinsics) and also to make it compatible to visual studio 2019.... So I gave up for now

Re: SVP encode HDR10 with hardware acceleration

> any chance that it may be adapted to the chain MPV/vapoursynth ?

afaik, there's no maintainer for the mpv's encoding mode...

Re: SVP encode HDR10 with hardware acceleration

BTW the new version have a tone mapping "shader" (in fact, an OpenCL routine) implemented in the Vapoursynth plugin, so both transcoder and SVPcast can now give satisfactory colors w/o using ffmpeg's "tonemap" filter (which is probably better, but _super_ slow).

6 (edited by damienbt 08-06-2021 19:26:41)

Re: SVP encode HDR10 with hardware acceleration

Thanks Chainik but I hesitate between those 2 scenarios :
1/ Keep on pluggin in my PC with external UHD player
2/ converting my UHD discs to SVP+MKV vidéos to avoid plugging in the player and having a ready to play library
I will loose HDR in scenario 2 so I'll stick to scenario 1 for now.
If I understand correctly, MPV should "only" have to passthrough HDR metadata besides the 10 bits colors matrix to the vapoursynth plugin and then to the encoder ?
In the past I played around with mplayer code, it is not too complicated I think as this is a mapping between mplayer arguments with ffmpeg primitives and options...

Re: SVP encode HDR10 with hardware acceleration

> MPV should "only" have to passthrough HDR metadata

yep

8 (edited by damienbt 10-06-2021 13:59:42)

Re: SVP encode HDR10 with hardware acceleration

Hi again,

I took a look on MPV & ffmpeg code : so actually (these are my assertions, I may be wrong)
1/ ffmpeg team is working on passing through HDR metadata (static & dynamic HDR10+/DV) to the encoder (h264/hevc) : https://trac.ffmpeg.org/ticket/7037
As long as this won't be achieved, it won't be possible to transcode with SVP while keeping HDR data (although 10 bits colors encoding is working). They seem to be almost there
2/ Adapt MPV code in the command line arguments to input the right parameters to ffmpeg : this is the easy part once ffmpeg will have done the job

Another approach is to extract and then reinject HDR data in the final file as NVEnC does (open source nvidia encoder) or else ffmpeg + Fastflix tool to reinject https://github.com/cdgriffith/FastFlix/ … /tag/3.4.0

Re: SVP encode HDR10 with hardware acceleration

> They seem to be almost there

yeah, "Opened 3 years ago"... just another 3 years and it'll work! big_smile

Re: SVP encode HDR10 with hardware acceleration

Chainik wrote:

> They seem to be almost there

yeah, "Opened 3 years ago"... just another 3 years and it'll work! big_smile

:-) I agree, except that this time this is just a matter of passthrough. They handle now the 10 bits pipeline correctly and one can submit HDR10 settings manually to the x265 encoder.

I just tested Fastflix with x265 and NvencC : HDR10 metada is preserved in the final video file. So the proof of concept is there.
HDR10+ too but not tested. Dolby vision I'm not sure

11

Re: SVP encode HDR10 with hardware acceleration

Now that ffmpeg 7.0 is out, has anything changed?

Re: SVP encode HDR10 with hardware acceleration

Use NVEncC encoding externally:

Encode your video with NVEncC using a separate tool like Nvidia NVENC SDK or Handbrake (with NVENC encoder selected).
SVP can then process the encoded video without the HDR metadata issue.
Consider alternative hardware encoding options:

If you have a recent Intel Quick Sync Video (QSV) capable CPU, SVP can leverage QSV encoding which might handle HDR metadata better.

Re: SVP encode HDR10 with hardware acceleration

I encode HDR10 videos using SVPCode with the H265 HEVC/NVENC codec by adding these commands into the opts: box.  "color_primaries=bt2020" "color_trc=smpte2084" "colorspace=bt2020nc" when adding these commands, the video retains HDR after transcoding with TensorRT RIFE.

Post's attachments

Screenshot (9438.png 463.83 kb, 31 downloads since 2024-04-18 

Re: SVP encode HDR10 with hardware acceleration

chesley96 wrote:

I encode HDR10 videos using SVPCode with the H265 HEVC/NVENC codec by adding these commands into the opts: box.  "color_primaries=bt2020" "color_trc=smpte2084" "colorspace=bt2020nc" when adding these commands, the video retains HDR after transcoding with TensorRT RIFE.

Hi,

I have adopted the settings as in your screenshot. However, at level=5.1 it makes a mistake and does not start the transcode. Can you tell me what level=5.1 does exactly?

15 (edited by _Shorty 03-06-2024 23:37:22)

Re: SVP encode HDR10 with hardware acceleration

I have written a python script to take files that probably have bitrate overkill and make them smaller by targeting a specific VMAF score to suit my needs.  In it I use ffprobe to check for HDR metadata, and when it exists I extract it and ensure the encoding job uses the same metadata in the x265 command so the output file is still an HDR file when the input file is an HDR file.  I don't see why SPV couldn't do the same thing.  I think we can probably manually accomplish this by editing the x265 parameters, but SPV should be able to automate that.

edit:  Well, maybe not.  An example file I have would need these parameters:

X265 Parameters:
hdr10=1
hdr10-opt=1
repeat-headers=1
colorprim=bt2020
range=limited
transfer=smpte2084
colormatrix=bt2020nc
master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(40000000,50)
max-cll=1655,117

But when you try to add those manually to the x265 parameters the dialog box doesn't let you enter the last two lines properly.  It interprets the commas as new-line characters and you get a bunch of new lines added that are nonsensical as a result, like this:

master-display=G(13250
34500)B(7500
3000)R(34000
16000)WP(15635
16450)L(40000000
50)
max-cll=1655
117

edit2: Unfortunately the parameters didn't work for me anyway.  But hopefully the devs can get this working.  Doesn't seem like too hard of a job to extract the necessary metadata and use that going forward from there.

16 (edited by AlvinB 12-06-2024 08:10:23)

Re: SVP encode HDR10 with hardware acceleration

damienbt wrote:

Hi there,

as far as I understand it is now possible to encode HDR videos. However the HDR metadata isn't getting through while using nvidia HEVC encoding.
Would it be possible to update SVP transcoder to get to use NVEncC instead instead of ffmpeg, as NVEncC handles passthrough of HDR10 metadata
Software encoding takes ages, so I really would like to make it work through nvidia hw encoding

Otherwise this is a great piece of software : 4K HDR plays OK now with most players (mpv/vlc and directshow players), please keep doing a great job!

Regards,
Damien
https://studyhelper.com/argumentative-essay-samples

You're right, NVEncC supports passthrough of HDR10 metadata, which ffmpeg currently lacks when using Nvidia HEVC encoding. Switching to NVEncC in SVP transcoder would indeed be beneficial for preserving HDR metadata during the encoding process.

Re: SVP encode HDR10 with hardware acceleration

AlvinB wrote:

You're right, NVEncC supports passthrough of HDR10 metadata, which ffmpeg currently lacks when using Nvidia HEVC encoding. Switching to NVEncC in SVP transcoder would indeed be beneficial for preserving HDR metadata during the encoding process.

As I just mentioned, you just need to tell ffmpeg what to use.  Doesn't look like SVP currently passes along all commands properly, though.

18 (edited by chesley96 21-06-2024 01:51:09)

Re: SVP encode HDR10 with hardware acceleration

I know how to retain HDR in SVP 4 Pro. Used Ai to help with the commands. https://ibb.co/L9JStyG   edit: oh, hell I forgot I already posted here lol

Re: SVP encode HDR10 with hardware acceleration

Unfortunately, the HDR after transcoding is not a real HDR! The HDR metadata will still be removed :-/