The ffmpeg is cross-platform and very powerful software to handle video/audio or to stream it. On Linux ffmpeg can capture X11 screen with a command below:
ffmpe
This can be done without using x11grab/xcbgrab/gdigrab with help of the below commands in linux .
x11grab/xcbgrab/gdigrab
linux
To record a video,
ffmpeg -f x11grab -s 1366x768 -i :0.0 -r 25 -vcodec libx264 output.mkv
To record a frame,
./ffmpeg -f fbdev -framerate 1 -i /dev/fb1 -frames:v 1 screenshot3.jpeg