All Projects → kapoorlakshya → Screen Recorder

kapoorlakshya / Screen Recorder

Licence: mit
A Ruby gem to video record and take screenshots of your desktop or specific application window. Works on Windows, Linux, and macOS.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Screen Recorder

Headless
Create a virtual X screen from Ruby, record videos and take screenshots.
Stars: ✭ 951 (+604.44%)
Mutual labels:  ffmpeg, selenium
Jvedio
Windows desktop application to manage local video;Support baidu AI, youdao translation;Support FFMPEG video processing;Support multi-database management and statistics;Support skin switching
Stars: ✭ 545 (+303.7%)
Mutual labels:  ffmpeg, screenshots
Reporting
Zebrunner Reporting Tool
Stars: ✭ 198 (+46.67%)
Mutual labels:  screenshots, selenium
Screenshots
Simple Website Screenshots as a Service (Django, Selenium, Docker, Docker-compose)
Stars: ✭ 126 (-6.67%)
Mutual labels:  screenshots, selenium
Audiobookconverter
Improved AudioBookConverter based on freeipodsoftware release (mp3 to m4b converter)
Stars: ✭ 131 (-2.96%)
Mutual labels:  ffmpeg
Youtube2audio
Desktop application to download YouTube videos as annotated MP3 or MP4 files
Stars: ✭ 128 (-5.19%)
Mutual labels:  ffmpeg
Anirip
🎬 A Crunchyroll show/season ripper
Stars: ✭ 127 (-5.93%)
Mutual labels:  ffmpeg
Makerlapse App
Document Your Journery Into A Timelapse Video
Stars: ✭ 127 (-5.93%)
Mutual labels:  ffmpeg
Nightwatch
End-to-end testing framework written in Node.js and using the Webdriver API
Stars: ✭ 10,912 (+7982.96%)
Mutual labels:  selenium
Avtranscoder
C++ API for LibAV / FFMpeg
Stars: ✭ 130 (-3.7%)
Mutual labels:  ffmpeg
Tiktokbot
A TikTokBot that downloads trending tiktok videos and compiles them using FFmpeg
Stars: ✭ 126 (-6.67%)
Mutual labels:  ffmpeg
Fwf
HTML video editor with FFmpeg
Stars: ✭ 128 (-5.19%)
Mutual labels:  ffmpeg
Video Srt Windows
这是一个可以识别视频语音自动生成字幕SRT文件的开源 Windows-GUI 软件工具。
Stars: ✭ 2,497 (+1749.63%)
Mutual labels:  ffmpeg
Agent orange
Parse and process User Agents like a secret one
Stars: ✭ 127 (-5.93%)
Mutual labels:  ruby-gem
Unium
Automation for Unity games
Stars: ✭ 132 (-2.22%)
Mutual labels:  selenium
So Simple Theme
A simple Jekyll theme for words and pictures.
Stars: ✭ 1,701 (+1160%)
Mutual labels:  ruby-gem
Rtmp Ts Dash Webrtc
👾 音视频解决方案 Audio and video solutions(AV1)
Stars: ✭ 129 (-4.44%)
Mutual labels:  ffmpeg
Nightwatch Custom Commands Assertions
Nightwatch.js custom commands and assertions
Stars: ✭ 131 (-2.96%)
Mutual labels:  selenium
Autolink
AutoLink是一个开源Web IDE自动化测试集成解决方案
Stars: ✭ 129 (-4.44%)
Mutual labels:  selenium
Pages Gem
A simple Ruby Gem to bootstrap dependencies for setting up and maintaining a local Jekyll environment in sync with GitHub Pages
Stars: ✭ 1,670 (+1137.04%)
Mutual labels:  ruby-gem

ScreenRecorder

Gem Version Yard Docs Build Status AppVeyor status Maintainability

A Ruby gem to video record or take screenshots of your computer screen - desktop or specific window - using FFmpeg. Primarily geared towards recording automated UI (Selenium) test executions for debugging and documentation.

Demo

https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem

Compatibility

Works on Windows, Linux, and macOS. Requires Ruby 2.0+ or JRuby 9.2+.

Installation

1. Setup FFmpeg

Linux and macOS instructions are here.

macOS: Follow these steps to avoid issues related to Privacy settings.

For Microsoft Windows, download the binary from here. Once downloaded, add location of the ffmpeg/bin folder to the PATH environment variable (instructions).

Alternatively, you can point to the binary file using ScreenRecorder.ffmpeg_binary = '/path/to/ffmpeg' in your project.

2. Install gem

Next, add these lines to your application's Gemfile:

gem 'ffi' # Windows only
gem 'screen-recorder', '~> 1.0'

The ffi gem is used by the childprocess gem on Windows, but it does not explicitly require it. More information on this here.

And then execute:

$ bundle

Or install it yourself as:

