ffmpeg-screenrecorder 1.0.0.beta6 → 1.0.0.beta7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c62a747ed63c6178eace85bc00839f1d1812f13eb2c024df6341fa7c9550ac5
4
- data.tar.gz: 340337ba29b6f447a77c9c721645aa5cc572c38082db63433e0e73fc70872919
3
+ metadata.gz: a472f64b6ba70b1f6b74ca6023f97ceba33c8d9977e8c6df2263513b60520af8
4
+ data.tar.gz: 33355f5984cca8c017ed1ec5dbfa065478bf3c512a7a40927a660bed4687c2f2
5
5
  SHA512:
6
- metadata.gz: f09d8655ffa42956ec4bfabafa38d742986f9f73781885d190e2b8598156dfe2f7dd70748059a0a6685f6f0b27b87e03af7bc4716c2f614616abb7b86209f261
7
- data.tar.gz: 4a8db4f7460bc9dbcae758730bb79a5355ea3ecafe4ffb6f8902d090e8dc4e0e9f4f617a0b3fb2e2571e7ec9ce1d5ffc1ce23da1e1804ea1baa931f887b31abb
6
+ metadata.gz: 32b9efa443e4ee7c7e25c8fd61fe173c207efa31c00cb41c3cbff8177014149a166a11d4560790a09337d5763870ebf8c8555f9362e4fe85b2b7dd7cc9c1b80e
7
+ data.tar.gz: 92d7c4b4f3c5db9fe021a0938353abb5979ba9bf4aff6f1607d16fb8b23f08145b01cf01ff94ce302f3809e8623f8bc45efc7f6a5c3a54fee1fea12c838c73bc
data/.gitignore CHANGED
@@ -1,104 +1,104 @@
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
- Gemfile.lock
21
-
22
- # rspec failure tracking
23
- .rspec_status
24
-
25
- # User-specific stuff
26
- .idea/
27
- .idea/**/workspace.xml
28
- .idea/**/tasks.xml
29
- .idea/**/usage.statistics.xml
30
- .idea/**/dictionaries
31
- .idea/**/shelf
32
-
33
- # Generated files
34
- .idea/**/contentModel.xml
35
-
36
- # Sensitive or high-churn files
37
- .idea/**/dataSources/
38
- .idea/**/dataSources.ids
39
- .idea/**/dataSources.local.xml
40
- .idea/**/sqlDataSources.xml
41
- .idea/**/dynamic.xml
42
- .idea/**/uiDesigner.xml
43
- .idea/**/dbnavigator.xml
44
-
45
- # Gradle
46
- .idea/**/gradle.xml
47
- .idea/**/libraries
48
-
49
- # Gradle and Maven with auto-import
50
- # When using Gradle or Maven with auto-import, you should exclude module files,
51
- # since they will be recreated, and may cause churn. Uncomment if using
52
- # auto-import.
53
- # .idea/modules.xml
54
- # .idea/*.iml
55
- # .idea/modules
56
-
57
- # CMake
58
- cmake-build-*/
59
-
60
- # Mongo Explorer plugin
61
- .idea/**/mongoSettings.xml
62
-
63
- # File-based project format
64
- *.iws
65
-
66
- # IntelliJ
67
- out/
68
-
69
- # mpeltonen/sbt-idea plugin
70
- .idea_modules/
71
-
72
- # JIRA plugin
73
- atlassian-ide-plugin.xml
74
-
75
- # Cursive Clojure plugin
76
- .idea/replstate.xml
77
-
78
- # Crashlytics plugin (for Android Studio and IntelliJ)
79
- com_crashlytics_export_strings.xml
80
- crashlytics.properties
81
- crashlytics-build.properties
82
- fabric.properties
83
-
84
- # Editor-based Rest Client
85
- .idea/httpRequests
86
-
87
- # Android studio 3.1+ serialized cache file
88
- .idea/caches/build_file_checksums.ser
89
-
90
- ### RubyMine+all Patch ###
91
- # Ignores the whole .idea folder and all .iml files
92
- # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
93
-
94
- .idea/
95
-
96
- # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
97
-
98
- *.iml
99
- modules.xml
100
- .idea/misc.xml
101
- *.ipr
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
+
20
+ Gemfile.lock
21
+
22
+ # rspec failure tracking
23
+ .rspec_status
24
+
25
+ # User-specific stuff
26
+ .idea/
27
+ .idea/**/workspace.xml
28
+ .idea/**/tasks.xml
29
+ .idea/**/usage.statistics.xml
30
+ .idea/**/dictionaries
31
+ .idea/**/shelf
32
+
33
+ # Generated files
34
+ .idea/**/contentModel.xml
35
+
36
+ # Sensitive or high-churn files
37
+ .idea/**/dataSources/
38
+ .idea/**/dataSources.ids
39
+ .idea/**/dataSources.local.xml
40
+ .idea/**/sqlDataSources.xml
41
+ .idea/**/dynamic.xml
42
+ .idea/**/uiDesigner.xml
43
+ .idea/**/dbnavigator.xml
44
+
45
+ # Gradle
46
+ .idea/**/gradle.xml
47
+ .idea/**/libraries
48
+
49
+ # Gradle and Maven with auto-import
50
+ # When using Gradle or Maven with auto-import, you should exclude module files,
51
+ # since they will be recreated, and may cause churn. Uncomment if using
52
+ # auto-import.
53
+ # .idea/modules.xml
54
+ # .idea/*.iml
55
+ # .idea/modules
56
+
57
+ # CMake
58
+ cmake-build-*/
59
+
60
+ # Mongo Explorer plugin
61
+ .idea/**/mongoSettings.xml
62
+
63
+ # File-based project format
64
+ *.iws
65
+
66
+ # IntelliJ
67
+ out/
68
+
69
+ # mpeltonen/sbt-idea plugin
70
+ .idea_modules/
71
+
72
+ # JIRA plugin
73
+ atlassian-ide-plugin.xml
74
+
75
+ # Cursive Clojure plugin
76
+ .idea/replstate.xml
77
+
78
+ # Crashlytics plugin (for Android Studio and IntelliJ)
79
+ com_crashlytics_export_strings.xml
80
+ crashlytics.properties
81
+ crashlytics-build.properties
82
+ fabric.properties
83
+
84
+ # Editor-based Rest Client
85
+ .idea/httpRequests
86
+
87
+ # Android studio 3.1+ serialized cache file
88
+ .idea/caches/build_file_checksums.ser
89
+
90
+ ### RubyMine+all Patch ###
91
+ # Ignores the whole .idea folder and all .iml files
92
+ # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
93
+
94
+ .idea/
95
+
96
+ # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
97
+
98
+ *.iml
99
+ modules.xml
100
+ .idea/misc.xml
101
+ *.ipr
102
+
103
+
104
104
  # End of https://www.gitignore.io/api/rubymine+all
