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 > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th May 2017, 03:15   #1  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
ffmpeg cliping luma values

Is it possible with ffmpeg and available filters to clip luma values below a certain level or would I have to use avi/vapour-synth?
Cary Knoop is offline   Reply With Quote
Old 20th May 2017, 05:30   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,374
Quote:
Originally Posted by Cary Knoop View Post
Is it possible with ffmpeg and available filters to clip luma values below a certain level or would I have to use avi/vapour-synth?
By "clip" did you mean replace with zero ? e.g. all values below a certain Y= threshold return zero ? All values above Y= threshold are untouched ?

One way is to use -vf lutyuv with an expression
https://ffmpeg.org/ffmpeg-filters.ht...gb_002c-lutyuv
https://ffmpeg.org/ffmpeg-utils.html...ion-Evaluation

eg. if the Y value is greater than 50, then return the value, otherwise zero

Code:
ffmpeg -i INPUT.ext -vf lutyuv=y='if(gte(val,50),val,0)' -c:v utvideo -an  OUTPUT.avi
You probably want to do for the U, V planes as well , or maybe U,V based on Y

Last edited by poisondeathray; 20th May 2017 at 05:32.
poisondeathray is offline   Reply With Quote
Old 20th May 2017, 05:46   #3  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Thanks, poisondeathray!

Actually I meant by 'clip' raise to the given lowest value.
I suppose the formula would be: lutyuv=y='if(gte(val,128),val,128)'

Just verifying, is this code 10 bit safe?
Cary Knoop is offline   Reply With Quote
Old 20th May 2017, 05:55   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,374
Quote:
Originally Posted by Cary Knoop View Post

Actually I meant by 'clip' raise to the given lowest value.
I suppose the formula would be: lutyuv=y='if(gte(val,128),val,128)'

Just verifying, is this code 10 bit safe?


"Clip" in video and image processing (and audio) terminology usually means "cut off"

To clarify, are you wanting to adjust a certain range of values ? Maybe a shadow boost etc....? Or did you mean raise the pedestal to a certain value ? - It's tricky because there are non linear ways to do it

ffmpeg filters used to be 8bit only. Not sure what the current status is.
poisondeathray is offline   Reply With Quote
Old 20th May 2017, 06:15   #5  |  Link
Cary Knoop
Cary Knoop
 
Cary Knoop's Avatar
 
Join Date: Feb 2017
Location: Newark CA, USA
Posts: 397
Quote:
Originally Posted by poisondeathray View Post
To clarify, are you wanting to adjust a certain range of values ? Maybe a shadow boost etc....? Or did you mean raise the pedestal to a certain value ? - It's tricky because there are non linear ways to do it
I am testing log footage. Luma value 128 (in 10 bit) is defined as absolute black, but the noise is actually shaped above and below this number. Some input transformations transform the below 128 values as well, with the result that in some cases (during color grading) more noise is introduced than is necessary. By setting all <128 values to 128 this is avoided.

But if the filters are 8 bit only it is not going to be useful, unless they would leave the actual bits alone and only set everything below 32 to 32 and still remain 10 bit integrity.

Do you have any alternatives you can think of?

Thanks for your help!
Cary Knoop is offline   Reply With Quote
Old 20th May 2017, 11:59   #6  |  Link
richardpl
Registered User
 
Join Date: Jan 2012
Posts: 271
lut* filters are not 8bit only any more. Make sure you use recent enough FFmpeg version.

Use something like: -vf "lutyuv='clip(val,128,255)'" to clip only luma.
richardpl is offline   Reply With Quote
Old 20th May 2017, 15:57   #7  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,374
Good to know richardpl

I verified valid 10bit is retained with lutyuv . (1023 in 10bit)

-vf "lutyuv='clip(val,128,1023)'"


One possible "gotcha" is the YUV<=>RGB mapping in other programs, especially with log, might not be what you expect it to be (e.g. when viewing LUT or reverse transform is applied). So double check with some tests if that "128" is the value you actually want it to be
poisondeathray 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 14:16.


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