Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
matthutchinson committed Sep 7, 2014
1 parent a9df762 commit 2eb6838
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/lolcommits/capturer/capture_linux.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
# -*- encoding : utf-8 -*-
module Lolcommits
class CaptureLinux < Capturer
MPLAYER_FPS = 25

def capture_device_string
@capture_device.nil? ? nil : "-tv device=\"#{@capture_device}\""
end

def capture
debug 'LinuxCapturer: making tmp directory'
tmpdir = Dir.mktmpdir
fps = 25

# Default delay is 1s
delay = if capture_delay != 0 then capture_delay else 1 end

# There's no way to give a capture delay in mplayer, but a number of frame
# mplayer's "delay" is actually a number of frames at 25 fps
# multiply the set value (in seconds) by 25
frames = delay.to_i * MPLAYER_FPS
frames = delay.to_i * fps

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

Expand Down

0 comments on commit 2eb6838

Please sign in to comment.