Beheaded

Generic X window and recording for headless setups in Python.


Keywords
headless, xvfb, ffmpeg, recording
License
GPL-2.0
Install
pip install Beheaded==1.2

Documentation

Beheaded

Author: Milan Falešník (milan@falesnik.net, mfalesni@redhat.com) Generic X window and recording for headless setups.

Installation:

  • pip install Beheaded

Requires Runner python package to be installed (pip handles that).

Usage:

The basic step is to import required objects into namespace

from Beheaded import Headless, Record

Obviously, if you don't need recording, the do not import Record.

Headless:

Headless's constructor signature:

Headless(display="auto", width=1280, height=1024, bit_depth=24)

Headless can be used both in normal and context-managed mode.

X = Headless()
X.start()
... do stuff ...
X.stop()

and

with Headless() as X:
    ... do stuff ...

are functionally equivalent.

Record:

Record's constructor signature:

Record(filename, xvfb, framerate=25)
  • filename specifies the target video file name
  • xvfb specifies the Headless object, or anything that provides width, height and display attributes.

Record can be used both in normal and context-managed mode.

rec = Record("filename.webm", X)
rec.start()
... do stuff ...
rec.stop()

and

with Record():
    ... do stuff ...

are functionally equivalent.

Combining:

Works obviously as expected:

with Headless() as X:
    with Record("filename.webm", X):
        ... do stuff ...

To-Do:

  • add checks whether Xvfb or ffmpeg really run