screen-recorder 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +99 -99
- data/.rspec +3 -3
- data/.rubocop.yml +1 -1
- data/.travis.yml +49 -35
- data/CHANGES.md +89 -78
- data/LICENSE.txt +21 -21
- data/README.md +212 -218
- data/appveyor.yml +23 -0
- data/bin/console +0 -0
- data/bin/setup +8 -8
- data/lib/screen-recorder.rb +54 -53
- data/lib/screen-recorder/common.rb +152 -146
- data/lib/screen-recorder/desktop.rb +40 -40
- data/lib/screen-recorder/errors.rb +9 -9
- data/lib/screen-recorder/options.rb +168 -151
- data/lib/screen-recorder/titles.rb +52 -49
- data/lib/screen-recorder/type_checker.rb +13 -11
- data/lib/screen-recorder/version.rb +2 -2
- data/lib/screen-recorder/window.rb +22 -22
- data/screen-recorder.gemspec +41 -39
- metadata +34 -6
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,219 +1,213 @@
|
|
1
|
-
# ScreenRecorder
|
2
|
-
|
3
|
-
[](https://badge.fury.io/rb/screen-recorder)
|
4
|
-
[](https://www.rubydoc.info/github/kapoorlakshya/screen-recorder/master)
|
5
|
-
[](https://travis-ci.org/kapoorlakshya/screen-recorder)
|
6
|
-
[
|
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
|
1
|
+
# ScreenRecorder
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/screen-recorder)
|
4
|
+
[](https://www.rubydoc.info/github/kapoorlakshya/screen-recorder/master)
|
5
|
+
[](https://travis-ci.org/kapoorlakshya/screen-recorder)
|
6
|
+
[](https://ci.appveyor.com/project/kapoorlakshya/screen-recorder/branch/master)
|
7
|
+
[](https://codeclimate.com/github/kapoorlakshya/screen-recorder/maintainability)
|
8
|
+
[](https://codeclimate.com/github/kapoorlakshya/screen-recorder/test_coverage)
|
9
|
+
|
10
|
+
A Ruby gem to video record your computer screen - desktop or specific
|
11
|
+
window - using [FFmpeg](https://www.ffmpeg.org/). Primarily
|
12
|
+
geared towards recording automated UI test executions for debugging
|
13
|
+
and documentation.
|
14
|
+
|
15
|
+
Demo - [https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem](https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem).
|
16
|
+
|
17
|
+
## Compatibility
|
18
|
+
|
19
|
+
Works on Windows, Linux, and macOS. Requires Ruby 2.0 or higher.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
##### 1. Setup FFmpeg
|
24
|
+
|
25
|
+
Linux and macOS instructions are [here](https://www.ffmpeg.org/download.html).
|
26
|
+
|
27
|
+
For Microsoft Windows, download the *libx264* enabled binary from [here](https://ffmpeg.zeranoe.com/builds/).
|
28
|
+
Once downloaded, add location of the `ffmpeg/bin` folder to `PATH` environment variable
|
29
|
+
([instructions](https://windowsloop.com/install-ffmpeg-windows-10/)).
|
30
|
+
|
31
|
+
Alternatively, you can point to the binary file using
|
32
|
+
`ScreenRecorder.ffmpeg_binary = '/path/to/ffmpeg'` in your project.
|
33
|
+
|
34
|
+
##### 2. Install gem
|
35
|
+
|
36
|
+
Next, add this line to your application's Gemfile:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
gem 'screen-recorder'
|
40
|
+
```
|
41
|
+
|
42
|
+
And then execute:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
$ bundle
|
46
|
+
```
|
47
|
+
|
48
|
+
Or install it yourself as:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
$ gem install screen-recorder
|
52
|
+
```
|
53
|
+
|
54
|
+
##### 3. Require gem
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'screen-recorder'
|
58
|
+
```
|
59
|
+
|
60
|
+
## Usage
|
61
|
+
|
62
|
+
#### Record Desktop
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
@recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')
|
66
|
+
@recorder.start
|
67
|
+
|
68
|
+
# Run tests or whatever you want to record
|
69
|
+
|
70
|
+
@recorder.stop
|
71
|
+
```
|
72
|
+
|
73
|
+
Linux and macOS users can optionally provide a display or input device number.
|
74
|
+
Read more about it in the wiki [here](https://github.com/kapoorlakshya/screen-recorder/wiki/Input-Values).
|
75
|
+
|
76
|
+
#### Record Application Window (Microsoft Windows only)
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
require 'watir'
|
80
|
+
|
81
|
+
browser = Watir::Browser.new :firefox
|
82
|
+
@recorder = ScreenRecorder::Window.new(title: 'Mozilla Firefox', output: 'recording.mkv')
|
83
|
+
@recorder.start
|
84
|
+
|
85
|
+
# Run tests or whatever you want to record
|
86
|
+
|
87
|
+
@recorder.stop
|
88
|
+
browser.quit
|
89
|
+
```
|
90
|
+
|
91
|
+
##### Fetch Title
|
92
|
+
|
93
|
+
A helper method is available to fetch the title of the active window
|
94
|
+
for the given process name.
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
ScreenRecorder::Titles.fetch('firefox') # Name of exe
|
98
|
+
#=> ["Mozilla Firefox"]
|
99
|
+
|
100
|
+
ScreenRecorder::Titles.fetch('chrome')
|
101
|
+
#=> ["New Tab - Google Chrome"]
|
102
|
+
```
|
103
|
+
|
104
|
+
This mode has limited capabilities. Read more about it in the wiki
|
105
|
+
[here](https://github.com/kapoorlakshya/screen-recorder/wiki/Window-Capture-Limitations).
|
106
|
+
|
107
|
+
#### Output
|
108
|
+
|
109
|
+
Once the recorder is stopped, you can view the video metadata or transcode
|
110
|
+
it if desired.
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
@recorder.video
|
114
|
+
=> #<FFMPEG::Movie:0x0000000004327900
|
115
|
+
@path="recording.mkv",
|
116
|
+
@metadata={:streams=>[{:index=>0, :codec_name=>"h264", :codec_long_name=>"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
|
117
|
+
:profile=>"High",
|
118
|
+
:codec_type=>"video"}
|
119
|
+
@video_codec="h264",
|
120
|
+
@colorspace="yuv420p",
|
121
|
+
... >
|
122
|
+
|
123
|
+
@recorder.video.transcode("movie.mp4") { |progress| puts progress } # 0.2 ... 0.5 ... 1.0
|
124
|
+
```
|
125
|
+
|
126
|
+
See [`streamio-ffmpeg`](https://github.com/streamio/streamio-ffmpeg) gem for more details.
|
127
|
+
|
128
|
+
#### Discard Recoding
|
129
|
+
|
130
|
+
If your test passes or you do not want the recording for any reason,
|
131
|
+
simply call `@recorder.discard` or `@recorder.delete` to delete
|
132
|
+
the video file.
|
133
|
+
|
134
|
+
#### Advanced Options
|
135
|
+
|
136
|
+
You can provide additional parameters to FFmpeg using the `advanced`
|
137
|
+
parameter. You can specify input/output specific parameters using the `input: {}`
|
138
|
+
and `output: {}` within the `advanced` Hash.
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
advanced = {
|
142
|
+
input: {
|
143
|
+
framerate: 30,
|
144
|
+
pix_fmt: 'yuv420p',
|
145
|
+
video_size: '1280x720'
|
146
|
+
},
|
147
|
+
output: {
|
148
|
+
r: 15, # Framerate
|
149
|
+
pix_fmt: 'yuv420p'
|
150
|
+
},
|
151
|
+
log: 'recorder.log',
|
152
|
+
loglevel: 'level+debug', # For FFmpeg
|
153
|
+
}
|
154
|
+
ScreenRecorder::Desktop.new(output: 'recording.mkv', advanced: advanced)
|
155
|
+
```
|
156
|
+
|
157
|
+
This will be parsed as:
|
158
|
+
|
159
|
+
```bash
|
160
|
+
ffmpeg -y -f gdigrab -framerate 30 -pix_fmt yuv420p -video_size 1280x720 -i desktop -r 15 pix_fmt yuv420p -loglevel level+debug recording.mkv
|
161
|
+
```
|
162
|
+
|
163
|
+
#### Logging & Debugging
|
164
|
+
|
165
|
+
You can configure the logging level of the gem to troubleshoot problems:
|
166
|
+
|
167
|
+
```ruby
|
168
|
+
ScreenRecorder.logger.level = :DEBUG
|
169
|
+
```
|
170
|
+
|
171
|
+
Also refer to the `ffmpeg.log` file for details.
|
172
|
+
|
173
|
+
#### Use with Cucumber
|
174
|
+
|
175
|
+
A Cucumber + Watir based example is available
|
176
|
+
[here](https://github.com/kapoorlakshya/cucumber-watir-test-recorder-example).
|
177
|
+
|
178
|
+
## Wiki
|
179
|
+
|
180
|
+
Please see the [wiki](https://github.com/kapoorlakshya/screen-recorder/wiki) for solutions to commonly reported issues.
|
181
|
+
|
182
|
+
## Development
|
183
|
+
|
184
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
185
|
+
Then, run `bundle exec rake` to run the tests and rubocop. You can also run
|
186
|
+
`bin/console` for an interactive prompt that will allow you to experiment.
|
187
|
+
|
188
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
189
|
+
|
190
|
+
### Contributing
|
191
|
+
|
192
|
+
Bug reports and pull requests are welcome.
|
193
|
+
|
194
|
+
- Please update the specs for your code changes and run them locally with `bundle exec rake spec`.
|
195
|
+
- Follow the Ruby style guide and format your code - <https://github.com/rubocop-hq/ruby-style-guide>
|
196
|
+
|
197
|
+
### License
|
198
|
+
|
199
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
200
|
+
|
201
|
+
## Credits
|
202
|
+
|
203
|
+
[](http://streamio.com)
|
204
|
+
|
205
|
+
This gem is based on the [streamio-ffmpeg](https://github.com/streamio/streamio-ffmpeg) gem.
|
206
|
+
<br />
|
207
|
+
<br />
|
208
|
+
|
209
|
+

|
210
|
+
|
211
|
+
Thanks to [SauceLabs](https://saucelabs.com) for providing me with a
|
212
|
+
free account. If you manage an open source project, you can apply for
|
219
213
|
a free account [here](https://saucelabs.com/open-source).
|