screen-recorder 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c04070110a0bb4d14c22683e2e226f68a2245ec8d0ae5ebf098e8a028fc22050
4
- data.tar.gz: eac8f6a6036d62a7634fd61b77a0a864ea589aa3b4d2d5e1693f6a813692d4cd
3
+ metadata.gz: 45346a64b3fbf881ad0e84d86b60071870c88ceb4903c887b8986523cd9cbc54
4
+ data.tar.gz: 9534f82f4a2f777beedd390f4bc684947f5a1439eb0c7cd197d4a5fca53a87ac
5
5
  SHA512:
6
- metadata.gz: 1cd22bbff801124ed2e3c42d94aa50cf8f568b473dcdff045e150bf25e543d0ff81d7d8a99da78ef2e6d8fffb5e57bc8d00a291dec4b72c7abe8f37453bf5e2e
7
- data.tar.gz: ca1af2f484ca9e360dcf94096f7066013e9fe645471c36173d417c589c1cbe12d533bc1269ae44f27fe17a61252a2e1ede833ce9dfc45bcf9daaaeb038866f18
6
+ metadata.gz: b41efb69403ff6739d94f43a663366fb50532bf5289b62fcdea478539299d7e1031f492ae0bda43db8a5e228b42205c585e9e9e29b85609e0eebda283b0c151b
7
+ data.tar.gz: 00f30237b8c76aa88ee19333c2c84cb43e9170bc0df3caa6b89a0591b78852ef4483709dbe00869c4672ef754ef8fa67f626ad42593a797eef4e653848217317
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This project adheres to [Semantic Versioning](https://semver.org/).
4
4
 
5
+ ### 1.6.0 (2021-08-22)
6
+ * Match "childprocess" gem version to `selenium-webdriver`. Closes [#99](https://github.com/kapoorlakshya/screen-recorder/issues/99).
7
+ * Add support for screenshot resolution. Closes [#98](https://github.com/kapoorlakshya/screen-recorder/issues/98).
8
+
5
9
  ### 1.5.0 (2021-03-23)
6
10
  * Relax "os" gem version to minor level ([#97](https://github.com/kapoorlakshya/screen-recorder/pull/97)). Thanks, [hlascelles](https://github.com/hlascelles)!
7
11
 
data/README.md CHANGED
@@ -166,6 +166,13 @@ window_title = ScreenRecorder::('chrome').first
166
166
  @recorder.screenshot('after-recording.png')
167
167
  browser.quit
168
168
  ```
169
+
170
+ You can even specify a custom capture resolution:
171
+
172
+ ```rb
173
+ @recorder.screenshot('screenshot.png', '1024x768')
174
+ ```
175
+
169
176
  #### Video Output
170
177
 
171
178
  Once the recorder is stopped, you can view the video metadata or transcode
@@ -78,5 +78,6 @@ require 'screen-recorder/errors'
78
78
  require 'screen-recorder/options'
79
79
  require 'screen-recorder/titles'
80
80
  require 'screen-recorder/common'
81
+ require 'screen-recorder/screenshot'
81
82
  require 'screen-recorder/desktop'
82
83
  require 'screen-recorder/window'
@@ -40,20 +40,6 @@ module ScreenRecorder
40
40
  @video = prepare_video unless exit_code == 1
41
41
  end
42
42
 
43
- #
44
- # Takes a screenshot in the current context (input) - desktop or current window
45
- #
46
- def screenshot(filename)
47
- process = execute_command(screenshot_cmd(filename))
48
- exit_code = wait_for_process_exit(process) # 0 (success) or 1 (fail)
49
- if exit_code&.zero?
50
- ScreenRecorder.logger.info "Screenshot: #{filename}"
51
- return filename
52
- end
53
- ScreenRecorder.logger.error 'Failed to take a screenshot.'
54
- nil
55
- end
56
-
57
43
  #
58
44
  # Discards the recorded file. Useful in automated testing
59
45
  # when a test passes and the recorded file is no longer
@@ -124,14 +110,6 @@ module ScreenRecorder
124
110
  "#{ffmpeg_bin} #{@options.parsed}"
125
111
  end
126
112
 
127
- #
128
- # Parameters to capture a single frame
129
- #
130
- def screenshot_cmd(filename)
131
- # -f overwrites existing file
132
- "#{ffmpeg_bin} -f #{options.capture_device} -i #{options.input} -framerate 1 -frames:v 1 #{filename}"
133
- end
134
-
135
113
  #
136
114
  # Returns true if ffmpeg binary is found.
137
115
  #
@@ -2,6 +2,8 @@
2
2
  module ScreenRecorder
3
3
  # @since 1.0.0-beta11
4
4
  class Desktop < Common
5
+ include Screenshot
6
+
5
7
  DEFAULT_INPUT_WIN = 'desktop'.freeze
6
8
  DEFAULT_INPUT_LINUX = ':0'.freeze
7
9
  DEFAULT_INPUT_MAC = '1'.freeze
@@ -0,0 +1,39 @@
1
+ module ScreenRecorder
2
+ # All screenshot related code
3
+ module Screenshot
4
+ #
5
+ # Takes a screenshot in the current context (input) - desktop or current window
6
+ #
7
+ def screenshot(filename, resolution = nil)
8
+ ScreenRecorder.logger.debug "Screenshot filename: #{filename}, resolution: #{resolution}"
9
+ cmd = screenshot_cmd(filename: filename, resolution: resolution)
10
+ process = execute_command(cmd)
11
+ exit_code = wait_for_process_exit(process) # 0 (success) or 1 (fail)
12
+ if exit_code&.zero?
13
+ ScreenRecorder.logger.info "Screenshot: #{filename}"
14
+ return filename
15
+ end
16
+ ScreenRecorder.logger.error 'Failed to take a screenshot.'
17
+ nil
18
+ end
19
+
20
+ #
21
+ # Parameters to capture a single frame
22
+ #
23
+ def screenshot_cmd(filename:, resolution: nil)
24
+ resolution = resolution ? resolution_arg(resolution) : nil
25
+ # -f overwrites existing file
26
+ "#{ffmpeg_bin} -f #{options.capture_device} -i #{options.input} -framerate 1 -frames:v 1 #{resolution}#{filename}"
27
+ end
28
+
29
+ private
30
+
31
+ #
32
+ # Returns OS specific video resolution arg for ffmpeg
33
+ #
34
+ def resolution_arg(size)
35
+ # macOS likes -s, windows and linux like -video_size
36
+ OS.mac? ? "-s #{size} " : "-video_size #{size} "
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module ScreenRecorder
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '1.6.0'.freeze
3
3
  end
@@ -2,6 +2,8 @@
2
2
  module ScreenRecorder
3
3
  # @since 1.0.0-beta11
4
4
  class Window < Common
5
+ include Screenshot
6
+
5
7
  #
6
8
  # Window recording mode.
7
9
  #
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency 'watir', '~> 6.0'
39
39
  spec.add_development_dependency 'webdrivers', '~> 4.0'
40
40
 
41
- spec.add_runtime_dependency 'childprocess', '>= 1.0', '< 4.0' # Roughly match Selenium
41
+ spec.add_runtime_dependency 'childprocess', '>= 1.0', '< 5.0' # Roughly match Selenium
42
42
  spec.add_runtime_dependency 'os', '~> 1.0'
43
43
  spec.add_runtime_dependency 'streamio-ffmpeg', '~> 3.0'
44
44
  end
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.5.0
4
+ version: 1.6.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: 2021-03-24 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -145,7 +145,7 @@ dependencies:
145
145
  version: '1.0'
146
146
  - - "<"
147
147
  - !ruby/object:Gem::Version
148
- version: '4.0'
148
+ version: '5.0'
149
149
  type: :runtime
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
@@ -155,7 +155,7 @@ dependencies:
155
155
  version: '1.0'
156
156
  - - "<"
157
157
  - !ruby/object:Gem::Version
158
- version: '4.0'
158
+ version: '5.0'
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: os
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -209,6 +209,7 @@ files:
209
209
  - lib/screen-recorder/desktop.rb
210
210
  - lib/screen-recorder/errors.rb
211
211
  - lib/screen-recorder/options.rb
212
+ - lib/screen-recorder/screenshot.rb
212
213
  - lib/screen-recorder/titles.rb
213
214
  - lib/screen-recorder/type_checker.rb
214
215
  - lib/screen-recorder/version.rb
@@ -219,8 +220,8 @@ licenses:
219
220
  - MIT
220
221
  metadata:
221
222
  changelog_uri: https://github.com/kapoorlakshya/screen-recorder/blob/master/CHANGELOG.md
222
- source_code_uri: https://github.com/kapoorlakshya/screen-recorder/tree/v1.5.0
223
- documentation_uri: https://www.rubydoc.info/gems/screen-recorder/1.5.0
223
+ source_code_uri: https://github.com/kapoorlakshya/screen-recorder/tree/v1.6.0
224
+ documentation_uri: https://www.rubydoc.info/gems/screen-recorder/1.6.0
224
225
  bug_tracker_uri: https://github.com/kapoorlakshya/screen-recorder/issues
225
226
  wiki_uri: https://github.com/kapoorlakshya/screen-recorder/wiki
226
227
  post_install_message: