Giter VIP home page Giter VIP logo

wd-video-recorder's Introduction

WD Video Recorder

Utility that allows you to make videos of your integration tests with WD. See WD homepage for more information on how to run integration tests with node.

WD Video Recorder uses fluent-ffmpeg interface for FFMpeg. FFMpeg must be installed on your system prior to using this utility!

Installation

Utility is distributed via npm. Execute

$ npm install wd-video

from root directory of your node project to install WD Video Recorder.

Usage

Using WD Video Recorder should be really easy. The process consists of 6 simple steps:

  1. Import library to your JavaScript (test) file

     var Recorder = require('wd-video-recorder');
    
  2. Initialize WD environment. For more information how to do this, please visit WD homepage.

     var browser = wd.promiseChainRemote();
     browser.init({browserName:'firefox'}).then(function() {
     	// ...
     });
    
  3. Create an instance of video recorder class

     var recorder = new Recorder(browser, [options]);
    

    You can limited set of configuration options to constructor. See Recorder.constructor for more information.

  4. Start recording

     recorder.start();
    
  5. Stop recording

     recorder.stop();
    
  6. Save recorded video

     recorder.save(output, callback);
    

    callback function receives three parameters - stderr, stdout and full path to recorded video.

  7. Clear recorder

     recorder.clear();
    

    Since recorder uses WD screenshot feature, it peridocally takes screenshots of browser window. These screenshots are stored on your filesystem (either your system's temporary directory or in tempDir directory specified in constructor options. See Recorder.constructor for more information.). These screenshots should be deleted after recording video.

Recorder API

constructor

new Recorder(browser:WD.browser, [options:Object]):Recorder

Parameters

browser WD Browser Instance of WD browser.

options Object Optional. Hash of configuration options for this recorder. Following options are recognized:

  • tmpdir String Path to a directory. Recorder will create a subdirectory for its screenshots in this directory. Defaults to os.tmpdir().
  • fps Integer Frames per second. Screenshots will be taken at most at this rate. Actual rate depends on the browser delay (taking a screenshot is asynchronous). default FPS is 15.
  • aspect String Aspect ratio of recorded video. 4:3 for example. It is unspecified by default.
  • size String Size of recorded video. 800x600 for example. It is unspecified by default.
  • beforeSave Function(proc:ffmpeg):void Callback invoked just before saving the video. It takes on paramater - underlying FFMpeg process instance (See fluent-ffmpeg for documentation). This allows you to further modify the video output.

start

recorder.start():Recorder

Starts taking screenshots from browser instance passed to constructor.

Returns This instance.

save

recorder.save(output:String, callback:Function(stderr:String, stdout:String, output:String)):Recorder

Parameters

output String Relative (to current working directory) or absolute path to desired output video file.

callback Function(stderr:String, stdout:String, output:String) Callback function that gets called after save is done.

Returns This instance

clear

recorder.clear():Recorder

Removes all taken screenshots and screenshots directory itself. Throws an exception and does nothing if the recorder is running.

Returns This instance

stop

recorder.stop():Recorder

Stops the recorder from taking screenshots. Does not remove screenshots or screenshots directory. After calling stop(), you may call start() again to resume recording.

Returns This instance

stopAndClear

recorder.stopAndClear():Recorder

Stops recorder and clears the screenshots directory.

Returns This instance

stopAndSave

recorder.stopAndSave(output:String, callback:Function(stderr:String, stdout:String, output:String)):Recorder

Stops recorder and saves the video. See save method for parameter reference.

Parameters

Same as for save method

Returns This instance

stopSaveAndClear

recorder.stopSaveAndClear(output:String, callback:Function(stderr:String, stdout:String, output:String)):Recorder

Stops recorder, saves the video and clears the screenshots directory. See save method for parameter reference.

Parameters

Same as for save method

Returns This instance

Testing

Unit tests can be run from command line with:

$ grunt test

wd-video-recorder's People

Watchers

James Cloos avatar Bogdan Anton 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.