$ gem install ffi # Windows only
$ gem install screen-recorder
3. Require gem
require 'screen-recorder'

Usage

Record Desktop

@recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')
@recorder.start

# Run tests or whatever you want to record

@recorder.stop

Linux and macOS users can optionally provide a display or input device number. Read more about it in the wiki here.

Record Application Window (Microsoft Windows only)

require 'watir'

browser   = Watir::Browser.new :firefox
@recorder = ScreenRecorder::Window.new(title: 'Mozilla Firefox', output: 'recording.mkv')
@recorder.start

# Run tests or whatever you want to record

@recorder.stop
browser.quit 

This mode has a few limitations which are listed in the wiki here.

Fetch Title

A helper method is available to fetch the title of the active window for the given process name.

ScreenRecorder::Window.fetch_title('firefox') # Name of exe
#=> ["Mozilla Firefox"]

ScreenRecorder::Window.fetch_title('chrome')
#=> ["New Tab - Google Chrome"]

Capture Audio

Provide the following advanced configurations to capture audio:

# Linux
advanced = { f: 'alsa', ac: 2, i: 'hw:0'} # Using ALSA
# Or using PulseAudio 
advanced = { 'f': 'pulse', 'ac': 2, 'i': 'default' } # Records default sound output device 

# macOS
advanced = { input: { i: '1:1' } } # -i video:audio input device ID

# Windows
advanced = { f: 'dshow', i: 'audio="Microphone (Realtek High Definition Audio)"' }

You can retrieve a list of audio devices by running these commands:

# Linux
$ arecord -L # See https://trac.ffmpeg.org/wiki/Capture/ALSA

# macOS
$ ffmpeg -f avfoundation -list_devices true -i ""

# Windows
> ffmpeg -list_devices true -f dshow -i dummy

Screenshots

Screenshots can be captured at any point after initializing the recorder:

# Desktop
@recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')
@recorder.screenshot('before-recording.png')
@recorder.start
@recorder.screenshot('during-recording.png')
@recorder.stop
@recorder.screenshot('after-recording.png')

# Window (Microsoft Windows only)
browser   = Watir::Browser.new :chrome, options: { args: ['--disable-gpu'] } # Hardware acceleration must be disabled
browser.goto('watir.com')
window_title = ScreenRecorder::Window.fetch_title('chrome').first
@recorder = ScreenRecorder::Window.new(title: window_title, output: 'recording.mkv')
@recorder.screenshot('before-recording.png')
@recorder.start
@recorder.screenshot('during-recording.png')
@recorder.stop
@recorder.screenshot('after-recording.png')
browser.quit 

Video Output

Once the recorder is stopped, you can view the video metadata or transcode it if desired.

@recorder.video
=> #<FFMPEG::Movie:0x0000000004327900 
        @path="recording.mkv", 
        @metadata={:streams=>[{:index=>0, :codec_name=>"h264", :codec_long_name=>"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", 
        :profile=>"High", 
        :codec_type=>"video"} 
        @video_codec="h264", 
        @colorspace="yuv420p", 
        ... >

@recorder.video.transcode("recording.mp4") { |progress| puts progress } # 0.2 ... 0.5 ... 1.0

See streamio-ffmpeg gem for more details.

Discard Recording

If your test passes or you do not want the recording for any reason, simply call @recorder.discard or @recorder.delete to delete the video file.

Advanced Options

You can provide additional parameters to FFmpeg using the advanced parameter. You can specify input/output specific parameters using input: {} and output: {} within the advanced Hash.

advanced = {
  input:    {
    framerate:  30,
    pix_fmt:    'yuv420p',
    video_size: '1280x720'
  },
  output:   {
    r:       15, # Framerate
    pix_fmt: 'yuv420p'
  },
  log:      'recorder.log',
  loglevel: 'level+debug', # For FFmpeg
}
ScreenRecorder::Desktop.new(output: 'recording.mkv', advanced: advanced)

This will be parsed as:

ffmpeg -y -f gdigrab -framerate 30 -pix_fmt yuv420p -video_size 1280x720 -i desktop -r 15 pix_fmt yuv420p -loglevel level+debug recording.mkv

Logging & Debugging

You can configure the logging level of the gem to troubleshoot problems:

ScreenRecorder.logger.level = :DEBUG

Also refer to the ffmpeg.log file for details.

Use with Cucumber

A Cucumber + Watir based example is available here.

Wiki

Please see the wiki for solutions to commonly reported issues.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake to run the tests and rubocop. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome.

License

The gem is available as open source under the terms of the MIT License.

Credits

Thanks to Denys Bazarnyi for testing macOS compatibility in v1.1.0.

Streamio

This gem relies on the streamio-ffmpeg gem to extract metadata from the output file.

SauceLabs Logo

Thanks to SauceLabs for providing me with a free account. If you manage an open source project, you can apply for a free account here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].