<p>If you're using x264 directly, it's <code>--rc-lookahead 20</code> for 20 frames. If it's via ffmpeg, it's <code>-x264-params rc_lookahead=10</code>.</p>

<p>Although I would suggest to use faster <a href="http://dev.beandog.org/x264_preset_reference.html" rel="nofollow noreferrer">presets</a>. Default is medum.</p>

CC BY-SA 4.0
2018-05-31T20:03:20.720Z
So I'm using OpenCVs videowrite() function. I know that it uses x264 encoding in the back end. Is there a way to set `--rc-lookahead 20` as a parameter through OpenCV?
newuser
CC BY-SA 4.0
2018-06-01T05:40:27.347Z
From what I can see, this is not possible. OpenCV does not accept private parameters for x264. You can raise an issue at https://github.com/opencv/opencv/issues
Gyan
CC BY-SA 4.0
2018-06-04T15:57:58.117Z
Would it be possible to change encoder parameters in the OpenCV sourcecode? Or do I have to into the x264 encoder source code?
newuser
CC BY-SA 4.0
2018-06-04T16:16:41.420Z
Not familiar with the OpenCV source but search for the x264 API calls initializing the encoder parameters and change those.
Gyan
CC BY-SA 4.0
2018-06-04T16:43:24.013Z
OpenCV does not seem to use x264, See https://github.com/opencv/opencv/blob/master/3rdparty/ffmpeg/readme.txt.
Gyan
CC BY-SA 4.0
2018-05-31T18:00:17.870Z
2018-05-31T18:00:17.870Z
Gyan
<p>I want minimize encoding latency per frame. Right now, there is a high increase in encoding latency on the 46th frame. I think lowering the lookahead value might help with this. How do I do this? 
Capture Resolution is 1080p. </p>

<h.264><x264><latency>
I'm using H264 encoding to encode video capture from a webcam. How do I turn of rc lookahead?
newuser
# I'm using H264 encoding to encode video capture from a webcam. How do I turn of rc lookahead?

(Asked by: username_0 on 2018-05-31)

I want minimize encoding latency per frame. Right now, there is a high increase in encoding latency on the 46th frame. I think lowering the lookahead value might help with this. How do I do this?
Capture Resolution is 1080p.

**Tags:** h.264, x264, latency


---

## 1 answers

### Answer by username_1 on 2018-05-31. Score: 0 | Accepted answer

If you're using x264 directly, it's `--rc-lookahead 20` for 20 frames. If it's via ffmpeg, it's `-x264-params rc_lookahead=10`.

Although I would suggest to use faster [presets](http://dev.beandog.org/x264_preset_reference.html). Default is medum.

> **Comments:**
> **username_0**: So I'm using OpenCVs videowrite() function. I know that it uses x264 encoding in the back end. Is there a way to set `--rc-lookahead 20` as a parameter through OpenCV?  
> **username_1**: From what I can see, this is not possible. OpenCV does not accept private parameters for x264. You can raise an issue at https://github.com/opencv/opencv/issues  
> **username_0**: Would it be possible to change encoder parameters in the OpenCV sourcecode? Or do I have to into the x264 encoder source code?  
> **username_1**: Not familiar with the OpenCV source but search for the x264 API calls initializing the encoder parameters and change those.  
> **username_1**: OpenCV does not seem to use x264, See https://github.com/opencv/opencv/blob/master/3rdparty/ffmpeg/readme.txt.  

---

