ffmpeg-screenrecorder 1.0.0.beta2 → 1.0.0.beta3

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: e85788e1924b1350003ba607d5cec470878cb2ecc49a5cf53d5508c4604cb38d
4
- data.tar.gz: b438f32841d00eb3c6d3b6a996379f61a9c5e1c4a74335729bd6fc725bf23bae
3
+ metadata.gz: a9440c4355488a734176f7c2f1efed255cb4ccb48b5a92ef3ca266597af1ee95
4
+ data.tar.gz: ce51483334355bc4768c655b6bbc644eca9ea9ccc9bea6402a3855bd4032923f
5
5
  SHA512:
6
- metadata.gz: f36dafd064d1363b8dd5c42e39c2b840bc6a68db1cc7d42b8c65a667b78e45140c304a47581350a32913a79e6860f34d82778cb89510ec4c1f5925b35f22ee8f
7
- data.tar.gz: 98763086b2b600ee80cc319b0b5a86bd598aa5e561f309c929afc613ae002caccf535ebb0d00050ad1a75380fd2d87f3e44b106dd13304571b2d13b5499f6a88
6
+ metadata.gz: 1884a94f4f2725cbdc2e61d323c0b2fab850e5e5d44552f96f9066a0dc4b51076d13f1f4a3de442189187ddb3f5cd9d6ea44466fcff62b20a84e20a4aa66787c
7
+ data.tar.gz: 859acd8e9f125033e7971c9d021cde9960b04123ce9b63c4f40ecc6af45a33b3cb34d7711e4d9ddd1a27e4aa5a0bfc88d6776946bb5dcafb6d9082531f9173c0
data/README.md CHANGED
@@ -2,12 +2,35 @@
2
2
 
