ffmpeg-screenrecorder 1.0.0.beta

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a02c5c9cc4db8684c4a6f3f2f557b0857089c488ef26fc0f6986d7db32ff95cf
4
+ data.tar.gz: 03c1e725b98ed53f12d954ad084cf86ebfe41514319ebe14e58aec091029809a
5
+ SHA512:
6
+ metadata.gz: 9c3582ca908bb205de16bf887db6750574b5ade7ad3d83e57bb4aada8a092715a121a8681dbcbf3676cce70ec711545a2472d6e46234e6015232b6c0f1af5237
7
+ data.tar.gz: 2226a59c6416d4d54a60313e849f09fdff30f6efda276678256b3799b56667d91f126793794c6bf44b72c32005eb8122e058cee88056f42edae033d0ae537f5c
@@ -0,0 +1,102 @@
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
+
18
+ Gemfile.lock
19
+
20
+ # rspec failure tracking
21
+ .rspec_status
22
+
23
+ # User-specific stuff
24
+ .idea/
25
+ .idea/**/workspace.xml
26
+ .idea/**/tasks.xml
27
+ .idea/**/usage.statistics.xml
28
+ .idea/**/dictionaries
29
+ .idea/**/shelf
30
+
31
+ # Generated files
32
+ .idea/**/contentModel.xml
33
+
34
+ # Sensitive or high-churn files
35
+ .idea/**/dataSources/
36
+ .idea/**/dataSources.ids
37
+ .idea/**/dataSources.local.xml
38
+ .idea/**/sqlDataSources.xml
39
+ .idea/**/dynamic.xml
40
+ .idea/**/uiDesigner.xml
41
+ .idea/**/dbnavigator.xml
42
+
43
+ # Gradle
44
+ .idea/**/gradle.xml
45
+ .idea/**/libraries
46
+
47
+ # Gradle and Maven with auto-import
48
+ # When using Gradle or Maven with auto-import, you should exclude module files,
49
+ # since they will be recreated, and may cause churn. Uncomment if using
50
+ # auto-import.
51
+ # .idea/modules.xml
52
+ # .idea/*.iml
53
+ # .idea/modules
54
+
55
+ # CMake
56
+ cmake-build-*/
57
+
58
+ # Mongo Explorer plugin
59
+ .idea/**/mongoSettings.xml
60
+
61
+ # File-based project format
62
+ *.iws
63
+
64
+ # IntelliJ
65
+ out/
66
+
67
+ # mpeltonen/sbt-idea plugin
68
+ .idea_modules/
69
+
70
+ # JIRA plugin
71
+ atlassian-ide-plugin.xml
72
+
73
+ # Cursive Clojure plugin
74
+ .idea/replstate.xml
75
+
76
+ # Crashlytics plugin (for Android Studio and IntelliJ)
77
+ com_crashlytics_export_strings.xml
78
+ crashlytics.properties
79
+ crashlytics-build.properties
80
+ fabric.properties
81
+
82
+ # Editor-based Rest Client
83
+ .idea/httpRequests
84
+
85
+ # Android studio 3.1+ serialized cache file
86
+ .idea/caches/build_file_checksums.ser
87
+
88
+ ### RubyMine+all Patch ###
89
+ # Ignores the whole .idea folder and all .iml files
90
+ # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
91
+
92
+ .idea/
93
+
94
+ # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
95
+
96
+ *.iml
97
+ modules.xml
98
+ .idea/misc.xml
99
+ *.ipr
100
+
101
+
102
+ # End of https://www.gitignore.io/api/rubymine+all
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,44 @@
1
+ Style/EndOfLine:
2
+ EnforcedStyle: lf
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
6
+
7
+ # Cop supports --auto-correct.
8
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
9
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining
10
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
11
+ # FunctionalMethods: let, let!, subject, watch
12
+ # IgnoredMethods: lambda, proc, it
13
+ Style/BlockDelimiters:
14
+ EnforcedStyle: braces_for_chaining
15
+
16
+ Style/CommentedKeyword:
17
+ Enabled: false
18
+
19
+ Style/DoubleNegation:
20
+ Enabled: false
21
+
22
+ Metrics/MethodLength:
23
+ Max: 18
24
+
25
+ Metrics/PerceivedComplexity:
26
+ Max: 10
27
+
28
+ Metrics/CyclomaticComplexity:
29
+ Max: 8
30
+
31
+ Metrics/AbcSize:
32
+ Max: 20
33
+
34
+ Style/MethodCallWithoutArgsParentheses:
35
+ Enabled: false
36
+
37
+ Style/Documentation:
38
+ Enabled: false
39
+
40
+ # Cop supports --auto-correct.
41
+ # Configuration parameters: EnforcedStyle.
42
+ # SupportedStyles: when_needed, always, never
43
+ Style/FrozenStringLiteralComment:
44
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.16.6
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Lakshya Kapoor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # FFMPEG::Screenrecorder
2
+
3
+ Ruby gem to record your computer screen using [FFMPEG](https://www.ffmpeg.org/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ffmpeg-screenrecorder'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ffmpeg-screenrecorder
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kapoorlakshya/ffmpeg-screenrecorder.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ffmpeg/screenrecorder"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'ffmpeg-screenrecorder'
6
+ spec.version = '1.0.0.beta'
7
+ spec.authors = ['Lakshya Kapoor']
8
+ spec.email = ['kapoorlakshya@gmail.com']
9
+
10
+ spec.summary = 'Record your computer screen using ffmpeg via Ruby.'
11
+ spec.description = 'A ruby gem based on streamio-ffmpeg gem to record your computer screen in various formats.'
12
+ spec.homepage = 'https://github.com/kapoorlakshya/ruby-ffmpeg_screenrecorder'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
16
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ end
18
+
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.16'
22
+ spec.add_development_dependency 'pry-byebug', '~> 3.6'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
+ spec.add_development_dependency 'watir', '~> 6.0'
26
+ spec.add_development_dependency 'webdrivers', '~> 3.0'
27
+
28
+ spec.add_runtime_dependency 'os', '~> 0.9.0'
29
+ spec.add_runtime_dependency 'streamio-ffmpeg', '~> 1.0'
30
+ end
@@ -0,0 +1 @@
1
+ require 'ffmpeg/screenrecorder'
@@ -0,0 +1,111 @@
1
+ require 'streamio-ffmpeg'
2
+ require 'os'
3
+
4
+ module FFMPEG
5
+ class Screenrecorder
6
+ attr_reader :opts, :output, :process_id
7
+
8
+ def initialize(opts = {})
9
+ @opts = default_config.merge opts
10
+ @output = opts[:output]
11
+ @video_file = nil
12
+ @process_id = nil
13
+ init_logger(opts[:logging_level])
14
+ end
15
+
16
+ def opts=(new_opts)
17
+ @opts = default_config.merge new_opts
18
+ @output = opts[:output]
19
+ init_logger(opts[:logging_level]) if FFMPEG.logger.level != opts[:logging_level]
20
+ end
21
+
22
+ def start
23
+ FFMPEG.logger.debug "Starting: #{command}"
24
+ @video_file = nil # New file
25
+ @process_id = start_ffmpeg
26
+ FFMPEG.logger.info 'Recording...'
27
+ @process_id
28
+ end
29
+
30
+ def stop
31
+ FFMPEG.logger.debug 'Stopping ffmpeg.exe...'
32
+ # msg = Process.kill('INT', @process_id)
33
+ # Process.detach(@process_id)
34
+ msg = kill_ffmpeg
35
+ FFMPEG.logger.debug msg
36
+ FFMPEG.logger.debug 'Stopped ffmpeg.exe'
37
+ FFMPEG.logger.info 'Recording complete.'
38
+ msg
39
+ end
40
+
41
+ # def inputs(application)
42
+ # FFMPEG.logger.debug "Retrieving available windows from: #{application}"
43
+ # available_inputs_by application
44
+ # end
45
+
46
+ def video_file
47
+ @video_file ||= Movie.new(output)
48
+ end
49
+
50
+ private
51
+
52
+ def default_config
53
+ { input: 'desktop',
54
+ framerate: 15,
55
+ device: 'gdigrab',
56
+ log: 'ffmpeg_recorder_log.txt' }
57
+ end
58
+
59
+ def start_ffmpeg
60
+ spawn(command)
61
+ pid = `powershell (Get-Process ffmpeg).id`.to_i
62
+ raise 'ffmpeg failed to start.' if pid.zero?
63
+ pid
64
+ end
65
+
66
+ def kill_ffmpeg
67
+ `TASKKILL /f /im ffmpeg.exe`
68
+ end
69
+
70
+ def init_logger(level)
71
+ FFMPEG.logger.progname = 'FFMPEG::Recorder'
72
+ FFMPEG.logger.level = level
73
+ FFMPEG.logger.formatter = proc do |severity, time, progname, msg|
74
+ "#{time.strftime('%F %T')} #{progname} - #{severity} - #{msg}\n"
75
+ end
76
+ FFMPEG.logger.debug "Logger initialized."
77
+ end
78
+
79
+ def command
80
+ "#{FFMPEG.ffmpeg_binary} -y " \
81
+ "#{extra_opts}" \
82
+ "-f #{opts[:device]} " \
83
+ "-framerate #{opts[:framerate]} " \
84
+ "-i #{opts[:input]} " \
85
+ "#{opts[:output]} " \
86
+ "2> #{opts[:log]}"
87
+ end
88
+
89
+ def extra_opts
90
+ return nil unless opts[:extra_opts]
91
+ raise ':extra_opts cannot be empty.' if opts[:extra_opts].empty?
92
+
93
+ arr = []
94
+ opts[:extra_opts].each { |k, v|
95
+ arr.push "-#{k} #{v}"
96
+ }
97
+ ' ' + arr.join(' ') + ' '
98
+ end
99
+
100
+ # def available_inputs_by(application)
101
+ # `tasklist /v /fi "imagename eq #{application}.exe" /fo list | findstr Window`
102
+ # .split("\n")
103
+ # .reject { |title| title == 'Window Title: N/A' }
104
+ # end
105
+ #
106
+ # def input
107
+ # return opts[:input] if opts[:input] == 'desktop'
108
+ # %Q(title="#{opts[:input].gsub('Window Title: ', '')}")
109
+ # end
110
+ end # class Recorder
111
+ end # module FFMPEG
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffmpeg-screenrecorder
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta
5
+ platform: ruby
6
+ authors:
7
+ - Lakshya Kapoor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-27 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: pry-byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: watir
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '6.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '6.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webdrivers
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: os
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.9.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.9.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: streamio-ffmpeg
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ description: A ruby gem based on streamio-ffmpeg gem to record your computer screen
126
+ in various formats.
127
+ email:
128
+ - kapoorlakshya@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".rubocop.yml"
136
+ - ".travis.yml"
137
+ - Gemfile
138
+ - LICENSE.txt
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/setup
143
+ - ffmpeg-screenrecorder.gemspec
144
+ - lib/ffmpeg.rb
145
+ - lib/ffmpeg/screenrecorder.rb
146
+ homepage: https://github.com/kapoorlakshya/ruby-ffmpeg_screenrecorder
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">"
162
+ - !ruby/object:Gem::Version
163
+ version: 1.3.1
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.7.6
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Record your computer screen using ffmpeg via Ruby.
170
+ test_files: []