Coder Social home page Coder Social logo

xxx1xxx / x11-canvas-screencast Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rprichard/x11-canvas-screencast

0.0 2.0 0.0 161 KB

X11-to-HTML5-Canvas screencasting

Home Page: http://htmlpreview.github.com/?https://github.com/rprichard/x11-canvas-screencast/blob/master/example/example.html

License: BSD 3-Clause "New" or "Revised" License

x11-canvas-screencast's Introduction

x11-canvas-screencast

x11-canvas-screencast is an X11-to-HTML5-Canvas screencasting system that uses the same animation technique as the anim_encoder project.

The project includes a Qt-X11 executable, screencast, which polls the screen and mouse cursor and outputs an animation. Specifically, it writes an animation script (a CSV-separated list of steps) and a number of PNG files (one per screen capture and one per unique mouse cursor). The pack_animation.py script (based on anim_encoder.py) optimizes an animation script by creating a packed PNG file and then replacing each screen command with a blit command that copies part of the packed PNG file into the canvas.

Packing the animation can be slow, and this approach makes it easy to view and tweak the animation prior to packing it.

Prerequisites

The screencast program needs Qt and the XFixes extension. The pack_animation.py script has the same dependencies as anim_encoder -- NumPy, SciPy, OpenCV, and pngcrush. On Ubuntu, install these packages:

libqt4-dev libxfixes-dev python-numpy python-scipy python-opencv pngcrush

Usage

  1. Build screencast:

     $ qmake
     $ make
     
  2. Capture an animation:

     $ ./screencast --rect X Y W H --output example.js
     

    Hit Enter to stop the capture. Turning on CAPS LOCK will temporarily pause the capture. Turning off CAPS LOCK returns the mouse cursor to its position before pausing the capture, then unpauses the capture.

  3. Pack the animation:

     $ ./pack_animation.py example.js
     

    pack_animation.py example.js will output example_packed.js and example_packed.png.

Embedding an animation in a web page

See example/example.html for an example of embedding the player.

Include the animation's JavaScript file and player.js in the page. The player.js script defines a Player class. Construct it:

var player = Player(<animation-script-object>, "<animation-source-dir>");

The <animation-source-dir> path will be prefixed to each path in the animation script. The Player object has an element field. Add or remove it to a page. A player is initially paused; unpause it with the start method. Pause it with the pause method.

The Player object has two events:

  • onload. This is called after all of the images are loaded, and after the player's canvas has been painted with the first frame.

  • onloop. This is called at the end of the animation, as it is looping back to the beginning. Pause it here to prevent looping.

License

BSD license.

x11-canvas-screencast's People

Contributors

rprichard avatar

Watchers

James Cloos avatar  avatar

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.