tlapse 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eab9b586439d82883ccc5ac792d4ffb540fe23aa
4
- data.tar.gz: 89a788b123c3c8f6c0f133b85e119a8be4afe208
3
+ metadata.gz: 4e3dade67d2c7f9af917ccf9b982edf95ded5632
4
+ data.tar.gz: 601892decfc0671d8747d5d365c0ef97d5744666
5
5
  SHA512:
6
- metadata.gz: 75c5ca5477bd8ee703feaefb0c6694b79d028c425ae1d217a76a378ebc729795eca6563f8f3dba96c5608e90a9db71a841dc43cd151b2b60a3b6fae7023f8b31
7
- data.tar.gz: 1cca071ea1e326b27d4cd37fac079295fdc7190468b688f16e5b4a55e9e9030fa6ef092c630bf97d5dd0270b9c96d6584ed223edd9d115dddd2254ad551c1338
6
+ metadata.gz: a3413e6f93ea1ba1119534df0184de5fe23b80a5ac31f4576e78ddb0155d6d2fe5efa667498c46a3bf36995123e097eb6183778d7ca85549e4aecf5ed6b1c9c9
7
+ data.tar.gz: e3275c1753c619db557cee7bf2722ff7ea9d0461849ac4124c1600b11021533e186087ee761fb2692c471f1ac902c62a8598aa3993f060bae49c0a79cd6c9b99
data/bin/tlapse CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "gli"
4
+ require "fileutils"
4
5
  require "byebug"
5
6
 
6
7
  require_relative "../lib/tlapse"
@@ -13,17 +14,46 @@ version Tlapse::VERSION
13
14
 
14
15
  desc "Determine whether you are ready to start capturing"
15
16
  command :doctor do |c|
16
- c.action do |global_options,options,args|
17
+ c.action do |global_options, options, args|
17
18
  doctor
18
19
  end
19
20
  end
20
21
 
21
22
  desc "Capture a single photo, saving it to the current directory"
22
23
  command :single do |c|
23
- c.action do |global_options,options,args|
24
+ c.action do |global_options, options, args|
24
25
  capture_single
25
26
  end
26
27
  end
27
28
 
29
+
30
+ desc "Use ffmpeg to combine all .jpg files in the current directory"
31
+ command :compile do |c|
32
+
33
+ c.switch :f, :force,
34
+ desc: "Force overwrite existing output files",
35
+ negatable: false
36
+
37
+ c.flag :o, :out,
38
+ desc: "The desired output filename",
39
+ default_value: "out.mkv",
40
+ arg_name: "outfile"
41
+
42
+ c.action do |global_options, options, args|
43
+ video = Video.new options
44
+
45
+ if video.outfile_exists?
46
+ if options[:force]
47
+ FileUtils.rm video.outfile
48
+ puts "Removed file #{video.outfile}"
49
+ else
50
+ raise "#{video.outfile} exists. Use -f to overwrite or " \
51
+ "-o to specify a different output file."
52
+ end
53
+ end
54
+ video.create!
55
+ end
56
+ end
57
+
28
58
  exit run(ARGV)
29
59
 
@@ -1,8 +1,7 @@
1
1
  module Tlapse
2
2
  module Capture
3
3
  def capture_single
4
- puts "Capturing single image"
5
- # TODO: Actually capture image
4
+ `gphoto2 --capture-image-and-download`
6
5
  end
7
6
  end # Capture
8
7
  end # Tlapse
data/lib/tlapse/doctor.rb CHANGED
@@ -2,16 +2,36 @@ module Tlapse
2
2
  module Doctor
3
3
  def doctor
4
4
  print "Checking gphoto2..."
5
- if `which gphoto2`.empty?
6
- raise "Could not find gphoto2 :("
7
- end
5
+ check_gphoto2!
8
6
  puts "ok!"
9
7
 
10
8
  print "Checking camera..."
11
- # TODO: Check camera
9
+ check_camera!
12
10
  puts "ok!"
13
11
 
14
12
  puts "Looks good!"
15
13
  end
14
+
15
+ private ###################################################################
16
+
17
+ def check_gphoto2!
18
+ raise "Could not find gphoto2 :(" if `which gphoto2`.empty?
19
+ end
20
+
21
+ def check_camera!
22
+ cameras = `gphoto2 --auto-detect`
23
+
24
+ # Output looks like this:
25
+ #
26
+ # Model Port
27
+ # --------------------
28
+ # Camera :usb
29
+ #
30
+ # If there is a third line, a camera was detected
31
+
32
+ unless cameras.split("\n").length > 2
33
+ raise "gphoto2 couldn't find a camera :("
34
+ end
35
+ end
16
36
  end # Doctor
17
37
  end # Tlapse
@@ -1,3 +1,3 @@
1
1
  module Tlapse
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,32 @@
1
+ module Tlapse
2
+ class Video
3
+
4
+ attr_accessor *%i(size framerate codec outfile)
5
+
6
+ def initialize(opts)
7
+ @size = opts.fetch :size, "1920x1080"
8
+ @framerate = opts.fetch :framerate, "60"
9
+ @codec = opts.fetch :codec, "libx264"
10
+ @outfile = opts.fetch :out, "out.mkv"
11
+ end
12
+
13
+ def create!
14
+ command = "ffmpeg"
15
+ command += " -pattern_type glob"
16
+ command += " -i '*.jpg'"
17
+ command += " -s #{@size}"
18
+ command += " -r #{@framerate}"
19
+ command += " -vcodec #{@codec}"
20
+ command += " #{@outfile}"
21
+ puts command
22
+ exec command
23
+ end
24
+
25
+ ##
26
+ # @return whether the output file already exists
27
+ def outfile_exists?
28
+ File.exist? @outfile
29
+ end
30
+
31
+ end # Video
32
+ end # Tlapse
data/lib/tlapse.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "tlapse/version"
2
2
  require_relative "tlapse/doctor"
3
3
  require_relative "tlapse/capture"
4
+ require_relative "tlapse/video"
4
5
 
5
6
  include Tlapse::Doctor
6
7
  include Tlapse::Capture
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tlapse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Toniazzo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -103,6 +103,7 @@ files:
103
103
  - lib/tlapse/capture.rb
104
104
  - lib/tlapse/doctor.rb
105
105
  - lib/tlapse/version.rb
106
+ - lib/tlapse/video.rb
106
107
  - tlapse.gemspec
107
108
  homepage: https://github.com/jutonz/tlapse
108
109
  licenses: