Class: Lolcommits::CaptureLinux
- Defined in:
- lib/lolcommits/capture_linux.rb
Instance Attribute Summary
Attributes inherited from Capturer
#capture_delay, #capture_device, #font, #snapshot_location
Instance Method Summary collapse
Methods inherited from Capturer
Constructor Details
This class inherits a constructor from Lolcommits::Capturer
Instance Method Details
#capture ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lolcommits/capture_linux.rb', line 3 def capture debug "LinuxCapturer: making tmp directory" tmpdir = Dir.mktmpdir # There's no way to give a capture delay in mplayer, but a number of frame # I've found that 6 is a good value for me. frames = if capture_delay != 0 then capture_delay else 6 end debug "LinuxCapturer: calling out to mplayer to capture image" # mplayer's output is ugly and useless, let's throw it away _, r, _ = Open3.popen3("mplayer -vo jpeg:outdir=#{tmpdir} -frames #{frames} 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" FileUtils.mv(tmpdir + "/%08d.jpg" % frames, snapshot_location) debug "LinuxCapturer: cleaning up" FileUtils.rm_rf( tmpdir ) end |