screen-recorder 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Lakshya Kapoor
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Lakshya Kapoor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,211 +1,219 @@
1
- # ScreenRecorder
2
-
3
- [![Gem Version](https://badge.fury.io/rb/screen-recorder.svg)](https://badge.fury.io/rb/screen-recorder)
4
- ![https://rubygems.org/gems/screen-recorder](https://ruby-gem-downloads-badge.herokuapp.com/screen-recorder?type=total)
5
- [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/kapoorlakshya/screen-recorder/master)
6
- [![Build Status](https://travis-ci.org/kapoorlakshya/screen-recorder.svg?branch=master)](https://travis-ci.org/kapoorlakshya/screen-recorder)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/b6049dfee7375aed9bc8/maintainability)](https://codeclimate.com/github/kapoorlakshya/screen-recorder/maintainability)
8
-
9
- A Ruby gem to record your computer screen - desktop or specific
10
- window - using [FFmpeg](https://www.ffmpeg.org/). Primarily
11
- geared towards recording automated UI test executions for debugging
12
- and documentation.
13
-
14
- Demo - [https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem](https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem).
15
-
16
- ## Compatibility
17
-
18
- Supports Windows and Linux as of version 1.0.0. macOS support
19
- is coming very soon.
20
-
21
- Requires Ruby 2.0.0 (MRI) or higher, and is tested
22
- with versions 2.3.8, 2.4.5, 2.5.3, and 2.6.1.
23
-
24
- ## Installation
25
-
26
- #### 1. Setup FFmpeg
27
-
28
- Linux and macOS instructions are [here](https://www.ffmpeg.org/download.html).
29
-
30
- For Microsoft Windows, download the *libx264* enabled binary from [here](https://ffmpeg.zeranoe.com/builds/).
31
- Once downloaded, add location of the `ffmpeg/bin` folder to `PATH` environment variable
32
- ([instructions](https://windowsloop.com/install-ffmpeg-windows-10/)).
33
-
34
- Alternatively, you can provide the location using
35
- `ScreenRecorder.ffmpeg_binary = '/path/to/binary'` in your project.
36
-
37
- #### 2. Install gem
38
-
39
- Next, add this line to your application's Gemfile:
40
-
41
- ```ruby
42
- gem 'screen-recorder'
43
- ```
44
-
45
- And then execute:
46
-
47
- ```bash
48
- $ bundle
49
- ```
50
-
51
- Or install it yourself as:
52
-
53
- ```bash
54
- $ gem install screen-recorder
55
- ```
56
-
57
- #### 3. Require gem
58
-
59
- Require this gem in your project and start using the gem:
60
-
61
- ```ruby
62
- require 'screen-recorder'
63
- ```
64
-
65
- ## Record Desktop
66
-
67
- ```ruby
68
- @recorder = ScreenRecorder::Desktop.new(output: 'recording.mp4')
69
- @recorder.start
70
-
71
- # Run tests or whatever you want to record
72
-
73
- @recorder.stop
74
- ```
75
-
76
- Linux users can optionally provide a `$DISPLAY` number as
77
- `input: ':99.0'`. Default is `:0.0`.
78
-
79
- ## Record Application Window (Microsoft Windows only)
80
-
81
- ```ruby
82
- require 'watir'
83
-
84
- browser = Watir::Browser.new :firefox
85
- @recorder = ScreenRecorder::Window.new(title: 'Mozilla Firefox', output: 'recording.mp4')
86
- @recorder.start
87
-
88
- # Run tests or whatever you want to record
89
-
90
- @recorder.stop
91
- browser.quit
92
- ```
93
-
94
- <b>Fetch Title</b>
95
-
96
- A helper method is available to fetch the title of the active window
97
- for the given process name.
98
-
99
- ```ruby
100
- ScreenRecorder::Titles.fetch('firefox') # Name of exe
101
- #=> ["Mozilla Firefox"]
102
- ```
103
-
104
- <b>Limitations</b>
105
- - Only available for Microsoft Windows (*gdigrab*). Linux (*x11grab*) and macOS
106
- (*avfoundation*) capture devices do not provide this feature. However, there
107
- is a workaround documented in the [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki/Window-recording-in-Linux-and-Mac).
108
- - `#fetch` only returns the title from a currently active (visible) window
109
- for the given process.
110
- - `#fetch` may return `ArgumentError (invalid byte sequence in UTF-8)`
111
- for a window title with non `UTF-8` characters. See [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki/Invalid-byte-sequence-in-UTF-8)
112
- for workaround.
113
- - Always stop the recording before closing the application. Otherwise,
114
- ffmpeg will force exit as soon as the window disappears and may produce
115
- an invalid video file.
116
- - If you're launching multiple applications or testing an application
117
- at different window sizes, recording the `desktop` is a better option.
118
-
119
- ## Output
120
-
121
- ```ruby
122
- @recorder.video
123
- #=> #<FFMPEG::Movie:0x00000000067e0a08
124
- @path="recording.mp4",
125
- @container="mov,mp4,m4a,3gp,3g2,mj2",
126
- @duration=5.0,
127
- @time=0.0,
128
- @creation_time=nil,
129
- @bitrate=1051,
130
- @rotation=nil,
131
- @video_stream="h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 2560x1440, 1048 kb/s, 15 fps, 15 tbr, 15360 tbn, 30 tbc (default)",
132
- @audio_stream=nil,
133
- @video_codec="h264 (High 4:4:4 Predictive) (avc1 / 0x31637661)", @colorspace="yuv444p",
134
- @video_bitrate=1048,
135
- @resolution="2560x1440">
136
- ```
137
-
138
- If your test passes or you do not want the record for any reason,
139
- simply call `@recorder.discard` or `@recorder.delete` to delete
140
- the video file.
141
-
142
- ## Advanced Options
143
-
144
- You can provide additional parameters to FFmpeg using the `advanced`
145
- parameter. The keys in the Hash are prefixed with `-` and paired with the
146
- values in the final command.
147
-
148
- ```ruby
149
- advanced = { framerate: 30,
150
- log: 'recorder.log',
151
- loglevel: 'level+debug', # For FFmpeg
152
- video_size: '640x480',
153
- show_region: '1' }
154
- ScreenRecorder::Desktop.new(output: 'recording.mp4',
155
- advanced: advanced)
156
- ```
157
-
158
- This will be parsed as:
159
-
160
- ```bash
161
- ffmpeg -y -f gdigrab -framerate 30 -loglevel level+debug -video_size 640x480 -show_region 1 -i desktop recording.mp4 2> recorder.log
162
- ```
163
-
164
- This feature is yet to be fully tested, so please feel free
165
- to report any bugs or request a feature.
166
-
167
- ## Logging
168
-
169
- You can also configure the logging level of the gem:
170
-
171
- ```ruby
172
- ScreenRecorder.logger.level = Logger::DEBUG
173
- ```
174
-
175
- ## Use with Cucumber
176
-
177
- A Cucumber + Watir based example is available
178
- [here](https://github.com/kapoorlakshya/cucumber-watir-test-recorder-example).
179
-
180
- ## Development
181
-
182
- After checking out the repo, run `bin/setup` to install dependencies.
183
- Then, run `bundle exec rake spec` to run the tests. You can also run
184
- `bin/console` for an interactive prompt that will allow you to experiment.
185
-
186
- To install this gem onto your local machine, run `bundle exec rake install`.
187
-
188
- ## Contributing
189
-
190
- Bug reports and pull requests are welcome.
191
-
192
- - Please update the specs for your code changes and run them locally with `bundle exec rake spec`.
193
- - Follow the Ruby style guide and format your code - https://github.com/rubocop-hq/ruby-style-guide
194
-
195
- ## License
196
-
197
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
198
-
199
- ## Credits
200
-
201
- [![Streamio](http://d253c4ja9jigvu.cloudfront.net/assets/small-logo.png)](http://streamio.com)
202
-
203
- This gem is based on the [streamio-ffmpeg](https://github.com/streamio/streamio-ffmpeg) gem.
204
- <br />
205
- <br />
206
-
207
- ![SauceLabs Logo](https://saucelabs.com/content/images/logo.png)
208
-
209
- Thanks to [SauceLabs](https://saucelabs.com) for providing me with a
210
- free account. If you manage an open source project, you can apply for
1
+ # ScreenRecorder
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/screen-recorder.svg)](https://badge.fury.io/rb/screen-recorder)
4
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/kapoorlakshya/screen-recorder/master)
5
+ [![Build Status](https://travis-ci.org/kapoorlakshya/screen-recorder.svg?branch=master)](https://travis-ci.org/kapoorlakshya/screen-recorder)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/b6049dfee7375aed9bc8/maintainability)](https://codeclimate.com/github/kapoorlakshya/screen-recorder/maintainability)
7
+
8
+ A Ruby gem to video record your computer screen - desktop or specific
9
+ window - using [FFmpeg](https://www.ffmpeg.org/). Primarily
10
+ geared towards recording automated UI test executions for debugging
11
+ and documentation.
12
+
13
+ Demo - [https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem](https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem).
14
+
15
+ ## Compatibility
16
+
17
+ Works on Windows, Linux, and macOS. Requires Ruby 2.0.0 or higher.
18
+
19
+ ## Installation
20
+
21
+ ##### 1. Setup FFmpeg
22
+
23
+ Linux and macOS instructions are [here](https://www.ffmpeg.org/download.html).
24
+
25
+ For Microsoft Windows, download the *libx264* enabled binary from [here](https://ffmpeg.zeranoe.com/builds/).
26
+ Once downloaded, add location of the `ffmpeg/bin` folder to `PATH` environment variable
27
+ ([instructions](https://windowsloop.com/install-ffmpeg-windows-10/)).
28
+
29
+ Alternatively, you can provide the location using
30
+ `ScreenRecorder.ffmpeg_binary = '/path/to/binary'` in your project.
31
+
32
+ ##### 2. Install gem
33
+
34
+ Next, add this line to your application's Gemfile:
35
+
36
+ ```ruby
37
+ gem 'screen-recorder'
38
+ ```
39
+
40
+ And then execute:
41
+
42
+ ```bash
43
+ $ bundle
44
+ ```
45
+
46
+ Or install it yourself as:
47
+
48
+ ```bash
49
+ $ gem install screen-recorder
50
+ ```
51
+
52
+ ##### 3. Require gem
53
+
54
+ ```ruby
55
+ require 'screen-recorder'
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ #### Record Desktop
61
+
62
+ ```ruby
63
+ @recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')
64
+ @recorder.start
65
+
66
+ # Run tests or whatever you want to record
67
+
68
+ @recorder.stop
69
+ ```
70
+
71
+ Linux and macOS users can optionally provide a display or input device number as
72
+ `input: ':99'`. Default is `:0` on Linux and `1` on macOS.
73
+
74
+ Run command `echo $DISPLAY` on Linux and `ffmpeg -f avfoundation -list_devices true -i ""` on macOS to get a list of available
75
+ inputs.
76
+
77
+ #### Record Application Window (Microsoft Windows only)
78
+
79
+ ```ruby
80
+ require 'watir'
81
+
82
+ browser = Watir::Browser.new :firefox
83
+ @recorder = ScreenRecorder::Window.new(title: 'Mozilla Firefox', output: 'recording.mkv')
84
+ @recorder.start
85
+
86
+ # Run tests or whatever you want to record
87
+
88
+ @recorder.stop
89
+ browser.quit
90
+ ```
91
+
92
+ ##### Fetch Title
93
+
94
+ A helper method is available to fetch the title of the active window
95
+ for the given process name.
96
+
97
+ ```ruby
98
+ ScreenRecorder::Titles.fetch('firefox') # Name of exe
99
+ #=> ["Mozilla Firefox"]
100
+ ```
101
+
102
+ ##### Limitations
103
+
104
+ - Only available for Microsoft Windows (*gdigrab*). Linux (*x11grab*) and macOS
105
+ (*avfoundation*) capture devices do not provide this feature. However, there
106
+ is a workaround documented in the [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki/Window-recording-in-Linux-and-Mac).
107
+ - Always stop the recording before closing the application. Otherwise,
108
+ ffmpeg will force exit as soon as the window disappears and may produce
109
+ an invalid video file.
110
+ - If you're launching multiple applications or testing an application
111
+ at different window sizes, recording the `desktop` is a better option.
112
+ - `#fetch` only returns the title from a currently active (visible) window
113
+ for the given process.
114
+ - `#fetch` may return `ArgumentError (invalid byte sequence in UTF-8)`
115
+ for a window title with non `UTF-8` characters. See [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki/Invalid-byte-sequence-in-UTF-8)
116
+ for workaround.
117
+
118
+ #### Output
119
+
120
+ Once the recorder is stopped, you can view the video metadata or transcode
121
+ it if desired. See [`streamio-ffmpeg`](https://github.com/streamio/streamio-ffmpeg) for more details.
122
+
123
+ ```ruby
124
+ @recorder.video
125
+ => #<FFMPEG::Movie:0x0000000004327900
126
+ @path="recording.mkv",
127
+ @metadata={:streams=>[{:index=>0, :codec_name=>"h264", :codec_long_name=>"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
128
+ :profile=>"High",
129
+ :codec_type=>"video",
130
+ ...
131
+ @bitrate=264198,
132
+ @video_codec="h264",
133
+ @colorspace="yuv420p",
134
+ @width=1920,
135
+ @height=1080,
136
+ @video_bitrate=0,
137
+ ... >
138
+ ```
139
+
140
+ If your test passes or you do not want the recording for any reason,
141
+ simply call `@recorder.discard` or `@recorder.delete` to delete
142
+ the video file.
143
+
144
+ #### Advanced Options
145
+
146
+ You can provide additional parameters to FFmpeg using the `advanced`
147
+ parameter. The keys in the Hash are prefixed with `-` and paired with the
148
+ values in the final command.
149
+
150
+ ```ruby
151
+ advanced = { framerate: 30,
152
+ log: 'recorder.log',
153
+ loglevel: 'level+debug', # For FFmpeg
154
+ video_size: '640x480',
155
+ show_region: '1' }
156
+ ScreenRecorder::Desktop.new(output: 'recording.mkv',
157
+ advanced: advanced)
158
+ ```
159
+
160
+ This will be parsed as:
161
+
162
+ ```bash
163
+ ffmpeg -y -f gdigrab -framerate 30 -loglevel level+debug -video_size 640x480 -show_region 1 -i desktop recording.mkv 2> recorder.log
164
+ ```
165
+
166
+ This feature is yet to be fully tested, so please feel free
167
+ to report any bugs or request a feature.
168
+
169
+ #### Logging
170
+
171
+ You can configure the logging level of the gem to troubleshoot problems:
172
+
173
+ ```ruby
174
+ ScreenRecorder.logger.level = :DEBUG
175
+ ```
176
+
177
+ Also refer to the `ffmpeg.log` file for details.
178
+
179
+ #### Use with Cucumber
180
+
181
+ A Cucumber + Watir based example is available
182
+ [here](https://github.com/kapoorlakshya/cucumber-watir-test-recorder-example).
183
+
184
+ ## Wiki
185
+
186
+ Please see the [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki) for solutions to commonly reported issues.
187
+
188
+ ## Development
189
+
190
+ After checking out the repo, run `bin/setup` to install dependencies.
191
+ Then, run `bundle exec rake spec` to run the tests. You can also run
192
+ `bin/console` for an interactive prompt that will allow you to experiment.
193
+
194
+ To install this gem onto your local machine, run `bundle exec rake install`.
195
+
196
+ ### Contributing
197
+
198
+ Bug reports and pull requests are welcome.
199
+
200
+ - Please update the specs for your code changes and run them locally with `bundle exec rake spec`.
201
+ - Follow the Ruby style guide and format your code - <https://github.com/rubocop-hq/ruby-style-guide>
202
+
203
+ ### License
204
+
205
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
206
+
207
+ ## Credits
208
+
209
+ [![Streamio](http://d253c4ja9jigvu.cloudfront.net/assets/small-logo.png)](http://streamio.com)
210
+
211
+ This gem is based on the [streamio-ffmpeg](https://github.com/streamio/streamio-ffmpeg) gem.
212
+ <br />
213
+ <br />
214
+
215
+ ![SauceLabs Logo](https://saucelabs.com/content/images/logo.png)
216
+
217
+ Thanks to [SauceLabs](https://saucelabs.com) for providing me with a
218
+ free account. If you manage an open source project, you can apply for
211
219
  a free account [here](https://saucelabs.com/open-source).