3
3
  Ruby gem to record your computer screen - desktop or specific application/window - using [FFMPEG](https://www.ffmpeg.org/).
4
4
 
5
- ## Support
5
+ ## Windows Only
6
6
 
7
- Only supports Windows OS as of version `1.0.0-beta2`.
7
+ Only supports Windows as of version `1.0.0-beta3`. Linux and macOS support will be added before the final release of `v1.0.0`.
8
8
 
9
9
  ## Installation
10
10
 
11
+ [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:
12
+
13
+ C:\Users\Lakshya Kapoor>ffmpeg -version
14
+ ffmpeg version N-92132-g0a41a8bf29 Copyright (c) 2000-2018 the FFmpeg developers
15
+ built with gcc 8.2.1 (GCC) 20180813
16
+ configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-g
17
+ nutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libm
18
+ p3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable
19
+ -libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable
20
+ -libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable
21
+ -libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab
22
+ le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libsp
23
+ eex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --ena
24
+ ble-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
25
+ libavutil 56. 19.101 / 56. 19.101
26
+ libavcodec 58. 32.100 / 58. 32.100
27
+ libavformat 58. 18.104 / 58. 18.104
28
+ libavdevice 58. 4.105 / 58. 4.105
29
+ libavfilter 7. 33.100 / 7. 33.100
30
+ libswscale 5. 2.100 / 5. 2.100
31
+ libswresample 3. 2.100 / 3. 2.100
32
+ libpostproc 55. 2.100 / 55. 2.100
33
+
11
34
  Add this line to your application's Gemfile:
12
35
 
13
36
  ```ruby
@@ -69,9 +92,13 @@ opts = { output: 'ffmpeg-screenrecorder-firefox.mp4',
69
92
  # Stop recording
70
93
  @recorder.stop
71
94
 
72
- # Recording file will be available: ffmpeg-screenrecorder-output.mp4
95
+ browser.quit
73
96
  ```
74
97
 
98
+ <b>Note</b>:
99
+ 1. Always stop the recording before closing the application. Otherwise, ffmpeg will not exit gracefully and may produce an invalid video file.
100
+ 2. If you're launching multiple applications or testing an application at different window sizes, recording the `desktop` is a better option.
101
+
75
102
  ## Development
76
103
 
77
104
  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.
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'ffmpeg-screenrecorder'
6
- spec.version = '1.0.0.beta2'
6
+ spec.version = '1.0.0.beta3'
7
7
  spec.authors = ['Lakshya Kapoor']
8
8
  spec.email = ['kapoorlakshya@gmail.com']
9
9
 
10
10
  spec.summary = 'Record your computer screen using ffmpeg via Ruby.'
11
11
  spec.description = 'Ruby gem to record your computer screen - desktop or specific application/window' \
12
- ' - using [FFMPEG](https://www.ffmpeg.org/).'
13
- spec.homepage = 'https://github.com/kapoorlakshya/ffmpeg-screenrecorder'
12
+ ' - using FFMPEG (https://www.ffmpeg.org).'
13
+ spec.homepage = 'http://github.com/kapoorlakshya/ffmpeg-screenrecorder'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -1,42 +1,71 @@
1
1
  module FFMPEG
2
+ # @since 1.0.0-beta2
2
3
  class RecorderOptions
3
4
 
4
5
  def initialize(options)
5
6
  @options = verify_options options
6
7
  end
7
8
 
9
+ #
10
+ # Returns given recording format
11
+ #
8
12
  def format
9
13
  @options[:format]
10
14
  end
11
15
 
16
+ #
17
+ # Returns given framerate
18
+ #
12
19
  def framerate
13
20
  @options[:framerate]
14
21
  end
15
22
 
23
+ #
24
+ # Returns given input file or infile
25
+ #
16
26
  def infile
17
27
  @options[:infile]
18
28
  end
19
29
 
30
+ #
31
+ # Returns given output filepath
32
+ #
20
33
  def output
21
34
  @options[:output]
22
35
  end
23
36
 
37
+ #
38
+ # Returns given values that are optional
39
+ #
24
40
  def advanced
25
41
  @options[:advanced]
26
42
  end
27
43
 
44
+ #
45
+ # Returns given log filename
46
+ #
28
47
  def log
29
48
  @options[:log]
30
49
  end
31
50
 
51
+ #
52
+ # Returns given log_level
53
+ #
32
54
  def log_level
33
55
  @options[:log_level]
34
56
  end
35
57
 
58
+ #
59
+ # Returns all given options
60
+ #
36
61
  def all
37
62
  @options
38
63
  end
39
64
 
65
+ #
66
+ # Returns a String with all options parsed as a String,
67
+ # ready for the ffmpeg process to use
68
+ #
40
69
  def parsed
41
70
  vals = "-f #{@options[:format]} "
42
71
  vals << "-r #{@options[:framerate]} "
@@ -49,7 +78,8 @@ module FFMPEG
49
78
  private
50
79
 
51
80
  #
52
- # Verifies the required options are provided
81
+ # Verifies the required options are provided and returns
82
+ # the given options Hash
53
83
  #
54
84
  def verify_options(options)
55
85
  missing_options = required_options.select { |req| options[req].nil? }
@@ -60,7 +90,7 @@ module FFMPEG
60
90
  end
61
91
 
62
92
  #
63
- # Returns Array of require options a Symbols
93
+ # Returns Array of required options sa Symbols
64
94
  #
65
95
  def required_options
66
96
  # -f format
@@ -85,8 +115,10 @@ module FFMPEG
85
115
  end
86
116
 
87
117
  #
88
- # Determines if the ffmpeg output will be to a log
89
- # file based on given options.
118
+ # Returns portion of the command which determines
119
+ # if the ffmpeg output will be logged to a file
120
+ # or completely ignored based on if the user
121
+ # provides a log filepath in the options.
90
122
  #
91
123
  def ffmpeg_log_to(file)
92
124
  return " 2> #{file}" if file
@@ -4,6 +4,7 @@ require_relative 'recorder_options'
4
4
  require_relative 'windows'
5
5
 
6
6
  module FFMPEG
7
+ # @since 1.0.0-beta1
7
8
  class Screenrecorder
8
9
  extend Windows
9
10
 
@@ -16,6 +17,9 @@ module FFMPEG
16
17
  initialize_logger(@options.log_level || Logger::ERROR)
17
18
  end
18
19
 
20
+ #
21
+ # Starts the recording
22
+ #
19
23
  def start
20
24
  @video = nil # New file
21
25
  start_time = Time.now
@@ -25,6 +29,9 @@ module FFMPEG
25
29
  FFMPEG.logger.info 'Recording...'
26
30
  end
27
31
 
32
+ #
33
+ # Stops the recording
34
+ #
28
35
  def stop
29
36
  FFMPEG.logger.debug 'Stopping ffmpeg.exe...'
30
37
  elapsed = kill_ffmpeg
@@ -35,6 +42,10 @@ module FFMPEG
35
42
 
36
43
  private
37
44
 
45
+ #
46
+ # Launches the ffmpeg binary using a generated command based on
47
+ # the given options.
48
+ #
38
49
  def start_ffmpeg
39
50
  FFMPEG.logger.debug "Command: #{command}"
40
51
  process = IO.popen(command, 'r+')
@@ -42,6 +53,9 @@ module FFMPEG
42
53
  process
43
54
  end
44
55
 
56
+ #
57
+ # Sends 'q' to the ffmpeg binary to gracefully stop the process.
58
+ #
45
59
  def kill_ffmpeg
46
60
  @process.puts 'q' # Gracefully exit ffmpeg
47
61
  elapsed = wait_for_io_eof(5)
@@ -49,6 +63,9 @@ module FFMPEG
49
63
  elapsed
50
64
  end
51
65
 
66
+ #
67
+ # Initializes the logger with the given log level.
68
+ #
52
69
  def initialize_logger(level)
53
70
  FFMPEG.logger.progname = 'FFMPEG'
54
71
  FFMPEG.logger.level = level
@@ -58,11 +75,19 @@ module FFMPEG
58
75
  FFMPEG.logger.debug 'Logger initialized.'
59
76
  end
60
77
 
78
+ #
79
+ # Generates the command line arguments based on the given
80
+ # options.
81
+ #
61
82
  def command
62
83
  cmd = "#{FFMPEG.ffmpeg_binary} -y "
63
84
  cmd << @options.parsed
64
85
  end
65
86
 
87
+ #
88
+ # Waits for IO#eof? to return true
89
+ # after 'q' is sent to the ffmpeg process.
90
+ #
66
91
  def wait_for_io_eof(timeout)
67
92
  start = Time.now
68
93
  Timeout.timeout(timeout) do
@@ -1,18 +1,34 @@
1
1
  module FFMPEG
2
+ # @since 1.0.0-beta2
2
3
  module Windows
3
4
 
5
+ #
6
+ # Returns a list of available window titles for the given application (process) name.
7
+ #
4
8
  def window_titles(application)
5
9
  FFMPEG.logger.debug "Retrieving available windows for: #{application}"
6
10
  WindowGrabber.new.available_windows_for application
7
11
  end
8
12
 
13
+ # @since 1.0.0-beta2
9
14
  class WindowGrabber
15
+ #
16
+ # Returns a cleaned up list of available window titles
17
+ # for the given application (process) name.
18
+ # Note: Only supports Windows OS as of version beta2.
19
+ #
10
20
  def available_windows_for(application)
11
- list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
12
- .split("\n")
13
- .reject { |title| title == 'Window Title: N/A' }
14
- list.map { |i| i.gsub('Window Title: ', '') } # Make it user friendly
21
+ raw_list = `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
22
+ .split("\n")
23
+ .reject { |title| title == 'Window Title: N/A' }
24
+ final_list = raw_list.map { |i| i.gsub('Window Title: ', '') } # Make it user friendly
25
+
26
+ raise ApplicationNotFound, "No open windows found for: #{application}.exe" if final_list.empty?
27
+ final_list
15
28
  end
16
29
  end
30
+
31
+ # @since 1.0.0-beta3
32
+ class ApplicationNotFound < StandardError; end
17
33
  end # module Windows
18
34
  end # module FFMPEG
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffmpeg-screenrecorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lakshya Kapoor
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.0'
125
125
  description: Ruby gem to record your computer screen - desktop or specific application/window
126
- - using [FFMPEG](https://www.ffmpeg.org/).
126
+ - using FFMPEG (https://www.ffmpeg.org).
127
127
  email:
128
128
  - kapoorlakshya@gmail.com
129
129
  executables: []
@@ -145,7 +145,7 @@ files:
145
145
  - lib/ffmpeg/recorder_options.rb
146
146
  - lib/ffmpeg/screenrecorder.rb
147
147
  - lib/ffmpeg/windows.rb
148
- homepage: https://github.com/kapoorlakshya/ffmpeg-screenrecorder
148
+ homepage: http://github.com/kapoorlakshya/ffmpeg-screenrecorder
149
149
  licenses:
150
150
  - MIT
151
151
  metadata: {}