ffmpeg-screenrecorder 1.0.0.beta7 → 1.0.0.beta8
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/.rubocop.yml +3 -0
- data/.travis.yml +23 -7
- data/CHANGES.md +24 -0
- data/README.md +55 -18
- data/bin/console +1 -1
- data/lib/ffmpeg-screenrecorder.rb +3 -0
- data/lib/ffmpeg/recorder_options.rb +10 -10
- data/lib/ffmpeg/recording_regions.rb +12 -12
- data/lib/ffmpeg/screenrecorder.rb +3 -5
- data/lib/ffmpeg/version.rb +1 -1
- metadata +4 -3
- data/lib/ffmpeg.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b93c3e8b673ad688449c8af7a13f3b936f6f9c0665d9b265e0a4ffd5d5820018
|
4
|
+
data.tar.gz: 9fc25d97554efee3a142bbadaf4699220221dacec0e7e6158484593be13f206d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa97bae768e73ad1175005d9e13a51874d443e692c539b3cd329fd6a412f84bb5c00e9bb07c2683b198a79ef7d8876c57be0d71b3e8ee30ebb9141fbd2d42e19
|
7
|
+
data.tar.gz: 9fa3025ffae72d29381d0342f88fa938e6800374e967d4e741f47df201ec820e5e289ba57a1277eba61b332720c95a8fba8e4a79ce7350c20c6ec80b265b3d94
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,7 +1,23 @@
|
|
1
|
-
---
|
2
|
-
sudo:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
sudo: required
|
3
|
+
os:
|
4
|
+
- linux
|
5
|
+
language: ruby
|
6
|
+
cache: bundler
|
7
|
+
branches:
|
8
|
+
only:
|
9
|
+
- master
|
10
|
+
rvm:
|
11
|
+
- 2.5.3
|
12
|
+
addons:
|
13
|
+
firefox: latest
|
14
|
+
before_install:
|
15
|
+
- gem update --system
|
16
|
+
- gem install bundler
|
17
|
+
- bundle update
|
18
|
+
before_script:
|
19
|
+
- sudo add-apt-repository -y ppa:mc3man/trusty-media
|
20
|
+
- sudo apt-get update
|
21
|
+
- sudo apt-get install -y ffmpeg
|
22
|
+
- ffmpeg -hwaccels
|
23
|
+
- echo $DISPLAY
|
data/CHANGES.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
### 1.0.0.beta8 (2019-01-03)
|
2
|
+
|
3
|
+
* Fix a bug where the gem was incorrectly configured to be required as `ffmpeg/screenrecorder` instead of `ffmpeg-screenrecorder`.
|
4
|
+
* `ScreenRecorder#start` now returns the IO process object in case the user has a use case for it.
|
5
|
+
* `RecordingRegion#fetch` now logs a warning that `x11grab` for Linux does not supporting window recording.
|
6
|
+
* :warning: Parameter `infile` is now `input` to make it more intuitive.
|
7
|
+
g
|
8
|
+
### 1.0.0.beta7 (2018-12-23)
|
9
|
+
|
10
|
+
* Fix bug in RecorderOptions where an incorrect object was referenced to read the user provided options.
|
11
|
+
|
12
|
+
### 1.0.0.beta6 (2018-12-3)
|
13
|
+
|
14
|
+
* Stopping the screenrecorder now prints the failure reason given by the ffmpeg binary when `#stop` fails (Issue #7).
|
15
|
+
* Log file is now defaulted to `ffmpeg.log` instead of redirecting to nul.
|
16
|
+
* `log_level` now defaults to `Logger::ERROR` instead of `Logger::INFO`.
|
17
|
+
|
18
|
+
### 1.0.0.beta5 (2018-11-26)
|
19
|
+
|
20
|
+
* `Screenrecorder` class is now `ScreenRecorder`.
|
21
|
+
* Add support for Linux.
|
22
|
+
* Now an exception raised if the gem fails to find `ffmpeg`.
|
23
|
+
* Fix a bug where a file named `nul` was created instead of directing the output to `NUL`.
|
24
|
+
* Fix a bug where `RecordingRegions#window_titles` was not returning anything because of missing return keyword.
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/ffmpeg-screenrecorder)
|
4
4
|