data/README.md CHANGED
@@ -1,118 +1,119 @@
1
- # FFMPEG::ScreenRecorder
2
-
3
- [![Gem Version](https://badge.fury.io/rb/ffmpeg-screenrecorder.svg)](https://badge.fury.io/rb/ffmpeg-screenrecorder)
4
-
5
- Ruby gem to record your computer screen - desktop or specific application/window - using [FFmpeg](https://www.ffmpeg.org/).
6
-
7
- ## Compatibility
8
-
9
- Supports Windows and Linux as of version `1.0.0-beta5`. macOS support will be added before the final release of `v1.0.0`.
10
-
11
- ## Installation
12
-
13
- [Download](https://www.ffmpeg.org/download.html), extract and add the location of `ffmpeg.exe` to your ENV `PATH` variable. Make sure you can execute ffmpeg:
14
-
15
- C:\Users\Lakshya Kapoor>ffmpeg -version
16
- ffmpeg version N-92132-g0a41a8bf29 Copyright (c) 2000-2018 the FFmpeg developers
17
- built with gcc 8.2.1 (GCC) 20180813
18
- configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-g
19
- nutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libm
20
- p3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable
21
- -libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable
22
- -libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable
23
- -libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab
24
- le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libsp
25
- eex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --ena
26
- ble-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
27
- libavutil 56. 19.101 / 56. 19.101
28
- libavcodec 58. 32.100 / 58. 32.100
29
- libavformat 58. 18.104 / 58. 18.104
30
- libavdevice 58. 4.105 / 58. 4.105
31
- libavfilter 7. 33.100 / 7. 33.100
32
- libswscale 5. 2.100 / 5. 2.100
33
- libswresample 3. 2.100 / 3. 2.100
34
- libpostproc 55. 2.100 / 55. 2.100
35
-
36
- Add this line to your application's Gemfile:
37
-
38
- ```ruby
39
- gem 'ffmpeg-screenrecorder'
40
- ```
41
-
42
- And then execute:
43
-
44
- $ bundle
45
-
46
- Or install it yourself as:
47
-
48
- $ gem install ffmpeg-screenrecorder
49
-
50
- ## Usage
51
-
52
- ##### Record Desktop
53
-
54
- ```
55
- opts = { output: 'ffmpeg-screenrecorder-desktop.mp4',
56
- input: 'desktop',
57
- framerate: 30.0 }
58
- @recorder = FFMPEG::ScreenRecorder.new(opts)
59
-
60
- # Start recording
61
- @recorder.start
62
-
63
- # ... Run tests or whatever you want to record
64
-
65
- # Stop recording
66
- @recorder.stop
67
-
68
- # Recorded file
69
- @recorder.video #=> 'ffmpeg-screenrecorder-desktop.mp4'
70
-
71
- # ffmpeg log will be stored in 'ffmpeg.log'
72
- ```
73
-
74
- ##### Record Specific Application/Window - gdigrab (Windows) Only
75
- ```
76
- require 'watir'
77
-
78
- browser = Watir::Browser.new :firefox
79
-
80
- FFMPEG::RecordingRegions.fetch('firefox') # Name of exe
81
- #=> "Mozilla Firefox"
82
-
83
- opts = { output: 'ffmpeg-screenrecorder-firefox.mp4',
84
- input: 'Mozilla Firefox',
85
- framerate: 30.0,
86
- log: 'ffmpeg-screenrecorder-firefox.txt' }
87
- @recorder = FFMPEG::ScreenRecorder.new(opts)
88
-
89
- # Start recording
90
- @recorder.start
91
-
92
- # Run tests or whatever you want to record
93
- browser.goto 'watir.com'
94
- browser.link(text: 'News').wait_until_present.click
95
-
96
- # Stop recording
97
- @recorder.stop
98
-
99
- browser.quit
100
- ```
101
-
102
- <b>Note</b>:
103
- 1. 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.
104
- 2. If you're launching multiple applications or testing an application at different window sizes, recording the `desktop` is a better option.
105
-
106
- ## Development
107
-
108
- 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.
109
-
110
- To install this gem onto your local machine, run `bundle exec rake install`.
111
-
112
- ## Contributing
113
-
114
- Bug reports and pull requests are welcome. Please follow the Ruby style guide here: https://github.com/rubocop-hq/ruby-style-guide
115
-
116
- ## License
117
-
118
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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
+
6
+ Ruby gem to record your computer screen - desktop or specific application/window - using [FFmpeg](https://www.ffmpeg.org/).
7
+
8
+ ## Compatibility
9
+
10
+ Supports Windows and Linux as of version `1.0.0-beta5`. macOS support will be added before the final release of `v1.0.0`.
11
+
12
+ ## Installation
13
+
14
+ [Download](https://www.ffmpeg.org/download.html), extract and add the location of `ffmpeg.exe` to your ENV `PATH` variable. Make sure you can execute ffmpeg:
15
+
16
+ C:\Users\Lakshya Kapoor>ffmpeg -version
17
+ ffmpeg version N-92132-g0a41a8bf29 Copyright (c) 2000-2018 the FFmpeg developers
18
+ built with gcc 8.2.1 (GCC) 20180813
19
+ configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-g
20
+ nutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libm
21
+ p3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable
22
+ -libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable
23
+ -libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable
24
+ -libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab
25
+ le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libsp
26
+ eex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --ena
27
+ ble-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
28
+ libavutil 56. 19.101 / 56. 19.101
29
+ libavcodec 58. 32.100 / 58. 32.100
30
+ libavformat 58. 18.104 / 58. 18.104
31
+ libavdevice 58. 4.105 / 58. 4.105
32
+ libavfilter 7. 33.100 / 7. 33.100
33
+ libswscale 5. 2.100 / 5. 2.100
34
+ libswresample 3. 2.100 / 3. 2.100
35
+ libpostproc 55. 2.100 / 55. 2.100
36
+
37
+ Add this line to your application's Gemfile:
38
+
39
+ ```ruby
40
+ gem 'ffmpeg-screenrecorder'
41
+ ```
42
+
43
+ And then execute:
44
+
45
+ $ bundle
46
+
47
+ Or install it yourself as:
48
+
49
+ $ gem install ffmpeg-screenrecorder
50
+
51
+ ## Usage
52
+
53
+ ##### Record Desktop
54
+
55
+ ```
56
+ opts = { output: 'ffmpeg-screenrecorder-desktop.mp4',
57
+ input: 'desktop',
58
+ framerate: 30.0 }
59
+ @recorder = FFMPEG::ScreenRecorder.new(opts)
60
+
61
+ # Start recording
62
+ @recorder.start
63
+
64
+ # ... Run tests or whatever you want to record
65
+
66
+ # Stop recording
67
+ @recorder.stop
68
+
69
+ # Recorded file
70
+ @recorder.video #=> 'ffmpeg-screenrecorder-desktop.mp4'
71
+
72
+ # ffmpeg log will be stored in 'ffmpeg.log'
73
+ ```
74
+
75
+ ##### Record Specific Application/Window - Windows Only
76
+ ```
77
+ require 'watir'
78
+
79
+ browser = Watir::Browser.new :firefox
80
+
81
+ FFMPEG::RecordingRegions.fetch('firefox') # Name of exe
82
+ #=> ["Mozilla Firefox"]
83
+
84
+ opts = { output: 'ffmpeg-screenrecorder-firefox.mp4',
85
+ input: FFMPEG::RecordingRegions.fetch('firefox').first,
86
+ framerate: 30.0,
87
+ log: 'ffmpeg-screenrecorder-firefox.txt' }
88
+ @recorder = FFMPEG::ScreenRecorder.new(opts)
89
+
90
+ # Start recording
91
+ @recorder.start
92
+
93
+ # Run tests or whatever you want to record
94
+ browser.goto 'watir.com'
95
+ browser.link(text: 'News').wait_until_present.click
96
+
97
+ # Stop recording
98
+ @recorder.stop
99
+
100
+ browser.quit
101
+ ```
102
+
103
+ <b>Note</b>:
104
+ 1. 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.
105
+ 2. If you're launching multiple applications or testing an application at different window sizes, recording the `desktop` is a better option.
106
+
107
+ ## Development
108
+
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.
110
+
111
+ To install this gem onto your local machine, run `bundle exec rake install`.
112
+
113
+ ## Contributing
114
+
115
+ Bug reports and pull requests are welcome. Please follow the Ruby style guide here: https://github.com/rubocop-hq/ruby-style-guide
116
+
117
+ ## License
118
+
119
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -3,15 +3,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'ffmpeg/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'ffmpeg-screenrecorder'
7
- spec.version = FFMPEG::ScreenRecorder::VERSION
8
- spec.authors = ['Lakshya Kapoor']
9
- spec.email = ['kapoorlakshya@gmail.com']
10
-
11
- spec.summary = 'Record your computer screen using ffmpeg via Ruby.'
12
- spec.description = 'Ruby gem to record your computer screen - desktop or specific application/window' \
13
- ' - using FFmpeg (https://www.ffmpeg.org).'
6
+ spec.name = 'ffmpeg-screenrecorder'
7
+ spec.version = FFMPEG::ScreenRecorder::VERSION
8
+ spec.authors = ['Lakshya Kapoor']
9
+ spec.email = ['kapoorlakshya@gmail.com']
14
10
  spec.homepage = 'http://github.com/kapoorlakshya/ffmpeg-screenrecorder'
11
+ spec.summary = 'Record your computer screen using ffmpeg via Ruby.'
12
+ spec.description = 'Record your computer screen - desktop or specific application/window - using FFmpeg (https://www.ffmpeg.org).'
15
13
  spec.license = 'MIT'
16
14
 
17
15
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -1,7 +1,7 @@
1
1
  module FFMPEG
2
2
  # @since 1.0.0-beta2
3
3
  class RecorderOptions
4
- DEFAULT_LOG_FILE = 'ffmpeg.log'
4
+ DEFAULT_LOG_FILE = 'ffmpeg.log'.freeze
5
5
 
6
6
  def initialize(options)
7
7
  @options = verify_options options
@@ -107,10 +107,10 @@ module FFMPEG
107
107
  #
108
108
  def advanced_options
109
109
  return nil unless @options[:advanced]
110
- raise(ArgumentError, ':advanced cannot be empty.') if options[:advanced].empty?
110
+ raise(ArgumentError, ':advanced cannot be empty.') if @options[:advanced].empty?
111
111
 
112
112
  arr = []
113
- options[:advanced].each do |k, v|
113
+ @options[:advanced].each do |k, v|
114
114
  arr.push "-#{k} #{v}"
115
115
  end
116
116
  arr.join(' ') + ' '
@@ -1,64 +1,64 @@
1
- module FFMPEG
2
- # @since 1.0.0-beta4
3
- module RecordingRegions
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
- # Note: Only supports Windows OS as of version beta2.
18
- #
19
- def available_windows_for(application)
20
- return windows_os(application) if OS.windows?
21
- return linux_os(application) if OS.linux?
22
-
23
- raise NotImplementedError, 'Your OS is not supported.'
24
- end
25
-
26
- private
27
-
28
- #
29
- # Returns list of windows for Microsoft Windows
30
- #
31
- def windows_os(application)
32
- raw_list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
33
- .split("\n")
34
- .reject { |title| title == 'Window Title: N/A' }
35
- final_list = raw_list.map { |i| i.gsub('Window Title: ', '') } # Match ffmpeg expected format
36
- raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}.exe" if final_list.empty?
37
-
38
- final_list
39
- end
40
-
41
- #
42
- # Returns list of windows for Linux
43
- #
44
- def linux_os(application)
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 RecordingRegions
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
+ # Note: Only supports Windows OS as of version beta2.
18
+ #
19
+ def available_windows_for(application)
20
+ return windows_os(application) if OS.windows?
21
+ return linux_os(application) if OS.linux?
22
+
23
+ raise NotImplementedError, 'Your OS is not supported.'
24
+ end
25
+
26
+ private
27
+
28
+ #
29
+ # Returns list of windows for Microsoft Windows
30
+ #
31
+ def windows_os(application)
32
+ raw_list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
33
+ .split("\n")
34
+ .reject { |title| title == 'Window Title: N/A' }
35
+ final_list = raw_list.map { |i| i.gsub('Window Title: ', '') } # Match ffmpeg expected format
36
+ raise RecorderErrors::ApplicationNotFound, "No open windows found for: #{application}.exe" if final_list.empty?
37
+
38
+ final_list
39
+ end
40
+
41
+ #
42
+ # Returns list of windows for Linux
43
+ #
44
+ def linux_os(application)
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,5 +1,5 @@
1
1
  module FFMPEG
2
2
  class ScreenRecorder
3
- VERSION = '1.0.0.beta6'.freeze
3
+ VERSION = '1.0.0.beta7'.freeze
4
4
  end
5
5
  end
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.beta6
4
+ version: 1.0.0.beta7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lakshya Kapoor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-04 00:00:00.000000000 Z
11
+ date: 2018-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.0'
125
- description: Ruby gem to record your computer screen - desktop or specific application/window
125
+ description: Record your computer screen - desktop or specific application/window
126
126
  - using FFmpeg (https://www.ffmpeg.org).
127
127
  email:
128
128
  - kapoorlakshya@gmail.com