screen-recorder 1.3.1 → 1.4.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 +1 -0
- data/.rspec +3 -3
- data/.rubocop.yml +6 -6
- data/.travis.yml +3 -3
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +21 -21
- data/README.md +59 -4
- data/appveyor.yml +8 -8
- data/bin/console +0 -0
- data/bin/setup +8 -8
- data/lib/screen-recorder.rb +6 -1
- data/lib/screen-recorder/common.rb +76 -35
- data/lib/screen-recorder/errors.rb +10 -2
- data/lib/screen-recorder/options.rb +7 -7
- data/lib/screen-recorder/version.rb +1 -1
- data/lib/screen-recorder/window.rb +3 -1
- data/screen-recorder.gemspec +3 -2
- data/support/install_jruby.ps1 +2 -2
- metadata +15 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07a4db7e87e1575f6ab01b6f07f91e23d4ca7002fbaeaada1c699e191da11c4d
|
4
|
+
data.tar.gz: 1da1db9f4b5cce4a96c7e550b8e47456dc12ea7ed32cb759d300f95edb38c042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4ae54ee250118a5c5ad525d74bac390e98f6c780a3518ff3c4d591ccd23ef7465dcd91ecf4e818284953c70eb0f497aa075120adf456b0edb79d633ea32a858
|
7
|
+
data.tar.gz: 18cf226da4ea901e956cadf490048367a95b96e441e867df982749b1ce9f72a82c6e3f202e06aa408612e8a4508d1a8189041f9abe80e45066d8907fad16bc9e
|
data/.github/ISSUE_TEMPLATE.md
CHANGED
@@ -6,6 +6,7 @@ Please provide the following information for bug reports:
|
|
6
6
|
|
7
7
|
* Operating system - Microsoft Windows, Linux, or macOS.
|
8
8
|
* Ruby version
|
9
|
+
* screen-recorder version
|
9
10
|
* Recorder parameters - input, output, etc.
|
10
11
|
* Recorder log (`ffmpeg.log`) file as a gist or on pastebin.com.
|
11
12
|
* Set `ScreenRecorder.logger.level = Logger::DEBUG`, run the recorder, and share the
|
data/.rspec
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
--format documentation
|
2
|
-
--color
|
3
|
-
--require spec_helper
|
1
|
+
--format documentation
|
2
|
+
--color
|
3
|
+
--require spec_helper
|
data/.rubocop.yml
CHANGED
@@ -17,25 +17,25 @@ Layout/EndOfLine:
|
|
17
17
|
Layout/MultilineMethodCallIndentation:
|
18
18
|
EnforcedStyle: indented_relative_to_receiver
|
19
19
|
|
20
|
-
Layout/
|
20
|
+
Layout/ArrayAlignment:
|
21
21
|
Enabled: true
|
22
22
|
|
23
|
-
Layout/
|
23
|
+
Layout/HashAlignment:
|
24
24
|
Enabled: true
|
25
25
|
EnforcedHashRocketStyle: key
|
26
26
|
EnforcedColonStyle: table
|
27
27
|
|
28
|
-
Layout/
|
28
|
+
Layout/ParameterAlignment:
|
29
29
|
Enabled: true
|
30
30
|
EnforcedStyle: with_first_parameter
|
31
31
|
|
32
|
-
Layout/
|
32
|
+
Layout/FirstHashElementIndentation:
|
33
33
|
Enabled: true
|
34
34
|
|
35
|
-
Layout/
|
35
|
+
Layout/TrailingEmptyLines:
|
36
36
|
Enabled: false
|
37
37
|
|
38
|
-
|
38
|
+
Layout/LineLength:
|
39
39
|
Max: 120
|
40
40
|
|
41
41
|
Metrics/MethodLength:
|
data/.travis.yml
CHANGED
@@ -14,10 +14,10 @@ matrix:
|
|
14
14
|
- rvm: 2.4.6
|
15
15
|
dist: xenial
|
16
16
|
env: RAKE_TASK=rubocop
|
17
|
-
- rvm: 2.
|
17
|
+
- rvm: 2.7.0
|
18
18
|
dist: xenial
|
19
19
|
env: RAKE_TASK=spec REPORT_COVERAGE=true
|
20
|
-
- rvm: jruby-9.2.
|
20
|
+
- rvm: jruby-9.2.9.0
|
21
21
|
dist: xenial
|
22
22
|
jdk: openjdk8
|
23
23
|
env: RAKE_TASK=spec JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"
|
@@ -39,4 +39,4 @@ before_script:
|
|
39
39
|
- bash support/start_test_reporter.sh
|
40
40
|
script: bundle exec rake $RAKE_TASK
|
41
41
|
after_script:
|
42
|
-
- bash support/stop_test_reporter.sh
|
42
|
+
- bash support/stop_test_reporter.sh
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
4
4
|
|
5
|
+
### 1.4.0 (2019-10-27)
|
6
|
+
* Users can now select a ffmpeg [capture device](https://ffmpeg.org/ffmpeg-devices.html) from advanced -> input.
|
7
|
+
* Fix a bug where some advanced parameters were not parsed correctly.
|
8
|
+
* Add support for audio stream capture ([#15](https://github.com/kapoorlakshya/screen-recorder/issues/15))
|
9
|
+
* Fix [#84](https://github.com/kapoorlakshya/screen-recorder/issues/84) where the user given ffmpeg binary path was never used.
|
10
|
+
* Relax childprocess gem version requirement to roughly match requirements in `selenium-webdriver` gem ([#85](https://github.com/kapoorlakshya/screen-recorder/issues/85))
|
11
|
+
* Add support for capturing screenshots in both desktop and window modes ([#44](https://github.com/kapoorlakshya/screen-recorder/issues/44)).
|
12
|
+
|
5
13
|
### 1.3.1 (2019-10-20)
|
6
14
|
* Reattempt `ffprobe` execution up to times if the first try raises `Errno::EAGAIN`.
|
7
15
|
Hopefully fixes [#79](https://github.com/kapoorlakshya/screen-recorder/issues/79).
|
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
@@ -7,13 +7,13 @@
|
|
7
7
|
[![Maintainability](https://api.codeclimate.com/v1/badges/b6049dfee7375aed9bc8/maintainability)](https://codeclimate.com/github/kapoorlakshya/screen-recorder/maintainability)
|
8
8
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/b6049dfee7375aed9bc8/test_coverage)](https://codeclimate.com/github/kapoorlakshya/screen-recorder/test_coverage)
|
9
9
|
|
10
|
-
A Ruby gem to video record your computer screen - desktop or specific
|
10
|
+
A Ruby gem to video record or take screenshots of your computer screen - desktop or specific
|
11
11
|
window - using [FFmpeg](https://www.ffmpeg.org/). Primarily
|
12
12
|
geared towards recording automated UI (Selenium) test executions for
|
13
13
|
debugging and documentation.
|
14
14
|
|
15
15
|
#### Demo
|
16
|
-
[https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem](https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem)
|
16
|
+
[https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem](https://kapoorlakshya.github.io/introducing-screen-recorder-ruby-gem)
|
17
17
|
|
18
18
|
## Compatibility
|
19
19
|
|
@@ -96,7 +96,7 @@ browser = Watir::Browser.new :firefox
|
|
96
96
|
@recorder.stop
|
97
97
|
browser.quit
|
98
98
|
```
|
99
|
-
This mode has
|
99
|
+
This mode has a few limitations which are listed in the wiki
|
100
100
|
[here](https://github.com/kapoorlakshya/screen-recorder/wiki/Window-Capture-Limitations).
|
101
101
|
|
102
102
|
##### Fetch Title
|
@@ -112,7 +112,62 @@ ScreenRecorder::Window.fetch_title('chrome')
|
|
112
112
|
#=> ["New Tab - Google Chrome"]
|
113
113
|
```
|
114
114
|
|
115
|
-
####
|
115
|
+
#### Capture Audio
|
116
|
+
|
117
|
+
Provide the following `advanced` configurations to capture audio:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
# Linux
|
121
|
+
advanced = { f: 'alsa', ac: 2, i: 'hw:0'} # Using ALSA
|
122
|
+
# Or using PulseAudio
|
123
|
+
advanced = { 'f': 'pulse', 'ac': 2, 'i': 'default' } # Records default sound output device
|
124
|
+
|
125
|
+
# macOS
|
126
|
+
advanced = { input: { i: '1:1' } } # -i video:audio input device ID
|
127
|
+
|
128
|
+
# Windows
|
129
|
+
advanced = { f: 'dshow', i: 'audio="Microphone (High Definition Aud"' }
|
130
|
+
```
|
131
|
+
|
132
|
+
You can retrieve a list of audio devices by running these commands:
|
133
|
+
|
134
|
+
```
|
135
|
+
# Linux
|
136
|
+
$ arecord -L # See https://trac.ffmpeg.org/wiki/Capture/ALSA
|
137
|
+
|
138
|
+
# macOS
|
139
|
+
$ ffmpeg -f avfoundation -list_devices true -i ""
|
140
|
+
|
141
|
+
# Windows
|
142
|
+
> ffmpeg -list_devices true -f dshow -i dummy
|
143
|
+
```
|
144
|
+
|
145
|
+
#### Screenshots
|
146
|
+
|
147
|
+
Screenshots can be captured at any point after initializing the recorder:
|
148
|
+
|
149
|
+
```ruby
|
150
|
+
# Desktop
|
151
|
+
@recorder = ScreenRecorder::Desktop.new(output: 'recording.mkv')
|
152
|
+
@recorder.screenshot('before-recording.png')
|
153
|
+
@recorder.start
|
154
|
+
@recorder.screenshot('during-recording.png')
|
155
|
+
@recorder.stop
|
156
|
+
@recorder.screenshot('after-recording.png')
|
157
|
+
|
158
|
+
# Window (Microsoft Windows only)
|
159
|
+
browser = Watir::Browser.new :chrome, options: { args: ['--disable-gpu'] } # Hardware acceleration must be disabled
|
160
|
+
browser.goto('watir.com')
|
161
|
+
window_title = ScreenRecorder::Titles.fetch('chrome').first
|
162
|
+
@recorder = ScreenRecorder::Window.new(title: window_title, output: 'recording.mkv')
|
163
|
+
@recorder.screenshot('before-recording.png')
|
164
|
+
@recorder.start
|
165
|
+
@recorder.screenshot('during-recording.png')
|
166
|
+
@recorder.stop
|
167
|
+
@recorder.screenshot('after-recording.png')
|
168
|
+
browser.quit
|
169
|
+
```
|
170
|
+
#### Video Output
|
116
171
|
|
117
172
|
Once the recorder is stopped, you can view the video metadata or transcode
|
118
173
|
it if desired.
|
data/appveyor.yml
CHANGED
@@ -15,7 +15,7 @@ environment:
|
|
15
15
|
RUBY_BIN: ruby
|
16
16
|
RAKE_TASK: spec
|
17
17
|
SCRIPT_CONTEXT: bundle exec
|
18
|
-
- RUBY_VERSION: jruby-9.2.
|
18
|
+
- RUBY_VERSION: jruby-9.2.9.0
|
19
19
|
RUBY_BIN: jruby
|
20
20
|
RAKE_TASK: spec
|
21
21
|
SCRIPT_CONTEXT: jruby -G -S
|
@@ -27,13 +27,13 @@ install:
|
|
27
27
|
}
|
28
28
|
- choco install ffmpeg
|
29
29
|
- set PATH=C:\%RUBY_VERSION%\bin;%PATH%
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
30
|
+
- "%RUBY_BIN% -S gem update --system"
|
31
|
+
- "%RUBY_BIN% -S gem install bundler"
|
32
|
+
- "%RUBY_BIN% -S bundle install"
|
33
33
|
before_test:
|
34
34
|
- ffmpeg -version
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
35
|
+
- "%RUBY_BIN% -v"
|
36
|
+
- "%RUBY_BIN% -S gem -v"
|
37
|
+
- "%RUBY_BIN% -S bundle -v"
|
38
38
|
test_script:
|
39
|
-
-
|
39
|
+
- "%SCRIPT_CONTEXT% rake %RAKE_TASK%"
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/lib/screen-recorder.rb
CHANGED
@@ -12,14 +12,19 @@ module ScreenRecorder
|
|
12
12
|
# ScreenRecorder.ffmpeg_binary = 'C:\ffmpeg.exe'
|
13
13
|
#
|
14
14
|
def self.ffmpeg_binary=(bin)
|
15
|
+
ScreenRecorder.logger.debug 'Setting ffmpeg path...'
|
15
16
|
FFMPEG.ffmpeg_binary = bin
|
17
|
+
ScreenRecorder.logger.debug "ffmpeg path set: #{bin}"
|
18
|
+
ScreenRecorder.ffmpeg_binary
|
16
19
|
end
|
17
20
|
|
18
21
|
#
|
19
|
-
# Returns path to ffmpeg binary
|
22
|
+
# Returns path to ffmpeg binary or raises DependencyNotFound
|
20
23
|
#
|
21
24
|
def self.ffmpeg_binary
|
22
25
|
FFMPEG.ffmpeg_binary
|
26
|
+
rescue Errno::ENOENT # Raised when binary is not set in project or found in ENV
|
27
|
+
raise Errors::DependencyNotFound
|
23
28
|
end
|
24
29
|
|
25
30
|
#
|
@@ -9,6 +9,8 @@ module ScreenRecorder
|
|
9
9
|
attr_reader :options, :video
|
10
10
|
|
11
11
|
def initialize(input:, output:, advanced: {})
|
12
|
+
raise Errors::DependencyNotFound unless ffmpeg_exists?
|
13
|
+
|
12
14
|
@options = Options.new(input: input, output: output, advanced: advanced)
|
13
15
|
@video = nil
|
14
16
|
@process = nil
|
@@ -36,13 +38,27 @@ module ScreenRecorder
|
|
36
38
|
@video = prepare_video
|
37
39
|
end
|
38
40
|
|
41
|
+
#
|
42
|
+
# Takes a screenshot in the current context (input) - desktop or current window
|
43
|
+
#
|
44
|
+
def screenshot(filename)
|
45
|
+
process = execute_command(screenshot_cmd(filename))
|
46
|
+
exit_code = wait_for_process_exit(process) # 0 (success) or 1 (fail)
|
47
|
+
if exit_code.zero?
|
48
|
+
ScreenRecorder.logger.info "Screenshot: #{filename}"
|
49
|
+
return filename
|
50
|
+
end
|
51
|
+
ScreenRecorder.logger.error 'Failed to take a screenshot.'
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
39
55
|
#
|
40
56
|
# Discards the recorded file. Useful in automated testing
|
41
57
|
# when a test passes and the recorded file is no longer
|
42
58
|
# needed.
|
43
59
|
#
|
44
60
|
def discard
|
45
|
-
|
61
|
+
File.delete options.output
|
46
62
|
end
|
47
63
|
|
48
64
|
alias delete discard
|
@@ -54,17 +70,9 @@ module ScreenRecorder
|
|
54
70
|
# the given options.
|
55
71
|
#
|
56
72
|
def start_ffmpeg
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
process = build_command
|
61
|
-
@log_file = File.new(options.log, 'w+')
|
62
|
-
process.io.stdout = process.io.stderr = @log_file
|
63
|
-
@log_file.sync = true
|
64
|
-
process.duplex = true
|
65
|
-
process.start
|
66
|
-
sleep(1.5) # Takes ~1.5s on average to initialize
|
67
|
-
# Stopped because of an error
|
73
|
+
process = execute_command(ffmpeg_command, options.log)
|
74
|
+
sleep(1.5) # Takes ~1.5s to initialize ffmpeg
|
75
|
+
# Check if it exited unexpectedly
|
68
76
|
raise FFMPEG::Error, "Failed to start ffmpeg. Reason: #{lines_from_log(:last, 2)}" if process.exited?
|
69
77
|
|
70
78
|
process
|
@@ -78,12 +86,7 @@ module ScreenRecorder
|
|
78
86
|
@process.io.stdin.puts 'q' # Gracefully exit ffmpeg
|
79
87
|
@process.io.stdin.close
|
80
88
|
@log_file.close
|
81
|
-
@process
|
82
|
-
@process.exit_code
|
83
|
-
rescue ChildProcess::TimeoutError
|
84
|
-
ScreenRecorder.logger.error 'FFmpeg failed to stop. Force killing it...'
|
85
|
-
@process.stop # Tries increasingly harsher methods to kill the process.
|
86
|
-
ScreenRecorder.logger.error "Check '#{@options.log}' for more information."
|
89
|
+
wait_for_process_exit(@process)
|
87
90
|
end
|
88
91
|
|
89
92
|
#
|
@@ -107,29 +110,35 @@ module ScreenRecorder
|
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
113
|
+
def ffmpeg_bin
|
114
|
+
"#{ScreenRecorder.ffmpeg_binary} -y"
|
115
|
+
end
|
116
|
+
|
110
117
|
#
|
111
118
|
# Generates the command line arguments based on the given
|
112
119
|
# options.
|
113
120
|
#
|
114
|
-
def
|
115
|
-
|
116
|
-
|
121
|
+
def ffmpeg_command
|
122
|
+
"#{ffmpeg_bin} #{@options.parsed}"
|
123
|
+
end
|
124
|
+
|
125
|
+
#
|
126
|
+
# Parameters to capture a single frame
|
127
|
+
#
|
128
|
+
def screenshot_cmd(filename)
|
129
|
+
# -f overwrites existing file
|
130
|
+
"#{ffmpeg_bin} -f #{options.capture_device} -i #{options.input} -framerate 1 -frames:v 1 #{filename}"
|
117
131
|
end
|
118
132
|
|
119
133
|
#
|
120
134
|
# Returns true if ffmpeg binary is found.
|
121
135
|
#
|
122
136
|
def ffmpeg_exists?
|
123
|
-
return
|
137
|
+
return true if FFMPEG.ffmpeg_binary
|
124
138
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
# ScreenRecorder.ffmpeg_binary returns 'ffmpeg' assuming it must be in ENV. However,
|
129
|
-
# if the above two checks fail, it is not in the ENV either.
|
130
|
-
return false if ScreenRecorder.ffmpeg_binary == 'ffmpeg'
|
131
|
-
|
132
|
-
true
|
139
|
+
false
|
140
|
+
rescue Errno::ENOENT # Raised when binary is not set in project or found in ENV
|
141
|
+
false
|
133
142
|
end
|
134
143
|
|
135
144
|
#
|
@@ -146,15 +155,47 @@ module ScreenRecorder
|
|
146
155
|
end
|
147
156
|
|
148
157
|
#
|
149
|
-
#
|
158
|
+
# Executes the given command and outputs to the
|
159
|
+
# optional logfile
|
160
|
+
#
|
161
|
+
def execute_command(cmd, logfile = nil)
|
162
|
+
ScreenRecorder.logger.debug "Executing command: #{cmd}"
|
163
|
+
process = new_process(cmd)
|
164
|
+
process.duplex = true
|
165
|
+
if logfile
|
166
|
+
@log_file = File.new(logfile, 'w+')
|
167
|
+
process.io.stdout = process.io.stderr = @log_file
|
168
|
+
@log_file.sync = true
|
169
|
+
end
|
170
|
+
process.start
|
171
|
+
process
|
172
|
+
end
|
173
|
+
|
174
|
+
#
|
175
|
+
# Calls Childprocess.new with OS specific arguments
|
176
|
+
# to start the given process.
|
150
177
|
#
|
151
|
-
def
|
152
|
-
ChildProcess.posix_spawn = true # Support JRuby.
|
178
|
+
def new_process(process)
|
179
|
+
ChildProcess.posix_spawn = true if RUBY_PLATFORM == 'java' # Support JRuby.
|
153
180
|
if OS.windows?
|
154
|
-
ChildProcess.
|
181
|
+
ChildProcess.new('cmd.exe', '/c', process)
|
155
182
|
else
|
156
|
-
ChildProcess.
|
183
|
+
ChildProcess.new('sh', '-c', process)
|
157
184
|
end
|
158
185
|
end
|
186
|
+
|
187
|
+
#
|
188
|
+
# Waits for given process to exit.
|
189
|
+
# Forcefully kills the process if it does not
|
190
|
+
# exit within 5 seconds.
|
191
|
+
#
|
192
|
+
def wait_for_process_exit(process)
|
193
|
+
process.poll_for_exit(PROCESS_TIMEOUT)
|
194
|
+
process.exit_code
|
195
|
+
rescue ChildProcess::TimeoutError
|
196
|
+
ScreenRecorder.logger.error 'ffmpeg failed to stop. Force killing it...'
|
197
|
+
process.stop # Tries increasingly harsher methods to kill the process.
|
198
|
+
ScreenRecorder.logger.error 'Forcefully killed ffmpeg.'
|
199
|
+
end
|
159
200
|
end
|
160
201
|
end
|
@@ -2,9 +2,17 @@ module ScreenRecorder
|
|
2
2
|
# @since 1.0.0-beta5
|
3
3
|
module Errors
|
4
4
|
# @since 1.0.0-beta3
|
5
|
-
class ApplicationNotFound < StandardError
|
5
|
+
class ApplicationNotFound < StandardError
|
6
|
+
def message
|
7
|
+
'expected application was not found by ffmpeg.'
|
8
|
+
end
|
9
|
+
end
|
6
10
|
|
7
11
|
# @since 1.0.0-beta5
|
8
|
-
class DependencyNotFound < StandardError
|
12
|
+
class DependencyNotFound < StandardError
|
13
|
+
def message
|
14
|
+
'ffmpeg binary path not set or not found in ENV.'
|
15
|
+
end
|
16
|
+
end
|
9
17
|
end
|
10
18
|
end
|
@@ -74,9 +74,9 @@ module ScreenRecorder
|
|
74
74
|
def parsed
|
75
75
|
vals = "-f #{capture_device} "
|
76
76
|
vals << parse_advanced(advanced_input)
|
77
|
-
vals << "-i #{input} "
|
78
|
-
vals << parse_advanced(advanced_output)
|
77
|
+
vals << "-i #{input} " unless advanced_input[:i] # Input provided by user
|
79
78
|
vals << parse_advanced(advanced)
|
79
|
+
vals << parse_advanced(advanced_output)
|
80
80
|
vals << output
|
81
81
|
end
|
82
82
|
|
@@ -143,19 +143,19 @@ module ScreenRecorder
|
|
143
143
|
# Returns input capture device based on user given value or the current OS.
|
144
144
|
#
|
145
145
|
def determine_capture_device
|
146
|
-
# User given capture device or format
|
146
|
+
# User given capture device or format from advanced configs Hash
|
147
147
|
# @see https://www.ffmpeg.org/ffmpeg.html#Main-options
|
148
|
-
return
|
148
|
+
return advanced_input[:f] if advanced_input[:f]
|
149
149
|
|
150
|
-
return
|
150
|
+
return advanced_input[:fmt] if advanced_input[:fmt]
|
151
151
|
|
152
|
-
|
152
|
+
default_capture_device
|
153
153
|
end
|
154
154
|
|
155
155
|
#
|
156
156
|
# Returns input capture device for current OS.
|
157
157
|
#
|
158
|
-
def
|
158
|
+
def default_capture_device
|
159
159
|
return 'gdigrab' if OS.windows?
|
160
160
|
|
161
161
|
return 'x11grab' if OS.linux?
|
@@ -21,7 +21,7 @@ module ScreenRecorder
|
|
21
21
|
# ScreenRecorder::Window.fetch_title('chrome')
|
22
22
|
# #=> ["New Tab - Google Chrome"]
|
23
23
|
def fetch_title(process_name)
|
24
|
-
ScreenRecorder.logger.debug "Retrieving window title
|
24
|
+
ScreenRecorder.logger.debug "Retrieving window title from '#{process_name}'"
|
25
25
|
window_title_for process_name
|
26
26
|
end
|
27
27
|
|
@@ -43,6 +43,8 @@ module ScreenRecorder
|
|
43
43
|
raise Errors::ApplicationNotFound, "No open windows found for: #{process_name}.exe" if titles.empty?
|
44
44
|
|
45
45
|
warn_on_mismatch(titles, process_name)
|
46
|
+
ScreenRecorder.logger.debug "Retrieved titles: #{titles}"
|
47
|
+
|
46
48
|
titles
|
47
49
|
end
|
48
50
|
|
data/screen-recorder.gemspec
CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
# noinspection RubyStringKeysInHashInspection
|
18
18
|
spec.metadata = {
|
19
19
|
'changelog_uri' => 'https://github.com/kapoorlakshya/screen-recorder/blob/master/CHANGELOG.md',
|
20
|
-
'source_code_uri' =>
|
20
|
+
'source_code_uri' => "https://github.com/kapoorlakshya/screen-recorder/tree/v#{ScreenRecorder::VERSION}",
|
21
|
+
'documentation_uri' => "https://www.rubydoc.info/gems/screen-recorder/#{ScreenRecorder::VERSION}",
|
21
22
|
'bug_tracker_uri' => 'https://github.com/kapoorlakshya/screen-recorder/issues',
|
22
23
|
'wiki_uri' => 'https://github.com/kapoorlakshya/screen-recorder/wiki'
|
23
24
|
}
|
@@ -38,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
38
39
|
spec.add_development_dependency 'watir', '~> 6.0'
|
39
40
|
spec.add_development_dependency 'webdrivers', '~> 4.0'
|
40
41
|
|
41
|
-
spec.add_runtime_dependency 'childprocess', '
|
42
|
+
spec.add_runtime_dependency 'childprocess', '>= 1.0', '< 4.0' # Roughly match Selenium
|
42
43
|
spec.add_runtime_dependency 'os', '~> 1.0.0'
|
43
44
|
spec.add_runtime_dependency 'streamio-ffmpeg', '~> 3.0'
|
44
45
|
end
|
data/support/install_jruby.ps1
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
$downloadLink = "https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.
|
2
|
-
$zipPath = "c:\jruby-dist-9.2.
|
1
|
+
$downloadLink = "https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.9.0/jruby-dist-9.2.9.0-bin.zip"
|
2
|
+
$zipPath = "c:\jruby-dist-9.2.9.0-bin.zip"
|
3
3
|
|
4
4
|
Write-Host "Installing $($env:RUBY_VERSION)" -ForegroundColor cyan
|
5
5
|
appveyor DownloadFile "$($downloadLink)" -FileName "$($zipPath)"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: screen-recorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lakshya Kapoor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -140,16 +140,22 @@ dependencies:
|
|
140
140
|
name: childprocess
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '1.0'
|
146
|
+
- - "<"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '4.0'
|
146
149
|
type: :runtime
|
147
150
|
prerelease: false
|
148
151
|
version_requirements: !ruby/object:Gem::Requirement
|
149
152
|
requirements:
|
150
|
-
- - "
|
153
|
+
- - ">="
|
151
154
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
155
|
+
version: '1.0'
|
156
|
+
- - "<"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '4.0'
|
153
159
|
- !ruby/object:Gem::Dependency
|
154
160
|
name: os
|
155
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,7 +225,8 @@ licenses:
|
|
219
225
|
- MIT
|
220
226
|
metadata:
|
221
227
|
changelog_uri: https://github.com/kapoorlakshya/screen-recorder/blob/master/CHANGELOG.md
|
222
|
-
source_code_uri: https://github.com/kapoorlakshya/screen-recorder/
|
228
|
+
source_code_uri: https://github.com/kapoorlakshya/screen-recorder/tree/v1.4.0
|
229
|
+
documentation_uri: https://www.rubydoc.info/gems/screen-recorder/1.4.0
|
223
230
|
bug_tracker_uri: https://github.com/kapoorlakshya/screen-recorder/issues
|
224
231
|
wiki_uri: https://github.com/kapoorlakshya/screen-recorder/wiki
|
225
232
|
post_install_message:
|
@@ -237,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
244
|
- !ruby/object:Gem::Version
|
238
245
|
version: '0'
|
239
246
|
requirements: []
|
240
|
-
rubygems_version: 3.
|
247
|
+
rubygems_version: 3.1.2
|
241
248
|
signing_key:
|
242
249
|
specification_version: 4
|
243
250
|
summary: Video record your computer screen using FFmpeg.
|