teslacam-merge 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/lib/teslacam.rb +1 -1
- data/lib/teslacam/cli.rb +1 -1
- data/lib/teslacam/cli/config.rb +40 -7
- data/lib/teslacam/cli/presets.rb +47 -0
- data/lib/teslacam/config.rb +11 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64008345c39af5336762d10962b743355cce74bc376656242b5265d38eb73568
|
4
|
+
data.tar.gz: f3a150683e4ae613037c43bfce3f7fbdac981e833058206df33f33ca58bc4967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e908cf4113a1fb9563248de1e16ff62b42bb5e1a6a1f7b63e4c83436abd0c36a84457da02b8b2d1c30de11cf9b7854e9c300703564393d811dc33d7c9196716
|
7
|
+
data.tar.gz: 3e984790348d66549dc672ca685a8ead81885210f0bea6d5cd8699943a89b1b503c31fd11b73d3f94713f67a226d23ef89c692dba320cb057d80cee71d23e59c
|
data/README.md
CHANGED
@@ -3,8 +3,15 @@
|
|
3
3
|
Combine TeslaCam videos into a single output video. Allows you to set
|
4
4
|
the output video size, and add a title to the output video.
|
5
5
|
|
6
|
-
|
6
|
+
![teslacam-merge example](example.jpg)
|
7
|
+
|
8
|
+
Features:
|
9
|
+
* Uses [ffmpeg][] to combine output videos.
|
10
|
+
* Scale results.
|
11
|
+
* Automatically sorts input videos, and handles missing videos.
|
12
|
+
* Extracts timestamp from video file names.
|
7
13
|
|
14
|
+
Example:
|
8
15
|
```
|
9
16
|
# combine given videos, set the title to "sample video", and write the
|
10
17
|
# result to the file "sentry-example.mp4"
|
@@ -20,4 +27,14 @@ Install `teslacam-merge` via [RubyGems][]:
|
|
20
27
|
gem install teslacam-merge
|
21
28
|
```
|
22
29
|
|
30
|
+
## Presets
|
31
|
+
Valid values for the `--preset` option:
|
32
|
+
|
33
|
+
* `full`: output size: 2560x1920, font size: 32
|
34
|
+
* `large`: output size: 1920x1440, font size: 32
|
35
|
+
* `medium`: output size: 1440x1080, font size: 24
|
36
|
+
* `half`: output size: 1280x960, font size: 18
|
37
|
+
* `small`: output size: 640x480, font size: 16
|
38
|
+
|
23
39
|
[rubygems]: https://rubygems.org/
|
40
|
+
[ffmpeg]: https://ffmpeg.org/
|
data/lib/teslacam.rb
CHANGED
data/lib/teslacam/cli.rb
CHANGED
@@ -7,6 +7,7 @@ require 'logger'
|
|
7
7
|
module TeslaCam::CLI
|
8
8
|
LIB_DIR = File.join(__dir__, 'cli').freeze
|
9
9
|
autoload :Config, File.join(LIB_DIR, 'config.rb')
|
10
|
+
autoload :Presets, File.join(LIB_DIR, 'presets.rb')
|
10
11
|
|
11
12
|
#
|
12
13
|
# Run from command-line.
|
@@ -21,7 +22,6 @@ module TeslaCam::CLI
|
|
21
22
|
# create model from config and log
|
22
23
|
model = ::TeslaCam::Model.new(config, log)
|
23
24
|
|
24
|
-
|
25
25
|
# exec command
|
26
26
|
log.debug { 'exec: %p' % [model.command] }
|
27
27
|
::Kernel.exec(*model.command)
|
data/lib/teslacam/cli/config.rb
CHANGED
@@ -8,35 +8,68 @@ class TeslaCam::CLI::Config < ::TeslaCam::Config
|
|
8
8
|
# initialize defaults
|
9
9
|
super()
|
10
10
|
|
11
|
+
defaults = ::TeslaCam::Config::DEFAULTS
|
11
12
|
@inputs = OptionParser.new do |o|
|
12
|
-
o.banner = "Usage: #{app} [options] <
|
13
|
+
o.banner = "Usage: #{app} [options] <input_videos>"
|
13
14
|
o.separator ''
|
14
15
|
|
15
16
|
o.separator 'Options:'
|
16
|
-
o.on(
|
17
|
+
o.on(
|
18
|
+
'-o', '--output [FILE]', String,
|
19
|
+
'Output file (required).'
|
20
|
+
) do |val|
|
17
21
|
@output = val
|
18
22
|
end
|
19
23
|
|
20
|
-
o.on(
|
24
|
+
o.on(
|
25
|
+
'-s', '--size [SIZE]', String,
|
26
|
+
'Output size (WxH).',
|
27
|
+
'Defaults to %dx%d if unspecified.' % [
|
28
|
+
defaults[:size].w * 2,
|
29
|
+
defaults[:size].h * 2,
|
30
|
+
]
|
31
|
+
) do |val|
|
21
32
|
md = val.match(/^(?<w>\d+)x(?<h>\d+)$/)
|
22
33
|
raise "invalid size: #{val}" unless md
|
23
34
|
@size = ::TeslaCam::Size.new(md[:w].to_i / 2, md[:h].to_i / 2)
|
24
35
|
end
|
25
36
|
|
26
|
-
o.on(
|
37
|
+
o.on(
|
38
|
+
'--font-size [SIZE]', Integer,
|
39
|
+
'Font size.',
|
40
|
+
'Defaults to %d if unspecified.' % [defaults[:font_size]]
|
41
|
+
) do |val|
|
27
42
|
raise "invalid font size: #{val}" if val < 1
|
28
43
|
@font_size = val
|
29
44
|
end
|
30
45
|
|
31
|
-
o.on(
|
32
|
-
|
46
|
+
o.on(
|
47
|
+
'--bg-color [COLOR]', Integer,
|
48
|
+
'Background color.',
|
49
|
+
'Defaults to %s if unspecified.' % [defaults[:missing_color]]
|
50
|
+
) do |val|
|
33
51
|
@missing_color = val
|
34
52
|
end
|
35
53
|
|
36
|
-
o.on(
|
54
|
+
o.on(
|
55
|
+
'-t', '--title [TITLE]', String,
|
56
|
+
'Video title.',
|
57
|
+
'Defaults to "" if unspecified.'
|
58
|
+
) do |val|
|
37
59
|
@title = val
|
38
60
|
end
|
39
61
|
|
62
|
+
presets = ::TeslaCam::CLI::Presets.list.join(', ')
|
63
|
+
o.on(
|
64
|
+
'-p', '--preset [name]', String,
|
65
|
+
'Use preset.',
|
66
|
+
'One of: %s.' % [::TeslaCam::CLI::Presets.list.join(', ')]
|
67
|
+
) do |val|
|
68
|
+
p = ::TeslaCam::CLI::Presets.get(val)
|
69
|
+
@size = ::TeslaCam::Size.new(p[:size][0] / 2, p[:size][1] / 2)
|
70
|
+
@font_size = p[:font_size]
|
71
|
+
end
|
72
|
+
|
40
73
|
o.on('-q', '--quiet', 'Silence ffmpeg output.') do
|
41
74
|
@quiet = true
|
42
75
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
#
|
4
|
+
# Parse config from command-line arguments
|
5
|
+
#
|
6
|
+
module TeslaCam::CLI::Presets
|
7
|
+
PRESETS = {
|
8
|
+
full: {
|
9
|
+
size: [2560, 1920],
|
10
|
+
font_size: 32,
|
11
|
+
},
|
12
|
+
|
13
|
+
# x0.75
|
14
|
+
large: {
|
15
|
+
size: [1920, 1440],
|
16
|
+
font_size: 32,
|
17
|
+
},
|
18
|
+
|
19
|
+
# x0.5625
|
20
|
+
medium: {
|
21
|
+
size: [1440, 1080],
|
22
|
+
font_size: 24,
|
23
|
+
},
|
24
|
+
|
25
|
+
# x0.5
|
26
|
+
half: {
|
27
|
+
size: [1280, 960],
|
28
|
+
font_size: 18,
|
29
|
+
},
|
30
|
+
|
31
|
+
# x0.25
|
32
|
+
small: {
|
33
|
+
size: [640, 480],
|
34
|
+
font_size: 16,
|
35
|
+
},
|
36
|
+
}
|
37
|
+
|
38
|
+
def self.get(s)
|
39
|
+
id = s.intern
|
40
|
+
raise "unknown preset: #{s}" unless PRESETS.key?(id)
|
41
|
+
PRESETS[id]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.list
|
45
|
+
PRESETS.keys.map { |v| v.to_s }.sort
|
46
|
+
end
|
47
|
+
end
|
data/lib/teslacam/config.rb
CHANGED
@@ -11,6 +11,13 @@ class TeslaCam::Config
|
|
11
11
|
:missing_color,
|
12
12
|
:title
|
13
13
|
|
14
|
+
DEFAULTS = {
|
15
|
+
title: '',
|
16
|
+
size: ::TeslaCam::Size.new(320, 240),
|
17
|
+
font_size: 16,
|
18
|
+
missing_color: 'black',
|
19
|
+
}.freeze
|
20
|
+
|
14
21
|
#
|
15
22
|
# Create a new Config instance and set defaults.
|
16
23
|
#
|
@@ -22,15 +29,15 @@ class TeslaCam::Config
|
|
22
29
|
@quiet = false
|
23
30
|
|
24
31
|
# video title
|
25
|
-
@title =
|
32
|
+
@title = DEFAULTS[:title]
|
26
33
|
|
27
34
|
# output size
|
28
|
-
@size =
|
35
|
+
@size = DEFAULTS[:size]
|
29
36
|
|
30
37
|
# font size
|
31
|
-
@font_size =
|
38
|
+
@font_size = DEFAULTS[:font_size]
|
32
39
|
|
33
40
|
# background color for missing videos
|
34
|
-
@missing_color =
|
41
|
+
@missing_color = DEFAULTS[:missing_color]
|
35
42
|
end
|
36
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teslacam-merge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Duncan
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- lib/teslacam.rb
|
25
25
|
- lib/teslacam/cli.rb
|
26
26
|
- lib/teslacam/cli/config.rb
|
27
|
+
- lib/teslacam/cli/presets.rb
|
27
28
|
- lib/teslacam/config.rb
|
28
29
|
- lib/teslacam/filter.rb
|
29
30
|
- lib/teslacam/model.rb
|