Sha256: dd378df4a7beb4643d2dd9e0b4d94e2df597e443c86f0241f151e533a73b25b1

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

module Lolcommits
  class CaptureLinux < Capturer
    def capture
      tmpdir = File.expand_path "#{Configuration.loldir}/tmpdir#{rand(1000)}/"
      FileUtils.mkdir_p( tmpdir )
      # 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

      # 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
      FileUtils.mv(tmpdir + "/%08d.jpg" % frames, snapshot_location)
      FileUtils.rm_rf( tmpdir )
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lolcommits-0.3.0 lib/lolcommits/capture_linux.rb
lolcommits-0.3.0.pre2 lib/lolcommits/capture_linux.rb
lolcommits-0.3.0.pre1 lib/lolcommits/capture_linux.rb