ffmpeg-screenrecorder 1.0.0.beta8 → 1.0.0.beta9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +107 -103
- data/.travis.yml +24 -23
- data/CHANGES.md +30 -23
- data/README.md +167 -156
- data/ffmpeg-screenrecorder.gemspec +0 -1
- data/lib/ffmpeg/recorder_options.rb +8 -2
- data/lib/ffmpeg/screenrecorder.rb +19 -2
- data/lib/ffmpeg/version.rb +1 -1
- data/lib/ffmpeg/{recording_regions.rb → window_titles.rb} +63 -63
- data/lib/ffmpeg-screenrecorder.rb +2 -2
- metadata +4 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12cfdba9f1cb9d3296d231d3cc1c6262ff6f2350a1bd79db2d66db3e12d06e09
|
4
|
+
data.tar.gz: a8be75c4fe64a40eff487fdc9345f612f185f21c1df7f81f31944a07913af72c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 116ffbcc5f2532a017f5d5fe02d2d44759301ad8955d91e6711fe186941a33064f82fecb03c92f10a12436e6159b0015c8449ddfd2fa439d5aa51b510bc673e2
|
7
|
+
data.tar.gz: 57867328f8e57dac849f63ba0be69f45fa365a8e6036c38e0c422b3dc3fd43f74b4a07321267cd7452d3ee460ba66d72f35d60764686fbf47240a7d28366fec9
|
data/.gitignore
CHANGED
@@ -1,104 +1,108 @@
|
|
1
|
-
Gemfile.lock # Part of best practice
|
2
|
-
|
3
|
-
# Created by https://www.gitignore.io/api/rubymine+all
|
4
|
-
|
5
|
-
### RubyMine+all ###
|
6
|
-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
7
|
-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
8
|
-
|
9
|
-
/.bundle/
|
10
|
-
/.yardoc
|
11
|
-
/_yardoc/
|
12
|
-
/coverage/
|
13
|
-
/doc/
|
14
|
-
/pkg/
|
15
|
-
/spec/reports/
|
16
|
-
/tmp/
|
17
|
-
/webdrivers_bin
|
18
|
-
*.log
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
.
|
28
|
-
|
29
|
-
|
30
|
-
.idea
|
31
|
-
.idea/**/
|
32
|
-
|
33
|
-
|
34
|
-
.idea/**/
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
.idea/**/
|
39
|
-
|
40
|
-
|
41
|
-
.idea/**/
|
42
|
-
.idea/**/
|
43
|
-
.idea/**/
|
44
|
-
|
45
|
-
|
46
|
-
.idea/**/
|
47
|
-
.idea/**/
|
48
|
-
|
49
|
-
# Gradle
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
#
|
54
|
-
#
|
55
|
-
# .
|
56
|
-
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
1
|
+
Gemfile.lock # Part of best practice
|
2
|
+
|
3
|
+
# Created by https://www.gitignore.io/api/rubymine+all
|
4
|
+
|
5
|
+
### RubyMine+all ###
|
6
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
7
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
8
|
+
|
9
|
+
/.bundle/
|
10
|
+
/.yardoc
|
11
|
+
/_yardoc/
|
12
|
+
/coverage/
|
13
|
+
/doc/
|
14
|
+
/pkg/
|
15
|
+
/spec/reports/
|
16
|
+
/tmp/
|
17
|
+
/webdrivers_bin
|
18
|
+
*.log
|
19
|
+
*.mkv
|
20
|
+
*.mp4
|
21
|
+
*.avi
|
22
|
+
*.gif
|
23
|
+
|
24
|
+
Gemfile.lock
|
25
|
+
|
26
|
+
# rspec failure tracking
|
27
|
+
.rspec_status
|
28
|
+
|
29
|
+
# User-specific stuff
|
30
|
+
.idea/
|
31
|
+
.idea/**/workspace.xml
|
32
|
+
.idea/**/tasks.xml
|
33
|
+
.idea/**/usage.statistics.xml
|
34
|
+
.idea/**/dictionaries
|
35
|
+
.idea/**/shelf
|
36
|
+
|
37
|
+
# Generated files
|
38
|
+
.idea/**/contentModel.xml
|
39
|
+
|
40
|
+
# Sensitive or high-churn files
|
41
|
+
.idea/**/dataSources/
|
42
|
+
.idea/**/dataSources.ids
|
43
|
+
.idea/**/dataSources.local.xml
|
44
|
+
.idea/**/sqlDataSources.xml
|
45
|
+
.idea/**/dynamic.xml
|
46
|
+
.idea/**/uiDesigner.xml
|
47
|
+
.idea/**/dbnavigator.xml
|
48
|
+
|
49
|
+
# Gradle
|
50
|
+
.idea/**/gradle.xml
|
51
|
+
.idea/**/libraries
|
52
|
+
|
53
|
+
# Gradle and Maven with auto-import
|
54
|
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
55
|
+
# since they will be recreated, and may cause churn. Uncomment if using
|
56
|
+
# auto-import.
|
57
|
+
# .idea/modules.xml
|
58
|
+
# .idea/*.iml
|
59
|
+
# .idea/modules
|
60
|
+
|
61
|
+
# CMake
|
62
|
+
cmake-build-*/
|
63
|
+
|
64
|
+
# Mongo Explorer plugin
|
65
|
+
.idea/**/mongoSettings.xml
|
66
|
+
|
67
|
+
# File-based project format
|
68
|
+
*.iws
|
69
|
+
|
70
|
+
# IntelliJ
|
71
|
+
out/
|
72
|
+
|
73
|
+
# mpeltonen/sbt-idea plugin
|
74
|
+
.idea_modules/
|
75
|
+
|
76
|
+
# JIRA plugin
|
77
|
+
atlassian-ide-plugin.xml
|
78
|
+
|
79
|
+
# Cursive Clojure plugin
|
80
|
+
.idea/replstate.xml
|
81
|
+
|
82
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
83
|
+
com_crashlytics_export_strings.xml
|
84
|
+
crashlytics.properties
|
85
|
+
crashlytics-build.properties
|
86
|
+
fabric.properties
|
87
|
+
|
88
|
+
# Editor-based Rest Client
|
89
|
+
.idea/httpRequests
|
90
|
+
|
91
|
+
# Android studio 3.1+ serialized cache file
|
92
|
+
.idea/caches/build_file_checksums.ser
|
93
|
+
|
94
|
+
### RubyMine+all Patch ###
|
95
|
+
# Ignores the whole .idea folder and all .iml files
|
96
|
+
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
|
97
|
+
|
98
|
+
.idea/
|
99
|
+
|
100
|
+
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
101
|
+
|
102
|
+
*.iml
|
103
|
+
modules.xml
|
104
|
+
.idea/misc.xml
|
105
|
+
*.ipr
|
106
|
+
|
107
|
+
|
104
108
|
# End of https://www.gitignore.io/api/rubymine+all
|
data/.travis.yml
CHANGED
@@ -1,23 +1,24 @@
|
|
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
|
-
-
|
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
|
+
- sudo apt-get install wmctrl
|
24
|
+
script: xvfb-run --server-args="-screen 0 1024x768x24" rake spec
|
data/CHANGES.md
CHANGED
@@ -1,24 +1,31 @@
|
|
1
|
-
### 1.0.0.
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
|
8
|
-
### 1.0.0.
|
9
|
-
|
10
|
-
* Fix bug
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
1
|
+
### 1.0.0.beta9 (2019-01-22)
|
2
|
+
|
3
|
+
* :warning: `FFMPEG::RecordingRegions` is now `FFMPEG::WindowTitles`, so the module name is true to the function it provides.
|
4
|
+
* Added support for for a user given path via `FFMPEG#ffmpeg_binary=()`.
|
5
|
+
* Removed Bundler version requirement from gemspec to support all versions.
|
6
|
+
* Implement `#discard` (alias `#delete`) to discard the video file. Useful when your test passes and you want to get rid of the video file.
|
7
|
+
|
8
|
+
### 1.0.0.beta8 (2019-01-03)
|
9
|
+
|
10
|
+
* Fix a bug where the gem was incorrectly configured to be required as `ffmpeg/screenrecorder` instead of `ffmpeg-screenrecorder`.
|
11
|
+
* `ScreenRecorder#start` now returns the IO process object in case the user has a use case for it.
|
12
|
+
* `RecordingRegion#fetch` now logs a warning that `x11grab` for Linux does not supporting window recording.
|
13
|
+
* :warning: Parameter `infile` is now `input` to make it more intuitive.
|
14
|
+
|
15
|
+
### 1.0.0.beta7 (2018-12-23)
|
16
|
+
|
17
|
+
* Fix bug in RecorderOptions where an incorrect object was referenced to read the user provided options.
|
18
|
+
|
19
|
+
### 1.0.0.beta6 (2018-12-3)
|
20
|
+
|
21
|
+
* Stopping the screenrecorder now prints the failure reason given by the ffmpeg binary when `#stop` fails (Issue #7).
|
22
|
+
* Log file is now defaulted to `ffmpeg.log` instead of redirecting to nul.
|
23
|
+
* `log_level` now defaults to `Logger::ERROR` instead of `Logger::INFO`.
|
24
|
+
|
25
|
+
### 1.0.0.beta5 (2018-11-26)
|
26
|
+
|
27
|
+
* `Screenrecorder` class is now `ScreenRecorder`.
|
28
|
+
* Add support for Linux.
|
29
|
+
* Now an exception raised if the gem fails to find `ffmpeg`.
|
30
|
+
* Fix a bug where a file named `nul` was created instead of directing the output to `NUL`.
|
24
31
|
* Fix a bug where `RecordingRegions#window_titles` was not returning anything because of missing return keyword.
|
data/README.md
CHANGED
@@ -1,156 +1,167 @@
|
|
1
|
-
# FFMPEG::ScreenRecorder
|
2
|
-
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/ffmpeg-screenrecorder.svg)](https://badge.fury.io/rb/ffmpeg-screenrecorder)
|
4
|
-
![https://rubygems.org/gems/ffmpeg-screenrecorder](https://ruby-gem-downloads-badge.herokuapp.com/ffmpeg-screenrecorder?type=total)
|
5
|
-
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/kapoorlakshya/ffmpeg-screenrecorder/master)
|
6
|
-
|
7
|
-
Ruby gem to record your computer screen - desktop or specific application/window - using [FFmpeg](https://www.ffmpeg.org/).
|
8
|
-
|
9
|
-
## Compatibility
|
10
|
-
|
11
|
-
Supports Windows and Linux as of version `1.0.0-beta5`. macOS support will be added before the final release of `v1.0.0`.
|
12
|
-
|
13
|
-
## Installation
|
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.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ffmpeg version
|
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
|
-
|
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
|
-
@recorder.
|
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
|
-
browser.
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
##
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
1
|
+
# FFMPEG::ScreenRecorder
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ffmpeg-screenrecorder.svg)](https://badge.fury.io/rb/ffmpeg-screenrecorder)
|
4
|
+
![https://rubygems.org/gems/ffmpeg-screenrecorder](https://ruby-gem-downloads-badge.herokuapp.com/ffmpeg-screenrecorder?type=total)
|
5
|
+
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/kapoorlakshya/ffmpeg-screenrecorder/master)
|
6
|
+
|
7
|
+
Ruby gem to record your computer screen - desktop or specific application/window - using [FFmpeg](https://www.ffmpeg.org/).
|
8
|
+
|
9
|
+
## Compatibility
|
10
|
+
|
11
|
+
Supports Windows and Linux as of version `1.0.0-beta5`. macOS support will be added before the final release of `v1.0.0`.
|
12
|
+
|
13
|
+
## Installation
|
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. If you want to use `libx264`, download
|
16
|
+
[this build](https://ffmpeg.zeranoe.com/builds/) instead.
|
17
|
+
|
18
|
+
For Linux, follow instructions here - https://ffmpeg.org/download.html#build-linux
|
19
|
+
|
20
|
+
Once installed, make sure ffmpeg is found:
|
21
|
+
|
22
|
+
$ ffmpeg -version
|
23
|
+
ffmpeg version N-92132-g0a41a8bf29 Copyright (c) 2000-2018 the FFmpeg developers
|
24
|
+
built with gcc 8.2.1 (GCC) 20180813
|
25
|
+
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-g
|
26
|
+
nutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libm
|
27
|
+
p3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable
|
28
|
+
-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable
|
29
|
+
-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable
|
30
|
+
-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab
|
31
|
+
le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libsp
|
32
|
+
eex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --ena
|
33
|
+
ble-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
|
34
|
+
libavutil 56. 19.101 / 56. 19.101
|
35
|
+
libavcodec 58. 32.100 / 58. 32.100
|
36
|
+
libavformat 58. 18.104 / 58. 18.104
|
37
|
+
libavdevice 58. 4.105 / 58. 4.105
|
38
|
+
libavfilter 7. 33.100 / 7. 33.100
|
39
|
+
libswscale 5. 2.100 / 5. 2.100
|
40
|
+
libswresample 3. 2.100 / 3. 2.100
|
41
|
+
libpostproc 55. 2.100 / 55. 2.100
|
42
|
+
|
43
|
+
Next, add this line to your application's Gemfile:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
gem 'ffmpeg-screenrecorder'
|
47
|
+
```
|
48
|
+
|
49
|
+
And then execute:
|
50
|
+
|
51
|
+
$ bundle
|
52
|
+
|
53
|
+
Or install it yourself as:
|
54
|
+
|
55
|
+
$ gem install ffmpeg-screenrecorder
|
56
|
+
|
57
|
+
Require it in your project and start using the gem:
|
58
|
+
|
59
|
+
require ffmpeg-screenrecorder
|
60
|
+
|
61
|
+
## Usage
|
62
|
+
|
63
|
+
#### Required Options
|
64
|
+
|
65
|
+
- `:input` - `'desktop'` or application window name
|
66
|
+
- `:output` - Output file location/name
|
67
|
+
- `:framerate` - Capture FPS
|
68
|
+
|
69
|
+
#### Advanced Options
|
70
|
+
|
71
|
+
- `:log` - Defaults to `ffmpeg.log`
|
72
|
+
- `:log_level` for this gem
|
73
|
+
|
74
|
+
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.
|
75
|
+
|
76
|
+
```
|
77
|
+
opts = { input: 'desktop',
|
78
|
+
output: 'recorder-test.mp4',
|
79
|
+
framerate: 15,
|
80
|
+
log: 'recorder.log',
|
81
|
+
log_level: Logger::DEBUG, # For gem
|
82
|
+
advanced: { loglevel: 'level+debug', # For FFmpeg
|
83
|
+
video_size: '640x480',
|
84
|
+
show_region: '1' }
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
##### Record Desktop
|
89
|
+
|
90
|
+
```
|
91
|
+
opts = { input: 'desktop',
|
92
|
+
output: 'screenrecorder-desktop.mp4',
|
93
|
+
framerate: 15.0 }
|
94
|
+
@recorder = FFMPEG::ScreenRecorder.new(opts)
|
95
|
+
|
96
|
+
# Start recording
|
97
|
+
@recorder.start #=> #<IO:fd 5>
|
98
|
+
|
99
|
+
# ... Run tests or whatever you want to record
|
100
|
+
|
101
|
+
# Stop recording
|
102
|
+
@recorder.stop #=> #<FFMPEG::Movie...>
|
103
|
+
|
104
|
+
# Recorded file
|
105
|
+
@recorder.video #=> #<FFMPEG::Movie...>
|
106
|
+
```
|
107
|
+
|
108
|
+
##### Record Application Window - Microsoft Windows (`gdigrab`) Only
|
109
|
+
```
|
110
|
+
require 'watir'
|
111
|
+
|
112
|
+
browser = Watir::Browser.new :firefox
|
113
|
+
|
114
|
+
FFMPEG::WindowTitles.fetch('firefox') # Name of exe
|
115
|
+
#=> ["Mozilla Firefox"]
|
116
|
+
|
117
|
+
opts = { input: FFMPEG::WindowTitles.fetch('firefox').first,
|
118
|
+
output: 'screenrecorder-firefox.mp4',
|
119
|
+
framerate: 15.0,
|
120
|
+
log: 'screenrecorder-firefox.log' }
|
121
|
+
@recorder = FFMPEG::ScreenRecorder.new(opts)
|
122
|
+
|
123
|
+
# Start recording
|
124
|
+
@recorder.start
|
125
|
+
|
126
|
+
# Run tests or whatever you want to record
|
127
|
+
browser.goto 'watir.com'
|
128
|
+
browser.link(text: 'News').wait_until_present.click
|
129
|
+
|
130
|
+
# Stop recording
|
131
|
+
@recorder.stop
|
132
|
+
|
133
|
+
browser.quit
|
134
|
+
```
|
135
|
+
|
136
|
+
<b>Note</b>:
|
137
|
+
- 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.
|
138
|
+
- If you're launching multiple applications or testing an application at different window sizes, recording the `desktop` is a better option.
|
139
|
+
|
140
|
+
## Demo
|
141
|
+
|
142
|
+
You can find example video recordings here - [https://kapoorlakshya.github.io/introducing-ffmpeg-screenrecorder](https://kapoorlakshya.github.io/introducing-ffmpeg-screenrecorder)
|
143
|
+
|
144
|
+
Cucumber + Watir based example - [kapoorlakshya/cucumber-watir-test-recorder-example](https://github.com/kapoorlakshya/cucumber-watir-test-recorder-example)
|
145
|
+
|
146
|
+
## Development
|
147
|
+
|
148
|
+
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.
|
149
|
+
|
150
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
151
|
+
|
152
|
+
## Contributing
|
153
|
+
|
154
|
+
Bug reports and pull requests are welcome.
|
155
|
+
|
156
|
+
- Please update the specs for your code changes and run them locally with `bundle exec rake spec`.
|
157
|
+
- Follow the Ruby style guide and format your code - https://github.com/rubocop-hq/ruby-style-guide
|
158
|
+
|
159
|
+
## License
|
160
|
+
|
161
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
162
|
+
|
163
|
+
## Credits
|
164
|
+
|
165
|
+
![SauceLabs Logo](https://saucelabs.com/content/images/logo.png)
|
166
|
+
|
167
|
+
Thanks to [SauceLabs](https://saucelabs.com) for providing me with a free account. If you manage an open source project, you can apply for a free account [here](https://saucelabs.com/open-source).
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.16'
|
22
21
|
spec.add_development_dependency 'pry-byebug', '~> 3.6'
|
23
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
23
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
@@ -4,6 +4,12 @@ module FFMPEG
|
|
4
4
|
DEFAULT_LOG_FILE = 'ffmpeg.log'.freeze
|
5
5
|
|
6
6
|
def initialize(options)
|
7
|
+
raise ArgumentError, "Expected Hash, given: #{options.class}" unless options.is_a? Hash
|
8
|
+
|
9
|
+
if options[:advanced]
|
10
|
+
raise ArgumentError, "Expected Hash, given: #{options.class}" unless options[:advanced].is_a? Hash
|
11
|
+
end
|
12
|
+
|
7
13
|
@options = verify_options options
|
8
14
|
end
|
9
15
|
|
@@ -64,7 +70,7 @@ module FFMPEG
|
|
64
70
|
end
|
65
71
|
|
66
72
|
#
|
67
|
-
# Returns a String with all options parsed
|
73
|
+
# Returns a String with all options parsed and
|
68
74
|
# ready for the ffmpeg process to use
|
69
75
|
#
|
70
76
|
def parsed
|
@@ -132,7 +138,7 @@ module FFMPEG
|
|
132
138
|
#
|
133
139
|
def determine_input
|
134
140
|
# x11grab doesn't support window capture
|
135
|
-
return ':
|
141
|
+
return ':99' if OS.linux?
|
136
142
|
|
137
143
|
return @options[:input] if @options[:input] == 'desktop'
|
138
144
|
|
@@ -1,6 +1,7 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require_relative 'recorder_errors'
|
2
3
|
require_relative 'recorder_options'
|
3
|
-
require_relative '
|
4
|
+
require_relative 'window_titles'
|
4
5
|
|
5
6
|
module FFMPEG
|
6
7
|
# @since 1.0.0-beta
|
@@ -38,6 +39,17 @@ module FFMPEG
|
|
38
39
|
@video = Movie.new(options.output)
|
39
40
|
end
|
40
41
|
|
42
|
+
#
|
43
|
+
# Discards the recorded file. Useful in automated testing
|
44
|
+
# when a test passes and the recorded file is no longer
|
45
|
+
# needed.
|
46
|
+
#
|
47
|
+
def discard
|
48
|
+
FileUtils.rm options.output
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_method :delete, :discard
|
52
|
+
|
41
53
|
private
|
42
54
|
|
43
55
|
#
|
@@ -109,6 +121,11 @@ module FFMPEG
|
|
109
121
|
|
110
122
|
return !`where ffmpeg`.empty? if OS.windows?
|
111
123
|
|
124
|
+
# If the user does not use FFMPEG#ffmpeg_binary=() to set the binary path,
|
125
|
+
# FFMPEG#ffmpeg_binary returns 'ffmpeg' assuming it must be in ENV. However,
|
126
|
+
# if the above two checks fail, it is not in the ENV either.
|
127
|
+
return false if FFMPEG.ffmpeg_binary == 'ffmpeg'
|
128
|
+
|
112
129
|
true
|
113
130
|
end
|
114
131
|
|
@@ -116,7 +133,7 @@ module FFMPEG
|
|
116
133
|
# Returns lines from the log file
|
117
134
|
#
|
118
135
|
def get_lines_from_log(position = :last, count = 2)
|
119
|
-
f
|
136
|
+
f = File.open(options.log)
|
120
137
|
lines = f.readlines
|
121
138
|
lines = lines.last(count) if position == :last
|
122
139
|
lines = lines.first(count) if position == :first
|
data/lib/ffmpeg/version.rb
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
module FFMPEG
|
2
|
-
# @since 1.0.0-beta4
|
3
|
-
module
|
4
|
-
#
|
5
|
-
# Returns a list of available window titles for the given application (process) name.
|
6
|
-
#
|
7
|
-
def self.fetch(application)
|
8
|
-
FFMPEG.logger.debug "Retrieving available windows for: #{application}"
|
9
|
-
WindowGrabber.new.available_windows_for application
|
10
|
-
end
|
11
|
-
|
12
|
-
# @since 1.0.0-beta4
|
13
|
-
class WindowGrabber
|
14
|
-
#
|
15
|
-
# Returns a cleaned up list of available window titles
|
16
|
-
# for the given application (process) name.
|
17
|
-
#
|
18
|
-
def available_windows_for(application)
|
19
|
-
return windows_os_window(application) if OS.windows?
|
20
|
-
return linux_os_window(application) if OS.linux?
|
21
|
-
|
22
|
-
raise NotImplementedError, 'Your OS is not supported.'
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
#
|
28
|
-
# Returns list of windows when using Microsoft Windows
|
29
|
-
#
|
30
|
-
def windows_os_window(application)
|
31
|
-
raw_list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
|
32
|
-
.split("\n")
|
33
|
-
.
|
34
|
-
final_list = raw_list.map { |i| i.gsub('Window Title: ', '') } # Match ffmpeg expected format
|
35
|
-
raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}.exe" if final_list.empty?
|
36
|
-
|
37
|
-
final_list
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Returns list of windows when using Linux
|
42
|
-
#
|
43
|
-
def linux_os_window(application)
|
44
|
-
FFMPEG.logger.warn 'Note: Default capture device x11grab on Linux does not support window recording.'
|
45
|
-
raise DependencyNotFound, 'wmctrl is not installed. Run: sudo apt-get install wmctrl.' unless wmctrl_installed?
|
46
|
-
|
47
|
-
final_list = `wmctrl -l | awk '{$3=""; $2=""; $1=""; print $0}'` # Returns all open windows
|
48
|
-
.split("\n")
|
49
|
-
.map(&:strip)
|
50
|
-
.select { |t| t.match?(/#{application}/i) } # Narrow down to given application
|
51
|
-
raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}" if final_list.empty?
|
52
|
-
|
53
|
-
final_list
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# Returns true if wmctrl is installed
|
58
|
-
#
|
59
|
-
def wmctrl_installed?
|
60
|
-
!`which wmctrl`.empty? # "" when not found
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end # module Windows
|
1
|
+
module FFMPEG
|
2
|
+
# @since 1.0.0-beta4
|
3
|
+
module WindowTitles
|
4
|
+
#
|
5
|
+
# Returns a list of available window titles for the given application (process) name.
|
6
|
+
#
|
7
|
+
def self.fetch(application)
|
8
|
+
FFMPEG.logger.debug "Retrieving available windows for: #{application}"
|
9
|
+
WindowGrabber.new.available_windows_for application
|
10
|
+
end
|
11
|
+
|
12
|
+
# @since 1.0.0-beta4
|
13
|
+
class WindowGrabber
|
14
|
+
#
|
15
|
+
# Returns a cleaned up list of available window titles
|
16
|
+
# for the given application (process) name.
|
17
|
+
#
|
18
|
+
def available_windows_for(application)
|
19
|
+
return windows_os_window(application) if OS.windows?
|
20
|
+
return linux_os_window(application) if OS.linux?
|
21
|
+
|
22
|
+
raise NotImplementedError, 'Your OS is not supported.'
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
#
|
28
|
+
# Returns list of windows when using Microsoft Windows
|
29
|
+
#
|
30
|
+
def windows_os_window(application)
|
31
|
+
raw_list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
|
32
|
+
.split("\n")
|
33
|
+
.select { |t| t.match?(/#{application}/i) } # Narrow down to given application
|
34
|
+
final_list = raw_list.map { |i| i.gsub('Window Title: ', '') } # Match ffmpeg expected format
|
35
|
+
raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}.exe" if final_list.empty?
|
36
|
+
|
37
|
+
final_list
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Returns list of windows when using Linux
|
42
|
+
#
|
43
|
+
def linux_os_window(application)
|
44
|
+
FFMPEG.logger.warn 'Note: Default capture device x11grab on Linux does not support window recording.'
|
45
|
+
raise DependencyNotFound, 'wmctrl is not installed. Run: sudo apt-get install wmctrl.' unless wmctrl_installed?
|
46
|
+
|
47
|
+
final_list = `wmctrl -l | awk '{$3=""; $2=""; $1=""; print $0}'` # Returns all open windows
|
48
|
+
.split("\n")
|
49
|
+
.map(&:strip)
|
50
|
+
.select { |t| t.match?(/#{application}/i) } # Narrow down to given application
|
51
|
+
raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}" if final_list.empty?
|
52
|
+
|
53
|
+
final_list
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Returns true if wmctrl is installed
|
58
|
+
#
|
59
|
+
def wmctrl_installed?
|
60
|
+
!`which wmctrl`.empty? # "" when not found
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end # module Windows
|
64
64
|
end # module FFMPEG
|
@@ -1,3 +1,3 @@
|
|
1
|
-
require 'streamio-ffmpeg'
|
2
|
-
require 'os'
|
1
|
+
require 'streamio-ffmpeg'
|
2
|
+
require 'os'
|
3
3
|
require 'ffmpeg/screenrecorder'
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
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.beta9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lakshya Kapoor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.16'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.16'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: pry-byebug
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,9 +131,9 @@ files:
|
|
145
131
|
- lib/ffmpeg-screenrecorder.rb
|
146
132
|
- lib/ffmpeg/recorder_errors.rb
|
147
133
|
- lib/ffmpeg/recorder_options.rb
|
148
|
-
- lib/ffmpeg/recording_regions.rb
|
149
134
|
- lib/ffmpeg/screenrecorder.rb
|
150
135
|
- lib/ffmpeg/version.rb
|
136
|
+
- lib/ffmpeg/window_titles.rb
|
151
137
|
homepage: http://github.com/kapoorlakshya/ffmpeg-screenrecorder
|
152
138
|
licenses:
|
153
139
|
- MIT
|
@@ -167,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
153
|
- !ruby/object:Gem::Version
|
168
154
|
version: 1.3.1
|
169
155
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.7.6
|
156
|
+
rubygems_version: 3.0.2
|
172
157
|
signing_key:
|
173
158
|
specification_version: 4
|
174
159
|
summary: Record your computer screen using ffmpeg via Ruby.
|