<p>This is the original expression to be implemented.</p>

<pre><code>x &gt; 0.14996582 ? (pow(10,0, (x - 0.385537) / 0.2471896) - 0.0522720) / 5.5555556 : (x - 0.092809) / 5.367655
</code></pre>

<p>where <code>x</code> is the pixel intensity normalized to [0,1]. <code>x</code> is linear, so gamma returns identity. </p>

<p>I'm going to assume the <code>0</code> in the pow expression is an extraneous arg since the linked reference at <a href="http://strattoncamera.com/pdf/11-06-30_Alexa_LogC_Curve.pdf" rel="nofollow noreferrer">http://strattoncamera.com/pdf/11-06-30_Alexa_LogC_Curve.pdf</a> depicts pow() as having only two arguments. I'm also assuming that the input is 16-bit full-range integer RGB.</p>

<pre><code>ffmpeg -apply_trc linear -i in%d.exr
       -vf "lutrgb=r='if(gt(val/maxval,0.14996582),maxval*((pow(10, (val/maxval-0.385537)/0.2471896)-0.0522720)/5.5555556),maxval*((val/maxval-0.092809)/5.367655))':
                   g='if(gt(val/maxval,0.14996582),maxval*((pow(10, (val/maxval-0.385537)/0.2471896)-0.0522720)/5.5555556),maxval*((val/maxval-0.092809)/5.367655))':
                   b='if(gt(val/maxval,0.14996582),maxval*((pow(10, (val/maxval-0.385537)/0.2471896)-0.0522720)/5.5555556),maxval*((val/maxval-0.092809)/5.367655))'"
        out%d.tiff
</code></pre>

