Skip to content

Commit

Permalink
minor improvements to linux capturer
Browse files Browse the repository at this point in the history
  • Loading branch information
matthutchinson committed Sep 27, 2014
1 parent d286365 commit 8c33812
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/lolcommits/capturer/capture_linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,25 @@ def capture

debug 'LinuxCapturer: calling out to mplayer to capture image'
# mplayer's output is ugly and useless, let's throw it away
_, r, _ = Open3.popen3("#{executable_path} -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} -fps #{MPLAYER_FPS} tv://")
_, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} #{capture_device_string} -frames #{frames} -fps #{MPLAYER_FPS} tv://")
# looks like we still need to read the output for something to happen
r.read

# the below SHOULD tell FileUtils actions to post their output if we are in debug mode
include FileUtils::Verbose if logger.level == 0

debug 'LinuxCapturer: calling out to mplayer to capture image'

# get last frame from tmpdir (regardless of fps)
all_frames = Dir.glob("#{tmpdir}/*.jpg").sort_by do |f|
File.mtime(f)
end

FileUtils.mv(all_frames.last, snapshot_location)
debug 'LinuxCapturer: cleaning up'
FileUtils.rm_rf(tmpdir)
end
if all_frames.empty?
debug 'LinuxCapturer: failed to capture any image'
else
FileUtils.mv(all_frames.last, snapshot_location)
debug 'LinuxCapturer: cleaning up'
end

def executable_path
'mplayer'
FileUtils.rm_rf(tmpdir)
end
end
end

0 comments on commit 8c33812

Please sign in to comment.