Real Time screen grabbing and streaming with libav-tools

921 views Asked by At

For my school project I have to stream screen grabbing from 1 station (i.e. server) to another (i.e. client) in Real Time, both running linux (ubuntu). I'm using libav-tools (avconv as the encoder on the server side and avplay as the player on the client side)

avconv uses x11grab format to grab from the screen.

My problem is: avconv needs a few seconds to output the encoded video. this wait is too long for RT.

I've tried streaming to localhost to avoid network influence on speed, it still seems that avconv is responsible for the long wait. Also, streaming a video file seems to be much faster, almost immediately.

The project is implemented in C++ and executes avconv in a fork.

Any suggestions as to shortening the procedure?

1

There are 1 answers

0
Ole Dittmann On

This is most likely due to internal buffering. There is often a buffer which is way too big on default. That is because having no delay is not the primary concern of most software, they are more concerned with bad connections and that sort of problems, which is what buffers are for.

See https://libav.org/avconv.html, search for "nobuffer" or "-analyzeduration" or "-rtbufsize" or "-max_delay" or "-fpsprobesize" or "rtmp_buffer" (if you use rtmp) or others and try your luck.

There will always be a noticable delay, especially if you use an encodings like h264 for transfer. But a few seconds it does not need to be in a controlled environment. You should be able to bring it down to fractions of a second.