Page 1 of 1

Network-Cahing not working because of keyframes

Posted: 18 Sep 2020 01:00
by Llorx
This is easy. If I set the network caching to something less than the amount of keyframes, it will still "Stream buffering done" the amount of keyframes I'm sending.

I'm using "tcp/ts://HOST:PORT" to receive the stream, and the stream is created using ffmpeg with mpegts output.

I tested this by having a 1 keyframe each 2 seconds stream and setting network-caching over 2 seconds, working as expected, then reducing it to 100ms and still having 2 seconds of caching.

If I change the keyframes to 1 per second, the network caching reduces to 1000ms, but sill not 100ms, which is what I want.

What option do I need to set to avoid this?

Re: Network-Cahing not working because of keyframes

Posted: 18 Sep 2020 20:26
by Lotesdelere
Interesting finds.

Please open Tools -> Messages (set Verbosity to 2) before you start the playback, and then paste the full resulting log here or on Pastebin.com if it's too long.

Re: Network-Cahing not working because of keyframes

Posted: 18 Sep 2020 21:45
by Llorx
Nice. This is a video of the process. The network caching is set to 100ms and the video keyframes are set to 1 per second. As you can see when the first picture is received, the video is paused for 1 second while buffering: https://femto.pw/8myg.mp4

By the way you can see the buffering also in the logs line 270: https://pastebin.pl/view/b70b8202

Re: Network-Cahing not working because of keyframes

Posted: 19 Sep 2020 07:48
by RĂ©mi Denis-Courmont
The caching value is just an initial hint. VLC will automatically increase if it needs to. AFAICT, it's working as intended.

You probably should make sure that the sent first frame is a always key frame.

Re: Network-Cahing not working because of keyframes

Posted: 19 Sep 2020 09:31
by Llorx
Hm, that's a bit difficult to achieve as is just a ffmpeg output piped directly to the socket. By the way, there's always a 2000ms seconds caching, although I restart the stream 10 times, and is impossible that all 10 times I just miss a keyframe and have to wait for the next one for 2 seconds.

The weird thing is that if I set the amount of keyframes to 1 per 2 seconds (which is the usual default), I'll get a network caching of 2 seconds, which is huge. I don't mind vlc to show some grey frames for 2 seconds as long as the stream is as live as possible, like ffplay does, for example. Almost all players do this so I don't get why vlc ignore "network-caching" if its value is lower than the amount of keyframes. I thought that the "network-caching" option was always forced under my responsibility. Right now is just not working as explained in the documentation :-( Even the default caching value is 1000ms when the usual keyframes are 1 each 2 seconds, so it usually is not applying.

Isn't there an option to disable waiting for keyframes or ignoring gop size or things like that?

EDIT: I'm not the only one having this problem, and a lot more not posting them on forums: https://forums.vmix.com/posts/t20603-VL ... -2-seconds
(Just arrived by chance looking for vMix SRT thingies haha)

Re: Network-Cahing not working because of keyframes

Posted: 25 Sep 2020 10:13
by InTheWings
use 4.0 nb and --low-delay

Re: Network-Cahing not working because of keyframes

Posted: 30 Sep 2020 16:09
by Llorx
Yeah, that made it @InTheWings. Still a bit of buffering (for example, if I set 1000ms it raises up to 1400ms and if I set 300ms it raises up to 700ms) but at least it skips the keyframes, which is what I wanted. Thank you!