[FFmpeg-user] 答复: How to obtain packets as soon as sending a frame?
linzehui
linzehui1 at huawei.com
Thu Nov 4 03:29:24 EET 2021
> I am no expert but I imagine it is keeping the old packets around so it can refer to them from later packets, and it only sends them when it no longer needs to refer back to them.
I guess the lag is indeed because of keeping the old packets. But I think libx265 could have kept the old frames instead of the old packets.
> I suppose you could configure the codec to send an I fraame for every frame or every second frame? You'd get almost no compression but the latency would probably be quite low.
> You could also consider increasing the frame rate, e.g. 30 fps in, 120 fps out. Since you'd be submitting each input frame multiple times, the encoder would produce an output packet sooner.
> There are probably much better ways than this but I imagine you'd have to delve into the codec source code.
I dig into the settings and finally find two related libx265 options: "rc-lookahead" and "bframes".
It seems that when B frames are enabled, the lag in frames will be (3 + "rc-lookahead" + "bframes"), and "rc-lookahead" has to be greater than "bframes" even if "b-adapt" is disabled.
I want a median compression (max_b_frames>=3) with a low latency (<=5 frames). Perhaps the only solution is to modify libx265's source code.
Thanks for your advice.
Grateful,
Zehui
More information about the ffmpeg-user
mailing list