Skip to content

Commit

Permalink
wip: window recording
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlakshya committed Jul 21, 2024
1 parent fa77d0d commit e8716f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/screen-recorder/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def log
# ready for the ffmpeg process to use
#
def parsed
vals = "-f #{capture_device} "
vals = "-f #{capture_device}"
vals << parse_advanced(advanced_input)
vals << "-i #{input} " unless advanced_input[:i] # Input provided by user
vals << "-i #{input}" unless advanced_input[:i] # Input provided by user
vals << parse_advanced(advanced)
vals << parse_advanced(advanced_output)
vals << output
Expand Down
7 changes: 4 additions & 3 deletions lib/screen-recorder/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Window < Common
def initialize(title:, output:, advanced: {})
raise 'Window recording is only supported on Microsoft Windows.' unless OS.windows?

super(input: "title=#{title}", output: output, advanced: advanced)
# %("title=#{title}")
super(input: %(title="#{title}"), output: output, advanced: advanced)
end

class << self
Expand Down Expand Up @@ -39,8 +40,8 @@ def window_title_for(process_name)
raise NotImplementedError, 'Only Microsoft Windows (gdigrab) supports window capture.' unless OS.windows?

output = `tasklist /v /fi "imagename eq #{process_name}.exe" /fo list | findstr Window`
encode = output.encode('iso-8859-1').force_encoding('utf-8')
titles = encode
output = output.encode('iso-8859-1').force_encoding('utf-8') unless output.valid_encoding?
titles = output
.split("\n")
.map { |i| i.gsub(FILTERED_TITLES, '') }
.reject(&:empty?)
Expand Down
6 changes: 3 additions & 3 deletions spec/screen-recorder/window_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end

before do
browser.goto 'watir.com'
browser.goto 'google.com'
browser.wait
end

Expand All @@ -27,10 +27,10 @@
recorder.stop

aggregate_failures do
expect(recorder.options.all[:input]).to include('Watir Project')
expect(recorder.options.all[:input]).to include('Google')
expect(File).to exist(recorder.options.output)
expect(recorder.video.valid?).to be(true)
end
end
end
end
end

0 comments on commit e8716f8

Please sign in to comment.