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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +7 -5
- data/.gitignore +99 -107
- data/.rspec +3 -3
- data/.rubocop.yml +45 -37
- data/.travis.yml +35 -32
- data/CHANGES.md +78 -70
- data/LICENSE.txt +21 -21
- data/README.md +218 -210
- data/Rakefile +6 -1
- data/bin/console +0 -0
- data/bin/setup +8 -8
- data/lib/screen-recorder.rb +53 -45
- data/lib/screen-recorder/common.rb +146 -127
- data/lib/screen-recorder/desktop.rb +40 -30
- data/lib/screen-recorder/errors.rb +9 -9
- data/lib/screen-recorder/options.rb +151 -148
- data/lib/screen-recorder/titles.rb +49 -81
- data/lib/screen-recorder/type_checker.rb +11 -11
- data/lib/screen-recorder/version.rb +2 -2
- data/lib/screen-recorder/window.rb +22 -22
- data/screen-recorder.gemspec +40 -31
- metadata +54 -21
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
|
-
![
|
5
|
-
[![
|
6
|
-
[![
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
@recorder
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
the
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
```
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
```
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
##
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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).
|