[x264-devel] Encoding frames with libavcodec

Jason Garrett-Glaser jason at x264.com
Fri Dec 7 17:30:07 CET 2012


On Fri, Dec 7, 2012 at 6:31 AM, Dolevo Jay <cmst at live.com> wrote:
> Perfect!
> My last question (for this week :) )
>
> I am capturing images from the screen, encoding them frame by frame using
> H264 (x264), sending them to the client and there decode them frame by frame
> and show on the screen.
> In my project, latency is important but not a problem up to let say 300 ms.
> For this purpose, I set my encoder parameter by using:
>
> x264_param_default_preset(&param, "ultrafast", "zerolatency");
> and also,
> x264_param_apply_profile(&param, "baseline");
>
> Is this all that I can do? I mean these commands will do the best for
> zerolatency ultrafast encoding for me? What else can I do?
>
> Thanks.

Baseline is unnecessary; don't set that without good reason.

There are two other important considerations for latency, assuming
that your network bandwidth is limited.

1) Ideally, you want to send each frame out to the network
immediately, without buffering or waiting.  To do this, each frame has
to be sendable in less than 33ms (at 30fps, or 16ms at 60fps, and so
on).  To cap the size of each frame like this, set --vbv-bufsize X and
--vbv-maxrate Y, where Y is your maximum bandwidth in kbps and X is Y
/ fps.  You should set --keyint infinite when doing this.

2) You need some way to deal with packet loss if you're working over
the open internet.  For starters, it's easiest to just use TCP, but if
you want to improve things later by using UDP in your system or
similar, you'll need to use a method of correcting errors, such as
intra refresh or reference invalidation.  This is fancier stuff
though, so don't worry about it yet.

Jason


More information about the x264-devel mailing list