{"id":14155338,"url":"https://github.com/kapoorlakshya/screen-recorder","last_synced_at":"2025-10-24T19:47:01.952Z","repository":{"id":53665387,"uuid":"152525638","full_name":"kapoorlakshya/screen-recorder","owner":"kapoorlakshya","description":"    A Ruby gem to video record and take screenshots of your desktop or specific application window. Works on Windows, Linux, and macOS.","archived":false,"fork":false,"pushed_at":"2024-07-30T06:29:21.000Z","size":283,"stargazers_count":195,"open_issues_count":6,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-03T21:13:09.987Z","etag":null,"topics":["capybara","ffmpeg","ruby","ruby-gem","screenshots","selenium","video-record","watir"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kapoorlakshya.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-11T03:28:35.000Z","updated_at":"2025-03-11T03:54:10.000Z","dependencies_parsed_at":"2024-06-19T11:14:11.296Z","dependency_job_id":"5c62521a-694b-44fc-8917-0f4979d6d704","html_url":"https://github.com/kapoorlakshya/screen-recorder","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapoorlakshya%2Fscreen-recorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapoorlakshya%2Fscreen-recorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapoorlakshya%2Fscreen-recorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kapoorlakshya%2Fscreen-recorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kapoorlakshya","download_url":"https://codeload.github.com/kapoorlakshya/screen-recorder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618262,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["capybara","ffmpeg","ruby","ruby-gem","screenshots","selenium","video-record","watir"],"created_at":"2024-08-17T08:02:52.157Z","updated_at":"2025-10-24T19:46:56.931Z","avatar_url":"https://github.com/kapoorlakshya.png","language":"Ruby","funding_links":[],"categories":["selenium"],"sub_categories":[],"readme":"# ScreenRecorder\r\n\r\n[![Gem Version](https://badge.fury.io/rb/screen-recorder.svg)](https://badge.fury.io/rb/screen-recorder)\r\n[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/screen-recorder/)\r\n[![Tests](https://github.com/kapoorlakshya/screen-recorder/actions/workflows/tests.yml/badge.svg)](https://github.com/kapoorlakshya/screen-recorder/actions/workflows/tests.yml)\r\n\r\nA Ruby gem to video record or take screenshots of your computer screen - desktop or specific\r\nwindow - using [FFmpeg](https://www.ffmpeg.org/). Primarily\r\ngeared towards recording automated UI (Selenium) test executions for\r\ndebugging and documentation.\r\n\r\n#### Demo\r\n\r\n[https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem](https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem)\r\n\r\n## Compatibility\r\n\r\nWorks on Windows, Linux, and macOS. Requires Ruby 2.0+ or JRuby 9.2+.\r\n\r\n## Installation\r\n\r\n##### 1. Setup FFmpeg\r\n\r\nDownload from [here](https://ffmpeg.org/download.html) and add to `PATH` or use `brew` / `winget` / `apt` to install.\r\n\r\n\u003e macOS: Follow [these steps](https://github.com/kapoorlakshya/screen-recorder/issues/88#issuecomment-629139032) to avoid\r\n\u003e issues related to Privacy settings.\r\n\r\nAlternatively, you can point to the binary file using `ScreenRecorder.ffmpeg_binary = '/path/to/ffmpeg'` in your project.\r\n\r\n##### 2. Install gem\r\n\r\nNext, add these lines to your application's Gemfile:\r\n\r\n```ruby\r\ngem 'screen-recorder', '~\u003e 1.0'\r\n```\r\n\r\nAnd then execute:\r\n\r\n```bash\r\nbundle install\r\n```\r\n\r\n##### 3. Require gem\r\n\r\n```ruby\r\nrequire 'screen-recorder'\r\n```\r\n\r\n## Usage\r\n\r\n#### Record Desktop\r\n\r\n```ruby\r\n@recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')\r\n@recorder.start\r\n\r\n# Run tests or whatever you want to record\r\n\r\n@recorder.stop\r\n```\r\n\r\nLinux and macOS users can optionally provide a display or input device number.\r\nRead more about it in the wiki [here](https://github.com/kapoorlakshya/screen-recorder/wiki/Display-or-Input-Device-Selection).\r\n\r\n#### Record Application Window (Microsoft Windows only)\r\n\r\n```ruby\r\nrequire 'watir'\r\n\r\nbrowser   = Watir::Browser.new :firefox\r\n@recorder = ScreenRecorder::Window.new(title: 'Mozilla Firefox', output: 'recording.mkv')\r\n@recorder.start\r\n\r\n# Run tests or whatever you want to record\r\n\r\n@recorder.stop\r\nbrowser.quit \r\n```\r\n\r\nThis mode has a few limitations which are listed in the wiki\r\n[here](https://github.com/kapoorlakshya/screen-recorder/wiki/Window-Capture-Limitations).\r\n\r\n##### Fetch Title\r\n\r\nA helper method is available to fetch the title of the active window\r\nfor the given process name.\r\n\r\n```ruby\r\nScreenRecorder::Window.fetch_title('firefox') # Name of exe\r\n#=\u003e [\"Mozilla Firefox\"]\r\n\r\nScreenRecorder::Window.fetch_title('chrome')\r\n#=\u003e [\"New Tab - Google Chrome\"]\r\n```\r\n\r\n#### Capture Audio\r\n\r\nProvide the following `advanced` configurations to capture audio:\r\n\r\n```ruby\r\n# Linux\r\nadvanced = { f: 'alsa', ac: 2, i: 'hw:0'} # Using ALSA\r\n# Or using PulseAudio \r\nadvanced = { 'f': 'pulse', 'ac': 2, 'i': 'default' } # Records default sound output device \r\n\r\n# macOS\r\nadvanced = { input: { i: '1:1' } } # -i video:audio input device ID\r\n\r\n# Windows\r\nadvanced = { f: 'dshow', i: 'audio=\"Microphone (Realtek High Definition Audio)\"' }\r\n```\r\n\r\nYou can retrieve a list of audio devices by running these commands:\r\n\r\n```\r\n# Linux\r\n$ arecord -L # See https://trac.ffmpeg.org/wiki/Capture/ALSA\r\n\r\n# macOS\r\n$ ffmpeg -f avfoundation -list_devices true -i \"\"\r\n\r\n# Windows\r\n\u003e ffmpeg -list_devices true -f dshow -i dummy\r\n```\r\n\r\n#### Screenshots\r\n\r\nScreenshots can be captured at any point after initializing the recorder:\r\n\r\n```ruby\r\n# Desktop\r\n@recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')\r\n@recorder.screenshot('before-recording.png')\r\n@recorder.start\r\n@recorder.screenshot('during-recording.png')\r\n@recorder.stop\r\n@recorder.screenshot('after-recording.png')\r\n\r\n# Window (Microsoft Windows only)\r\nbrowser   = Watir::Browser.new :chrome, options: { args: ['--disable-gpu'] } # Hardware acceleration must be disabled\r\nbrowser.goto('watir.com')\r\nwindow_title = ScreenRecorder::('chrome').first\r\n@recorder = ScreenRecorder::Window.new(title: window_title, output: 'recording.mkv')\r\n@recorder.screenshot('before-recording.png')\r\n@recorder.start\r\n@recorder.screenshot('during-recording.png')\r\n@recorder.stop\r\n@recorder.screenshot('after-recording.png')\r\nbrowser.quit \r\n```\r\n\r\nYou can even specify a custom capture resolution:\r\n\r\n```rb\r\n@recorder.screenshot('screenshot.png', '1024x768')\r\n```\r\n\r\n#### Video Output\r\n\r\nOnce the recorder is stopped, you can view the video metadata or transcode\r\nit if desired.\r\n\r\n```ruby\r\n@recorder.video\r\n=\u003e #\u003cFFMPEG::Movie:0x0000000004327900 \r\n        @path=\"recording.mkv\", \r\n        @metadata={:streams=\u003e[{:index=\u003e0, :codec_name=\u003e\"h264\", :codec_long_name=\u003e\"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10\", \r\n        :profile=\u003e\"High\", \r\n        :codec_type=\u003e\"video\"} \r\n        @video_codec=\"h264\", \r\n        @colorspace=\"yuv420p\", \r\n        ... \u003e\r\n\r\n@recorder.video.transcode(\"recording.mp4\") { |progress| puts progress } # 0.2 ... 0.5 ... 1.0\r\n```\r\n\r\nSee [`streamio-ffmpeg`](https://github.com/streamio/streamio-ffmpeg) gem for more details.\r\n\r\n#### Discard Recording\r\n\r\nIf your test passes or you do not want the recording for any reason,\r\nsimply call `@recorder.discard` or `@recorder.delete` to delete\r\nthe video file.\r\n\r\n#### Advanced Options\r\n\r\nYou can provide additional parameters to FFmpeg using the `advanced`\r\nparameter. You can specify input/output specific parameters using `input: {}`\r\nand `output: {}` within the `advanced` Hash.\r\n\r\n```ruby\r\nadvanced = {\r\n  input:    {\r\n    framerate:  30,\r\n    pix_fmt:    'yuv420p',\r\n    video_size: '1280x720'\r\n  },\r\n  output:   {\r\n    r:       15, # Framerate\r\n    pix_fmt: 'yuv420p'\r\n  },\r\n  log:      'recorder.log',\r\n  loglevel: 'level+debug', # For FFmpeg\r\n}\r\nScreenRecorder::Desktop.new(output: 'recording.mkv', advanced: advanced)\r\n```\r\n\r\nThis will be parsed as:\r\n\r\n```bash\r\nffmpeg -y -f gdigrab -framerate 30 -pix_fmt yuv420p -video_size 1280x720 -i desktop -r 15 pix_fmt yuv420p -loglevel level+debug recording.mkv\r\n```\r\n\r\n#### Logging \u0026 Debugging\r\n\r\nYou can configure the logging level of the gem to troubleshoot problems:\r\n\r\n```ruby\r\nScreenRecorder.logger.level = :DEBUG\r\n```\r\n\r\nAlso refer to the `ffmpeg.log` file for details.\r\n\r\n#### Use with Cucumber\r\n\r\nA Cucumber + Watir based example is available\r\n[here](https://github.com/kapoorlakshya/cucumber-watir-test-recorder-example).\r\n\r\n## Wiki\r\n\r\nPlease see the [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki) for solutions to commonly reported issues.\r\n\r\n## Development\r\n\r\nAfter checking out the repo, run `bin/setup` to install dependencies.\r\nThen, run `bundle exec rake` to run the tests and rubocop. You can also run\r\n`bin/console` for an interactive prompt that will allow you to experiment.\r\n\r\nTo install this gem onto your local machine, run `bundle exec rake install`.\r\n\r\n### Contributing\r\n\r\nBug reports and pull requests are welcome.\r\n\r\n- Please update the specs for your code changes and run them locally with `bundle exec rake spec`.\r\n- Follow the Ruby style guide and format your code - \u003chttps://github.com/rubocop-hq/ruby-style-guide\u003e\r\n\r\n### License\r\n\r\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\r\n\r\n## Credits\r\n\r\nThanks to [Denys Bazarnyi](https://github.com/bazarnyi) for testing\r\nmacOS compatibility in v1.1.0.\r\n\u003cbr /\u003e\r\n\u003cbr /\u003e\r\n\r\n[![Streamio](http://d253c4ja9jigvu.cloudfront.net/assets/small-logo.png)](http://streamio.com)\r\n\r\nThis gem relies on the [streamio-ffmpeg](https://github.com/streamio/streamio-ffmpeg)\r\ngem to extract metadata from the output file.\r\n\u003cbr /\u003e\r\n\u003cbr /\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkapoorlakshya%2Fscreen-recorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkapoorlakshya%2Fscreen-recorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkapoorlakshya%2Fscreen-recorder/lists"}