|
5
|
+
[](https://www.rubydoc.info/github/kapoorlakshya/ffmpeg-screenrecorder/master)
|
5
6
|
|
6
7
|
Ruby gem to record your computer screen - desktop or specific application/window - using [FFmpeg](https://www.ffmpeg.org/).
|
7
8
|
|
@@ -11,9 +12,13 @@ Supports Windows and Linux as of version `1.0.0-beta5`. macOS support will be ad
|
|
11
12
|
|
12
13
|
## Installation
|
13
14
|
|
14
|
-
[
|
15
|
+
On Microsoft Windows, [download](https://www.ffmpeg.org/download.html#build-windows), extract and add the location of `/bin` to your ENV `PATH` variable.
|
15
16
|
|
16
|
-
|
17
|
+
For Linux, follow instructions here - https://ffmpeg.org/download.html#build-linux
|
18
|
+
|
19
|
+
Once installed, make sure ffmpeg is found:
|
20
|
+
|
21
|
+
$ ffmpeg -version
|
17
22
|
ffmpeg version N-92132-g0a41a8bf29 Copyright (c) 2000-2018 the FFmpeg developers
|
18
23
|
built with gcc 8.2.1 (GCC) 20180813
|
19
24
|
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-g
|
@@ -34,7 +39,7 @@ Supports Windows and Linux as of version `1.0.0-beta5`. macOS support will be ad
|
|
34
39
|
libswresample 3. 2.100 / 3. 2.100
|
35
40
|
libpostproc 55. 2.100 / 55. 2.100
|
36
41
|
|
37
|
-
|
42
|
+
Next, add this line to your application's Gemfile:
|
38
43
|
|
39
44
|
```ruby
|
40
45
|
gem 'ffmpeg-screenrecorder'
|
@@ -50,29 +55,52 @@ Or install it yourself as:
|
|
50
55
|
|
51
56
|
## Usage
|
52
57
|
|
58
|
+
#### Required Options
|
59
|
+
|
60
|
+
- `:input` - `desktop` or application window name
|
61
|
+
- `:output` - Output file location/name
|
62
|
+
- `:framerate` - Capture FPS
|
63
|
+
|
64
|
+
#### Advanced Options
|
65
|
+
|
66
|
+
- `:log` - Defaults to `ffmpeg.log`
|
67
|
+
- `:log_level` for this gem
|
68
|
+
|
69
|
+
All other FFmpeg options can be passed through the `advanced` key. This feature is yet to be fully tested, so please feel free to report any bugs or request a feature.
|
70
|
+
|
71
|
+
<b>Example</b>:
|
72
|
+
|
73
|
+
```
|
74
|
+
opts = { input: 'desktop',
|
75
|
+
output: 'recorder-test.mp4',
|
76
|
+
framerate: 30,
|
77
|
+
log: 'recorder.log',
|
78
|
+
log_level: Logger::DEBUG, # For gem
|
79
|
+
advanced: { loglevel: 'level+debug' } # For FFmpeg
|
80
|
+
}
|
81
|
+
```
|
82
|
+
|
53
83
|
##### Record Desktop
|
54
84
|
|
55
85
|
```
|
56
|
-
opts = {
|
57
|
-
|
86
|
+
opts = { input: 'desktop',
|
87
|
+
output: 'screenrecorder-desktop.mp4',
|
58
88
|
framerate: 30.0 }
|
59
89
|
@recorder = FFMPEG::ScreenRecorder.new(opts)
|
60
90
|
|
61
91
|
# Start recording
|
62
|
-
@recorder.start
|
92
|
+
@recorder.start #=> #<IO:fd 5>
|
63
93
|
|
64
94
|
# ... Run tests or whatever you want to record
|
65
95
|
|
66
96
|
# Stop recording
|
67
|
-
@recorder.stop
|
97
|
+
@recorder.stop #=> #<FFMPEG::Movie...>
|
68
98
|
|
69
99
|
# Recorded file
|
70
|
-
@recorder.video #=>
|
71
|
-
|
72
|
-
# ffmpeg log will be stored in 'ffmpeg.log'
|
100
|
+
@recorder.video #=> #<FFMPEG::Movie...>
|
73
101
|
```
|
74
102
|
|
75
|
-
##### Record
|
103
|
+
##### Record Application Window - Microsoft Windows (`gdigrab`) Only
|
76
104
|
```
|
77
105
|
require 'watir'
|
78
106
|
|
@@ -81,10 +109,10 @@ browser = Watir::Browser.new :firefox
|
|
81
109
|
FFMPEG::RecordingRegions.fetch('firefox') # Name of exe
|
82
110
|
#=> ["Mozilla Firefox"]
|
83
111
|
|
84
|
-
opts = {
|
85
|
-
|
112
|
+
opts = { input: FFMPEG::RecordingRegions.fetch('firefox').first,
|
113
|
+
output: 'screenrecorder-firefox.mp4',
|
86
114
|
framerate: 30.0,
|
87
|
-
log: '
|
115
|
+
log: 'screenrecorder-firefox.log' }
|
88
116
|
@recorder = FFMPEG::ScreenRecorder.new(opts)
|
89
117
|
|
90
118
|
# Start recording
|
@@ -101,19 +129,28 @@ browser.quit
|
|
101
129
|
```
|
102
130
|
|
103
131
|
<b>Note</b>:
|
104
|
-
|
105
|
-
|
132
|
+
- Always stop the recording before closing the application. Otherwise, ffmpeg will force exit as soon as the window disappears and may produce an invalid video file.
|
133
|
+
- If you're launching multiple applications or testing an application at different window sizes, recording the `desktop` is a better option.
|
106
134
|
|
107
135
|
## Development
|
108
136
|
|
109
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
137
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
110
138
|
|
111
139
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
112
140
|
|
113
141
|
## Contributing
|
114
142
|
|
115
|
-
Bug reports and pull requests are welcome.
|
143
|
+
Bug reports and pull requests are welcome.
|
144
|
+
|
145
|
+
- Please update the specs for your code changes and run them locally with `bundle exec rake spec`.
|
146
|
+
- Follow the Ruby style guide and format your code - https://github.com/rubocop-hq/ruby-style-guide
|
116
147
|
|
117
148
|
## License
|
118
149
|
|
119
150
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
151
|
+
|
152
|
+
## Credits
|
153
|
+
|
154
|
+

|
155
|
+
|
156
|
+
Thanks to [SauceLabs](https://saucelabs.com) for providing me with a free account. If you manage an open source project, you can get your free account [here](https://saucelabs.com/open-source).
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
|
-
require 'ffmpeg
|
4
|
+
require 'ffmpeg-screenrecorder'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -22,10 +22,10 @@ module FFMPEG
|
|
22
22
|
end
|
23
23
|
|
24
24
|
#
|
25
|
-
# Returns given input file or
|
25
|
+
# Returns given input file or input
|
26
26
|
#
|
27
|
-
def
|
28
|
-
@options[:
|
27
|
+
def input
|
28
|
+
@options[:input]
|
29
29
|
end
|
30
30
|
|
31
31
|
#
|
@@ -71,7 +71,7 @@ module FFMPEG
|
|
71
71
|
vals = "-f #{determine_format} "
|
72
72
|
vals << "-r #{@options[:framerate]} "
|
73
73
|
vals << advanced_options if @options[:advanced]
|
74
|
-
vals << "-i #{
|
74
|
+
vals << "-i #{determine_input} "
|
75
75
|
vals << @options[:output]
|
76
76
|
vals << ffmpeg_log_to(@options[:log]) # If provided
|
77
77
|
end
|
@@ -97,7 +97,7 @@ module FFMPEG
|
|
97
97
|
# -r framerate
|
98
98
|
# -i input
|
99
99
|
# output
|
100
|
-
return %i[framerate
|
100
|
+
return %i[framerate input output] unless OS.linux?
|
101
101
|
|
102
102
|
%i[framerate output] # Linux
|
103
103
|
end
|
@@ -126,18 +126,18 @@ module FFMPEG
|
|
126
126
|
end
|
127
127
|
|
128
128
|
#
|
129
|
-
# Returns final
|
130
|
-
# Adds title= qualifier to
|
129
|
+
# Returns final input parameter.
|
130
|
+
# Adds title= qualifier to input parameter
|
131
131
|
# unless the user is recording the desktop.
|
132
132
|
#
|
133
|
-
def
|
133
|
+
def determine_input
|
134
134
|
# x11grab doesn't support window capture
|
135
135
|
return ':0.0' if OS.linux?
|
136
136
|
|
137
|
-
return @options[:
|
137
|
+
return @options[:input] if @options[:input] == 'desktop'
|
138
138
|
|
139
139
|
# Windows only
|
140
|
-
%("title=#{@options[:
|
140
|
+
%("title=#{@options[:input]}")
|
141
141
|
end
|
142
142
|
|
143
143
|
#
|
@@ -14,11 +14,10 @@ module FFMPEG
|
|
14
14
|
#
|
15
15
|
# Returns a cleaned up list of available window titles
|
16
16
|
# for the given application (process) name.
|
17
|
-
# Note: Only supports Windows OS as of version beta2.
|
18
17
|
#
|
19
18
|
def available_windows_for(application)
|
20
|
-
return
|
21
|
-
return
|
19
|
+
return windows_os_window(application) if OS.windows?
|
20
|
+
return linux_os_window(application) if OS.linux?
|
22
21
|
|
23
22
|
raise NotImplementedError, 'Your OS is not supported.'
|
24
23
|
end
|
@@ -26,12 +25,12 @@ module FFMPEG
|
|
26
25
|
private
|
27
26
|
|
28
27
|
#
|
29
|
-
# Returns list of windows
|
28
|
+
# Returns list of windows when using Microsoft Windows
|
30
29
|
#
|
31
|
-
def
|
30
|
+
def windows_os_window(application)
|
32
31
|
raw_list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
|
33
|
-
|
34
|
-
|
32
|
+
.split("\n")
|
33
|
+
.reject { |title| title == 'Window Title: N/A' }
|
35
34
|
final_list = raw_list.map { |i| i.gsub('Window Title: ', '') } # Match ffmpeg expected format
|
36
35
|
raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}.exe" if final_list.empty?
|
37
36
|
|
@@ -39,15 +38,16 @@ module FFMPEG
|
|
39
38
|
end
|
40
39
|
|
41
40
|
#
|
42
|
-
# Returns list of windows
|
41
|
+
# Returns list of windows when using Linux
|
43
42
|
#
|
44
|
-
def
|
43
|
+
def linux_os_window(application)
|
44
|
+
FFMPEG.logger.warn 'Note: Default capture device x11grab on Linux does not support window recording.'
|
45
45
|
raise DependencyNotFound, 'wmctrl is not installed. Run: sudo apt-get install wmctrl.' unless wmctrl_installed?
|
46
46
|
|
47
47
|
final_list = `wmctrl -l | awk '{$3=""; $2=""; $1=""; print $0}'` # Returns all open windows
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
.split("\n")
|
49
|
+
.map(&:strip)
|
50
|
+
.select { |t| t.match?(/#{application}/i) } # Narrow down to given application
|
51
51
|
raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}" if final_list.empty?
|
52
52
|
|
53
53
|
final_list
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'streamio-ffmpeg'
|
2
|
-
require 'os'
|
3
1
|
require_relative 'recorder_errors'
|
4
2
|
require_relative 'recorder_options'
|
5
3
|
require_relative 'recording_regions'
|
@@ -26,6 +24,7 @@ module FFMPEG
|
|
26
24
|
elapsed = Time.now - start_time
|
27
25
|
FFMPEG.logger.debug "Process started in #{elapsed}s"
|
28
26
|
FFMPEG.logger.info 'Recording...'
|
27
|
+
@process
|
29
28
|
end
|
30
29
|
|
31
30
|
#
|
@@ -62,10 +61,9 @@ module FFMPEG
|
|
62
61
|
elapsed = wait_for_io_eof(5)
|
63
62
|
@process.close_write # Close IO
|
64
63
|
elapsed
|
65
|
-
|
66
64
|
rescue Errno::EPIPE
|
67
65
|
# Gets last line from log file
|
68
|
-
err_line = get_lines_from_log(
|
66
|
+
err_line = get_lines_from_log(:last, 2)
|
69
67
|
raise FFMPEG::Error, err_line
|
70
68
|
end
|
71
69
|
|
@@ -117,7 +115,7 @@ module FFMPEG
|
|
117
115
|
#
|
118
116
|
# Returns lines from the log file
|
119
117
|
#
|
120
|
-
def get_lines_from_log(
|
118
|
+
def get_lines_from_log(position = :last, count = 2)
|
121
119
|
f = File.open(options.log)
|
122
120
|
lines = f.readlines
|
123
121
|
lines = lines.last(count) if position == :last
|
data/lib/ffmpeg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffmpeg-screenrecorder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta8
|
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: 2019-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- ".rspec"
|
135
135
|
- ".rubocop.yml"
|
136
136
|
- ".travis.yml"
|
137
|
+
- CHANGES.md
|
137
138
|
- Gemfile
|
138
139
|
- LICENSE.txt
|
139
140
|
- README.md
|
@@ -141,7 +142,7 @@ files:
|
|
141
142
|
- bin/console
|
142
143
|
- bin/setup
|
143
144
|
- ffmpeg-screenrecorder.gemspec
|
144
|
-
- lib/ffmpeg.rb
|
145
|
+
- lib/ffmpeg-screenrecorder.rb
|
145
146
|
- lib/ffmpeg/recorder_errors.rb
|
146
147
|
- lib/ffmpeg/recorder_options.rb
|
147
148
|
- lib/ffmpeg/recording_regions.rb
|
data/lib/ffmpeg.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'ffmpeg/screenrecorder'
|