Giter Site home page Giter Site logo

lemonpi / window_recorder Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 23 KB

Programatically video record a window with a python context manager in Linux

License: MIT License

Python 100.00%
python screen-capture screen-recorder context-manager programmatic record record-video video-recording

window_recorder's Introduction

Installation

This only works on Linux systems. You should have xwininfo installed by default.

pip install window-recorder

If the above does not work (OpenCV can be finicky), then you can install the dependencies manually. Install opencv and mss as dependencies (recommended with conda):

conda install opencv
conda install -c conda-forge python-mss

Then clone this repository anywhere and install locally with

pip install -e .

Usage

The WindowRecorder class comes as a context manager. You pass in a list of window names to record and it will try to find them in the order given, recording the first one with a valid window configuration. If you pass in None as the first argument, then instead it will prompt you to click on a window (cursor turns into a cross and blocks until you click).

The video will start and end recording according to the life cycle of the context manager.

from window_recorder import WindowRecorder
import time

# passing in nothing as the window name will allow you to select the window by clicking
# want to capture an RViz window, which could have name "RViz*" as well
with WindowRecorder(["RViz*", "RViz"], frame_rate=30.0, name_suffix="rviz"):
    # do things...
    time.sleep(0.1)
    start = time.time()
    while time.time() - start < 2:
        time.sleep(0.1)

You can test it out with scripts/text.py which will prompt you to click a window that it will then record for 2 seconds (see the log for the default location the video will be saved to)

Limitations

The original location of the window will be what is actually recorded, so if you move the window during the recording or another window comes in front of it, that will also be recorded.

window_recorder's People

Contributors

bsaund avatar lemonpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bsaund

window_recorder's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.