Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st December 2017, 09:45   #21  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 5,491
@Atak_Snajpera: Thanks for the example!
----
@all: Is there a way to do this in Vapoursynth? Only thing I saw was the HDR10 to SDR with Hable tone-mapping'-thread.
I also read somewhere that tone-mapping basically is wrapping zimg, so this should be possible with Vapoursynth (for someone who knows their way around Python&Vapoursynth), but is there a script out there which basically brings the tone-mapping functionality to Vapoursynth?

Cu Selur
__________________
Hybrid here in the forum, homepage
Selur is online now   Reply With Quote
Old 2nd January 2018, 00:35   #22  |  Link
dipje
Registered User
 
Join Date: Oct 2014
Posts: 260
zimg is the scaling library built into vapoursynth. So the vs.resize.xxxx functions are Z.Img routines. (And I used a lot of Vapoursynth's Resize docs in figuring out stuff for ffmpeg zscale filter :P).

So after using zimg / vs.resize to convert to linear RGB in floating point, you can tonemap with basic math in Python if you know the algorithm. The thread about it you're already active in: https://forum.doom9.org/showthread.php?t=174415
dipje is offline   Reply With Quote
Old 4th January 2018, 08:14   #23  |  Link
Kef71
Registered User
 
Join Date: Jan 2004
Location: Amsterdam
Posts: 7
ITU has released recommendation for HDR -> SDR conversion. You can find it here: https://www.itu.int/pub/R-REP-BT.2390-3-2017

Look at page 19:

5.4.1 Mapping to display with limited brightness range
Kef71 is offline   Reply With Quote
Old 4th January 2018, 10:35   #24  |  Link
dipje
Registered User
 
Join Date: Oct 2014
Posts: 260
Do note that they're talking about taking the full reference signal (between basically 0 and 10.000 nits) and display it on a normal HDR screen (which for instance can take a maximum of 1.000 nits).

That being said, in figure 20 they show multiple lines for target displays with different brightness capabilities, and they show a blue line for a screen with 100 nits max, which is a nice SDR target.

I'm no math expert, so not really looking at that, but just the text and the graphs basically describe what looks like a pretty normal 'knee' to map the values? Which I boil down in my mind to 'they are recommending to clip signals lower than a certain threshold, clip signals higher than a certain threshold, and use a s-curve for the left-over signal so it looks nice with rolled-off shadows and rolled-off highlights on the target display'. Am I wrong?

This will not really show any detail that might be present in the signal of 1000 nits or brighter, it just rolls it off and compresses it in the upper region. Algorithms like Hable are ment to recover some of those details, right?
dipje is offline   Reply With Quote
Old 4th January 2018, 11:08   #25  |  Link
Kef71
Registered User
 
Join Date: Jan 2004
Location: Amsterdam
Posts: 7
Quote:
Originally Posted by dipje View Post
Do note that they're talking about taking the full reference signal (between basically 0 and 10.000 nits) and display it on a normal HDR screen (which for instance can take a maximum of 1.000 nits).
Agreed, HDR10 supports up to 4,000 nits peak brightness, with a current 1,000 nit peak brightness target, 10-bit color depth and capable of displaying everything in the Rec.2020 color space.

Quote:
Originally Posted by dipje View Post
That being said, in figure 20 they show multiple lines for target displays with different brightness capabilities, and they show a blue line for a screen with 100 nits max, which is a nice SDR target.
Yep, agreed.

Quote:
Originally Posted by dipje View Post
I'm no math expert, so not really looking at that, but just the text and the graphs basically describe what looks like a pretty normal 'knee' to map the values? Which I boil down in my mind to 'they are recommending to clip signals lower than a certain threshold, clip signals higher than a certain threshold, and use a s-curve for the left-over signal so it looks nice with rolled-off shadows and rolled-off highlights on the target display'. Am I wrong?
AFAIK, you are correct in your assumption.

Quote:
Originally Posted by dipje View Post
This will not really show any detail that might be present in the signal of 1000 nits or brighter, it just rolls it off and compresses it in the upper region. Algorithms like Hable are ment to recover some of those details, right?
It is an official recommendation not tied to any specific hardware so yes, there are compromises to be made. Remember that the scale is logarithmic so most of the information maps 1:1 from UHD to SDR. Just need to compress a little bit in the upper and lower regions to get a picture as close as possible to UHD. Hable, Reinhard, Mobius are just slightly different shapes of this s-curve as far as I know.

edit: UHD to SDR blu-ray most likely follow this recommendation.

Last edited by Kef71; 4th January 2018 at 11:15.
Kef71 is offline   Reply With Quote
Old 6th February 2018, 13:14   #26  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 6,450
Single threaded tonemapping is creating huge bottleneck on my 8C/16T CPU. Is there any way to speed up zscale by using multi-threading?


Atak_Snajpera is offline   Reply With Quote
Old 6th February 2018, 13:45   #27  |  Link
dipje
Registered User
 
Join Date: Oct 2014
Posts: 260
From my Vapoursynth experience it's not zscale that is the speed limiting factor, but I'm only guessing.
ffmpeg isn't very good at multi-threading at all, and I think the tonemap filter is just made as a proof of concept as a single-threaded demo. Guess you will have to ask on the ffmpeg-user list.
dipje is offline   Reply With Quote
Old 9th February 2018, 20:26   #28  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
Quote:
Originally Posted by Atak_Snajpera View Post
dipje you are my hero! Thank you very much for your help! I would never figure that on my own.

I'm posting example command line for those who what to convert HDR to SDR and pipe result to encoder.

Code:
ffmpeg.exe -loglevel panic -i script.avs -vf zscale=tin=smpte2084:min=bt2020nc:pin=bt2020:rin=tv:t=smpte2084:m=bt2020nc:p=bt2020:r=tv,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -strict -1 -f yuv4mpegpipe - | x264_x64.exe --stdin y4m --output "C:\video.264" -
@Atak_Snajpera - I tried your command line and get this error - x264 [error]: could not open input file `-' - Do you know why? I'm using 32 bit ffmpeg and x264 because I have 32 bit avisynth installed.
tyee is offline   Reply With Quote
Old 9th February 2018, 20:28   #29  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 5,491
Remove the '-loglevel panic' to see wether ffmpeg complains about having problems with you avs file,..
__________________
Hybrid here in the forum, homepage
Selur is online now   Reply With Quote
Old 9th February 2018, 20:32   #30  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 6,450
See how it is done in ripbot264. Add some HDR footage and see C:\Temp\RipBot264temp\Job1\job1_EncodeVideoPass1.cmd.
Probably you made a typo somewhere...
Atak_Snajpera is offline   Reply With Quote
Old 9th February 2018, 20:35   #31  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
It's getting further now but still errors -

Code:
Input #0, avisynth, from 'Standard.avs':
  Duration: 00:01:56.83, start: 0.000000, bitrate: 0 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x532, 23.98 fps, 23.98 tbr, 23.98
 tbn, 23.98 tbc
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'smpte2084'
[zscale @ 19ce05c0] Unable to parse option value "smpte2084"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'bt2020nc'
[zscale @ 19ce05c0] Unable to parse option value "bt2020nc"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'bt2020'
[zscale @ 19ce05c0] Unable to parse option value "bt2020"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'tv'
[zscale @ 19ce05c0] Unable to parse option value "tv"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'smpte2084'
[zscale @ 19ce05c0] Unable to parse option value "smpte2084"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'bt2020nc'
[zscale @ 19ce05c0] Unable to parse option value "bt2020nc"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'bt2020'
[zscale @ 19ce05c0] Unable to parse option value "bt2020"
[zscale @ 19ce05c0] [Eval @ 0028e6cc] Undefined constant or missing '(' in 'tv'
[zscale @ 19ce05c0] Unable to parse option value "tv"
[zscale @ 19ce05c0] [Eval @ 0028e71c] Undefined constant or missing '(' in 'smpte2084'
[zscale @ 19ce05c0] Unable to parse option value "smpte2084"
[zscale @ 19ce05c0] Error setting option tin to value smpte2084.
[Parsed_zscale_0 @ 19ce0b80] Error applying options to the filter.
[AVFilterGraph @ 031b18e0] Error initializing filter 'zscale' with args 'tin=smpte2084:min=bt2020nc:
pin=bt2020:rin=tv:t=smpte2084:m=bt2020nc:p=bt2020:r=tv'
Error opening filters!
x264 [error]: could not open input file `-'
tyee is offline   Reply With Quote
Old 9th February 2018, 20:36   #32  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 6,450
Update your ffmpeg https://ffmpeg.zeranoe.com/builds/
Atak_Snajpera is offline   Reply With Quote
Old 9th February 2018, 20:43   #33  |  Link
tyee
Registered User
 
Join Date: Oct 2001
Posts: 397
That did it, thanks! This will give me 8 bit output, yes? I thought I read somewhere that ffmpeg did not support 10 bit yet?

Update - confirmed it is 8 bit.

Last edited by tyee; 9th February 2018 at 20:48.
tyee is offline   Reply With Quote
Old 9th February 2018, 22:50   #34  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 4,945
ffmpeg does support 10 bit input/output. But "format=yuv420p" sets 8 bit. 10 bit equivalent is called "yuv420p10le". (I haven't looked at the complete filter list, this is just the last filter.) And if you pipe to x264cli/x265cli you have to use a 10 bit build and possibly explicity set 10 bit output if it's a multi-depth build.
sneaker_ger is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:38.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.