CC BY-SA 4.0
2018-10-02T07:21:52.500Z
Thanks for much for helping out @gyan, tried it and its still blown out but seems this is definitely the filter to use, the highlights got completely blown up
tankbusta
CC BY-SA 4.0
2018-10-02T08:29:25.090Z
You need to verify range and the expr. How are you viewing the TIFFs?
Gyan
CC BY-SA 4.0
2018-10-02T08:34:46.643Z
doing it in nuke / after effects and i need it to output EXR's not TIFFS but both are ok :)
tankbusta
CC BY-SA 4.0
2018-10-02T08:53:05.800Z
FFmpeg does not have an EXR encoder. Are you sure the input is full range?
Gyan
CC BY-SA 4.0
2018-10-02T09:34:28.330Z
i meant to type i want the output to be mov eventually when i can sticth the files but im just viwing the images in after effects
tankbusta
CC BY-SA 4.0
2018-10-02T09:34:39.257Z
also yes input is full range as nuke handles it just fine
tankbusta
CC BY-SA 4.0
2018-10-02T13:40:31.560Z
I ended up doing it in OpenImageIO, FFMPEG couldn't do the job for me
tankbusta
CC BY-SA 4.0
2018-10-02T05:57:38.397Z
2018-10-02T05:57:38.397Z
Gyan
<p>Im trying to use a expression from NUKE (to convert an exr sequence from its native format into AlexaLogC. Now ive got an expression from nuke which is the following</p>

<pre><code>x &gt; 0.14996582 ? (pow(10,0, (x - 0.385537) / 0.2471896) - 0.0522720) / 5.5555556 : (x - 0.092809) / 5.367655 
</code></pre>

<p>been trying to find a spot to place this inside a FFMPEG filter to allow it to bring my footage to the right starting point so i can apply the lut from on set on it.</p>

<p>Was wondering if anybody here had advice on how to correctly filter this into ffmpeg.</p>

CC BY-SA 4.0
2018-10-01T13:15:34.037Z
That expr looks like it works on normalized values. What is the pixel format? RGB 16-bit? pow has three arguments - what is the definition?
Gyan
CC BY-SA 4.0
2018-10-01T15:45:36.080Z
RGB 16BIT yeahw
tankbusta
CC BY-SA 4.0
2018-10-01T15:46:03.077Z
Basically need ffmpeg to being it to the alexa color space so i can use a lut on it from DI
tankbusta
CC BY-SA 4.0
2018-10-01T16:06:08.520Z
pow has three arguments - what is the definition?
Gyan
CC BY-SA 4.0
2018-10-01T16:15:34.580Z
@Gyan its not HDR
tankbusta
CC BY-SA 4.0
2018-10-01T16:16:49.750Z
2048 X 968 Alexa Scan maybe it is HDR who knows but the whites are blown out and they come in better when i use the alexalogc curve in nuke need that in ffmpeg
tankbusta
CC BY-SA 4.0
2018-10-01T16:21:29.133Z
I still need the definition of nuke's 3-arg pow function that is shown here.
Gyan
CC BY-SA 4.0
2018-10-01T16:22:36.247Z
@Gyan where can i get that info ? i just copy pasted the expression from nukes color preferences
tankbusta
CC BY-SA 4.0
2018-10-01T16:32:07.653Z
Probably the manual or other Nuke users.
Gyan
CC BY-SA 4.0
2018-10-01T16:36:32.313Z
@Gyan so assuming i get that there is a way to fire this into ffmpeg ?
tankbusta
CC BY-SA 4.0
2018-10-01T16:57:18.167Z
yes, using a combination of filters
Gyan
CC BY-SA 4.0
2018-10-01T16:59:42.657Z
@Gyan im looking around now for it
tankbusta
CC BY-SA 4.0
2018-10-01T17:00:08.443Z
@Gyan cuz this is just the basic AlexaV3LogC curve from nuke
tankbusta
CC BY-SA 4.0
2018-10-01T17:00:40.743Z
@Gyan
http://strattoncamera.com/pdf/11-06-30_Alexa_LogC_Curve.pdf
tankbusta
CC BY-SA 4.0
2018-10-01T17:09:28.450Z
I only see two args in `(t > e * cut + f) ? (pow(10, (t - d) / c) - b) / a: (t - f) / e`
Gyan
CC BY-SA 4.0
2018-10-01T17:14:26.850Z
@Gyan yeah i guess thats all i could find on it
tankbusta
<ffmpeg>
Where to input a log expression in FFMPEG
tankbusta
# Where to input a log expression in FFMPEG

(Asked by: username_0 on 2018-10-01)

Im trying to use a expression from NUKE (to convert an exr sequence from its native format into AlexaLogC. Now ive got an expression from nuke which is the following
x > 0.14996582 ? (pow(10,0, (x - 0.385537) / 0.2471896) - 0.0522720) / 5.5555556 : (x - 0.092809) / 5.367655 

been trying to find a spot to place this inside a FFMPEG filter to allow it to bring my footage to the right starting point so i can apply the lut from on set on it.
Was wondering if anybody here had advice on how to correctly filter this into ffmpeg.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: That expr looks like it works on normalized values. What is the pixel format? RGB 16-bit? pow has three arguments - what is the definition?  
> **username_0**: RGB 16BIT yeahw  
> **username_0**: Basically need ffmpeg to being it to the alexa color space so i can use a lut on it from DI  
> **username_1**: pow has three arguments - what is the definition?  
> **username_0**: @username_1 its not HDR  
> **username_0**: 2048 X 968 Alexa Scan maybe it is HDR who knows but the whites are blown out and they come in better when i use the alexalogc curve in nuke need that in ffmpeg  
> **username_1**: I still need the definition of nuke's 3-arg pow function that is shown here.  
> **username_0**: @username_1 where can i get that info ? i just copy pasted the expression from nukes color preferences  
> **username_1**: Probably the manual or other Nuke users.  
> **username_0**: @username_1 so assuming i get that there is a way to fire this into ffmpeg ?  
> **username_1**: yes, using a combination of filters  
> **username_0**: @username_1 im looking around now for it  
> **username_0**: @username_1 cuz this is just the basic AlexaV3LogC curve from nuke  
> **username_0**: @username_1 http://strattoncamera.com/pdf/11-06-30_Alexa_LogC_Curve.pdf  
> **username_1**: I only see two args in `(t > e * cut + f) ? (pow(10, (t - d) / c) - b) / a: (t - f) / e`  
> **username_0**: @username_1 yeah i guess thats all i could find on it  

---

## 1 answers

### Answer by username_1 on 2018-10-02. Score: 0

This is the original expression to be implemented.
x > 0.14996582 ? (pow(10,0, (x - 0.385537) / 0.2471896) - 0.0522720) / 5.5555556 : (x - 0.092809) / 5.367655

where x is the pixel intensity normalized to [0,1]. x is linear, so gamma returns identity. 
I'm going to assume the 0 in the pow expression is an extraneous arg since the linked reference at http://strattoncamera.com/pdf/11-06-30_Alexa_LogC_Curve.pdf depicts pow() as having only two arguments. I'm also assuming that the input is 16-bit full-range integer RGB.
ffmpeg -apply_trc linear -i in%d.exr
       -vf "lutrgb=r='if(gt(val/maxval,0.14996582),maxval*((pow(10, (val/maxval-0.385537)/0.2471896)-0.0522720)/5.5555556),maxval*((val/maxval-0.092809)/5.367655))':
                   g='if(gt(val/maxval,0.14996582),maxval*((pow(10, (val/maxval-0.385537)/0.2471896)-0.0522720)/5.5555556),maxval*((val/maxval-0.092809)/5.367655))':
                   b='if(gt(val/maxval,0.14996582),maxval*((pow(10, (val/maxval-0.385537)/0.2471896)-0.0522720)/5.5555556),maxval*((val/maxval-0.092809)/5.367655))'"
        out%d.tiff

> **Comments:**
> **username_0**: Thanks for much for helping out @gyan, tried it and its still blown out but seems this is definitely the filter to use, the highlights got completely blown up  
> **username_1**: You need to verify range and the expr. How are you viewing the TIFFs?  
> **username_0**: doing it in nuke / after effects and i need it to output EXR's not TIFFS but both are ok :)  
> **username_1**: FFmpeg does not have an EXR encoder. Are you sure the input is full range?  
> **username_0**: i meant to type i want the output to be mov eventually when i can sticth the files but im just viwing the images in after effects  
> **username_0**: also yes input is full range as nuke handles it just fine  
> **username_0**: I ended up doing it in OpenImageIO, FFMPEG couldn't do the job for me  

---

