<p>You can use the geq filter to remap the pixel value ranges.</p>

<pre><code>ffmpeg
 -i input
 -vf "geq=lum='(p(X,Y)-16)/(255-16)*(235-16)+16':cb='(p(X,Y)-16)/(255-16)*(240-16)+16'"
 -c:v libx264 -c:a copy out.mp4
</code></pre>

<p>The geq filter rescales the input luma from 16-255 to 16-235, and both the input chroma from 16-255 to 16-240, which is  the legal range for broadcast 8-bit signals.</p>

CC BY-SA 4.0
2021-04-28T10:16:34.707Z
Thank you very mutch for your help ! Another question: is there a way to "legalize" any source level to broadcast level ? In other words: can FFMPEG probe source file(s) level before remap to broadcast ?
FORART npo
CC BY-SA 4.0
2020-04-04T11:46:30.747Z
2020-04-04T11:46:30.747Z
Gyan
<p>for a noprofit project I do shoot with (up to 5x) Canon HF100 camera(s) but, as stated in <a href="http://nerdfever.com/video-editing-for-scientific-analysis/" rel="nofollow noreferrer">this interesting artile</a>, it genetates a "custom RGB range" (16-255) files.</p>

<p>Thanks to <a href="https://github.com/dericed/ffmpeg-mpeg2video-clipping" rel="nofollow noreferrer">this cool repository</a> I've generated this GIF of 10s of source video:</p>

<p><a href="http://www.forart.it/_priv/cultura/HF100_measurement.gif" rel="nofollow noreferrer">http://www.forart.it/_priv/cultura/HF100_measurement.gif</a> (33 Mb, so can't post. Click to watch)</p>

<p>It graphically shows how recorded video exceed the broadcast range.</p>

<p>The question is: how to "shift down" everything (and constrain inside broadcast range, of course) in order to preserve the maximum possible color quality ?</p>

<p>(note: someone already suggested me to use " <em>Levels(0, 16, 255, 16, 235, coring=false)</em> " in AviSynth but, if possible, I want to do it only with FFMPEG)</p>

<p>Thanks in advance to anyone that can/will help.</p>

<p>Marco</p>

CC BY-SA 4.0
2020-03-14T07:25:25.227Z
Well, I've already asked @ Doom9 forums and here is the response: https://forum.doom9.org/showthread.php?p=1902399
FORART npo
CC BY-SA 4.0
2020-03-25T10:27:44.083Z
Can you share a sample video from HF100?
Gyan
CC BY-SA 4.0
2020-03-25T18:24:43.453Z
Of course, here's an untouched shooting as downloaded from the camera: https://clicknupload.co/0ooaljx1oqi1
FORART npo
CC BY-SA 4.0
2020-03-26T07:10:09.967Z
Here's another interesting discussion - I'm partecipating in too - about FFMPEG's color "management": https://forum.videohelp.com/threads/395939-ffmpeg-Color-Range/
FORART npo
CC BY-SA 4.0
2020-03-27T11:20:14.827Z
Ok, chris319 (@ videohelp.com 3ad) suggested this parameters: -vf lutrgb='r=clip(val,30,223)',lutrgb='g=clip(val,30,223)',lutrgb='b=clip(val,30,223)'
FORART npo
CC BY-SA 4.0
2020-04-04T11:29:41.263Z
Ok, so your video is YUV, not RGB.And clip will squish the values beyond the clip ranges. You should remap them. I'll post an answer shortly.
Gyan
<ffmpeg><canon><colorspace><broadcast><avisynth>
"Canon RGB" color space *shift* to broadcast range with FFMPEG
FORART npo
# "Canon RGB" color space *shift* to broadcast range with FFMPEG

(Asked by: username_0 on 2020-03-11)

for a noprofit project I do shoot with (up to 5x) Canon HF100 camera(s) but, as stated in [this interesting artile](http://nerdfever.com/video-editing-for-scientific-analysis/), it genetates a "custom RGB range" (16-255) files.

Thanks to [this cool repository](https://github.com/dericed/ffmpeg-mpeg2video-clipping) I've generated this GIF of 10s of source video:

<http://www.forart.it/_priv/cultura/HF100_measurement.gif> (33 Mb, so can't post. Click to watch)

It graphically shows how recorded video exceed the broadcast range.

The question is: how to "shift down" everything (and constrain inside broadcast range, of course) in order to preserve the maximum possible color quality ?

(note: someone already suggested me to use " *Levels(0, 16, 255, 16, 235, coring=false)* " in AviSynth but, if possible, I want to do it only with FFMPEG)

Thanks in advance to anyone that can/will help.

Marco

**Tags:** ffmpeg, canon, colorspace, broadcast, avisynth

> **Comments:**
> **username_0**: Well, I've already asked @ Doom9 forums and here is the response: https://forum.doom9.org/showthread.php?p=1902399  
> **username_1**: Can you share a sample video from HF100?  
> **username_0**: Of course, here's an untouched shooting as downloaded from the camera: https://clicknupload.co/0ooaljx1oqi1  
> **username_0**: Here's another interesting discussion - I'm partecipating in too - about FFMPEG's color "management": https://forum.videohelp.com/threads/395939-ffmpeg-Color-Range/  
> **username_0**: Ok, chris319 (@ videohelp.com 3ad) suggested this parameters: -vf lutrgb='r=clip(val,30,223)',lutrgb='g=clip(val,30,223)',lutrgb='b=clip(val,30,223)'  
> **username_1**: Ok, so your video is YUV, not RGB.And clip will squish the values beyond the clip ranges. You should remap them. I'll post an answer shortly.  

---

## 1 answers

### Answer by username_1 on 2020-04-04. Score: 1

You can use the geq filter to remap the pixel value ranges.
ffmpeg
 -i input
 -vf "geq=lum='(p(X,Y)-16)/(255-16)*(235-16)+16':cb='(p(X,Y)-16)/(255-16)*(240-16)+16'"
 -c:v libx264 -c:a copy out.mp4

The geq filter rescales the input luma from 16-255 to 16-235, and both the input chroma from 16-255 to 16-240, which is  the legal range for broadcast 8-bit signals.

> **Comments:**
> **username_0**: Thank you very mutch for your help ! Another question: is there a way to "legalize" any source level to broadcast level ? In other words: can FFMPEG probe source file(s) level before remap to broadcast ?  

---

