VLC Playback shows only a few frames

ddiepo

n3wb
Joined
Aug 7, 2016
Messages
2
Reaction score
2
I searched over this forum and couldn't find any information about this. However with enough trial and error I eventually found the problem.

First, I have a Hikvision camera and had problems with h.264 and h.265 playback both via VLC. The bottom line, I found I needed the network caching set to at least 300ms to avoid missing tons of frames (for h.265). For some reason I had this value set very low to avoid adding latency to network streams.

In my debugging, I was able to play the stream using vsplayer (the hikvision player) without issue in Windows. However in Linux when I tried using VLC I would get usually 1 full initial frame immediately, and then the video would "freeze". After some time, it would occasionally play about 1 frame per second which would actually render.

So long story short, if you can't get your camera to play smoothly in VLC, check the caching setting and increase it.
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,680
Reaction score
14,041
Location
USA
I have fought with that network cache size many times, but network delay is sadly a necessary evil if you want smooth, correct playback. The default value is 1000 ms (one full second) which might seem a bit excessive given that it can often work at 300-500ms, but the extra time can help the network protocol fix any rare data transmission errors before they affect the video playback.
 

ddiepo

n3wb
Joined
Aug 7, 2016
Messages
2
Reaction score
2
The RTSP stream I was using was coming in via UDP, so there's no retrying to fix any network transmission errors. My best guess, based mostly on mjpeg working fine but h.264/h.265 not, is that it needs the cache as a buffer to acquire enough data to feed into the decoder in the right size chunks.
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,680
Reaction score
14,041
Location
USA
Mjpeg was designed to be very simple. It is just a stream of one jpeg picture after another, separated only by a short, predictable string of characters in the stream. All a player has to do to play mjpeg is decode and show each jpeg image the moment it finishes downloading.

Just about every video format after mjpeg is way more complex. Frames come in a wide range of sizes so the player can't just show them each at the moment they arrive or else the frame rate would be very inconsistent and it wouldn't sync with the audio (if there is audio). The network needs to get ahead a little so the player can keep playing smoothly and never run out of data.
 
Top