viddl 0.0.2
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 +7 -0
- data/LICENSE +13 -0
- data/README.md +100 -0
- data/bin/viddl +80 -0
- data/lib/viddl.rb +19 -0
- data/lib/viddl/system.rb +38 -0
- data/lib/viddl/video.rb +23 -0
- data/lib/viddl/video/clip.rb +129 -0
- data/lib/viddl/video/clip/audio.rb +43 -0
- data/lib/viddl/video/clip/crop.rb +59 -0
- data/lib/viddl/video/clip/cut.rb +83 -0
- data/lib/viddl/video/clip/resize.rb +66 -0
- data/lib/viddl/video/download.rb +49 -0
- data/lib/viddl/video/instance.rb +62 -0
- data/spec/helper.rb +8 -0
- data/spec/system_spec.rb +77 -0
- data/spec/video/clip/audio_spec.rb +81 -0
- data/spec/video/clip/crop_spec.rb +113 -0
- data/spec/video/clip/cut_spec.rb +246 -0
- data/spec/video/clip/resize_spec.rb +136 -0
- data/spec/video/clip_spec.rb +443 -0
- data/spec/video/download_spec.rb +42 -0
- data/spec/video/instance_spec.rb +121 -0
- data/spec/video_spec.rb +24 -0
- metadata +109 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Viddl::Video::Clip::Crop do
|
4
|
+
|
5
|
+
context ".options_formatted" do
|
6
|
+
|
7
|
+
context "with no options" do
|
8
|
+
|
9
|
+
it "returns empty hash" do
|
10
|
+
options = {}
|
11
|
+
opts = Viddl::Video::Clip::Crop.send(:options_formatted, options)
|
12
|
+
expect(opts).to(be_empty)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with crop properties" do
|
18
|
+
|
19
|
+
it "returns crop properties" do
|
20
|
+
options = {
|
21
|
+
crop: {
|
22
|
+
x: 100,
|
23
|
+
y: 110,
|
24
|
+
width: 120,
|
25
|
+
height: 130
|
26
|
+
}
|
27
|
+
}
|
28
|
+
opts = Viddl::Video::Clip::Crop.send(:options_formatted, options)
|
29
|
+
expect(opts).to_not(be_empty)
|
30
|
+
expect(opts[:crop]).to_not(be_nil)
|
31
|
+
expect(opts[:crop]).to_not(be_empty)
|
32
|
+
expect(opts[:crop][:x]).to(eq(100))
|
33
|
+
expect(opts[:crop][:y]).to(eq(110))
|
34
|
+
expect(opts[:crop][:width]).to(eq(120))
|
35
|
+
expect(opts[:crop][:height]).to(eq(130))
|
36
|
+
expect(opts.values.compact.count).to(eq(1))
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
context "with mixed types" do
|
42
|
+
|
43
|
+
it "returns integers" do
|
44
|
+
options = {
|
45
|
+
crop: {
|
46
|
+
x: 60,
|
47
|
+
y: "70",
|
48
|
+
width: "80",
|
49
|
+
height: 90
|
50
|
+
}
|
51
|
+
}
|
52
|
+
opts = Viddl::Video::Clip::Crop.send(:options_formatted, options)
|
53
|
+
expect(opts).to_not(be_empty)
|
54
|
+
expect(opts[:crop]).to_not(be_nil)
|
55
|
+
expect(opts[:crop]).to_not(be_empty)
|
56
|
+
expect(opts[:crop][:x]).to(eq(60))
|
57
|
+
expect(opts[:crop][:y]).to(eq(70))
|
58
|
+
expect(opts[:crop][:width]).to(eq(80))
|
59
|
+
expect(opts[:crop][:height]).to(eq(90))
|
60
|
+
expect(opts.values.compact.count).to(eq(1))
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "incomplete crop properties" do
|
66
|
+
|
67
|
+
it "raises" do
|
68
|
+
options = {
|
69
|
+
crop: {
|
70
|
+
x: 20
|
71
|
+
}
|
72
|
+
}
|
73
|
+
expect {
|
74
|
+
Viddl::Video::Clip::Crop.send(:options_formatted, options)
|
75
|
+
}.to(raise_error(RuntimeError))
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
context ".filter_args" do
|
83
|
+
|
84
|
+
context "with no options" do
|
85
|
+
|
86
|
+
it "returns blank string" do
|
87
|
+
options = {}
|
88
|
+
args = Viddl::Video::Clip::Crop.send(:filter_args, options)
|
89
|
+
expect(args).to(be_nil)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
context "with crop properties" do
|
95
|
+
|
96
|
+
it "returns crop arg" do
|
97
|
+
options = {
|
98
|
+
crop: {
|
99
|
+
x: 20,
|
100
|
+
y: 30,
|
101
|
+
width: 40,
|
102
|
+
height: 50
|
103
|
+
}
|
104
|
+
}
|
105
|
+
args = Viddl::Video::Clip::Crop.send(:filter_args, options)
|
106
|
+
expect(args).to(eq("crop=40:50:20:30"))
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Viddl::Video::Clip::Cut do
|
4
|
+
|
5
|
+
context ".options_formatted" do
|
6
|
+
|
7
|
+
context "with no args" do
|
8
|
+
|
9
|
+
it "returns hash with no values" do
|
10
|
+
options = {}
|
11
|
+
formatted_opts = Viddl::Video::Clip::Cut.send(:options_formatted, options)
|
12
|
+
expect(formatted_opts.values.compact).to(be_empty)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with start time only" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@options = {
|
21
|
+
start: 12
|
22
|
+
}
|
23
|
+
@formatted_opts = Viddl::Video::Clip::Cut.send(:options_formatted, @options)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns hash with only start time" do
|
27
|
+
expect(@formatted_opts[:start]).not_to(be_nil)
|
28
|
+
expect(@formatted_opts.values.compact.count).to(eq(1))
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has correct start time value" do
|
32
|
+
expect(@formatted_opts[:start]).to(eq(12))
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with end time only" do
|
38
|
+
|
39
|
+
before(:each) do
|
40
|
+
@options = {
|
41
|
+
end: 14
|
42
|
+
}
|
43
|
+
@formatted_opts = Viddl::Video::Clip::Cut.send(:options_formatted, @options)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns hash with only start time" do
|
47
|
+
expect(@formatted_opts[:duration]).not_to(be_nil)
|
48
|
+
expect(@formatted_opts.values.compact.count).to(eq(1))
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has correct end time value" do
|
52
|
+
expect(@formatted_opts[:duration]).to(eq(14))
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
context "with duration only" do
|
58
|
+
|
59
|
+
before(:each) do
|
60
|
+
@options = {
|
61
|
+
duration: 16
|
62
|
+
}
|
63
|
+
@formatted_opts = Viddl::Video::Clip::Cut.send(:options_formatted, @options)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns hash with only start time" do
|
67
|
+
expect(@formatted_opts[:duration]).not_to(be_nil)
|
68
|
+
expect(@formatted_opts.values.compact.count).to(eq(1))
|
69
|
+
end
|
70
|
+
|
71
|
+
it "has correct end time value" do
|
72
|
+
expect(@formatted_opts[:duration]).to(eq(16))
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
context "with end time and duration" do
|
78
|
+
|
79
|
+
it "raises" do
|
80
|
+
options = {
|
81
|
+
duration: 3,
|
82
|
+
end: 15
|
83
|
+
}
|
84
|
+
expect {
|
85
|
+
Viddl::Video::Clip::Cut.send(:options_formatted, options)
|
86
|
+
}.to(raise_error(RuntimeError))
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
context "with start time and end time" do
|
92
|
+
|
93
|
+
before(:each) do
|
94
|
+
@options = {
|
95
|
+
start: 22,
|
96
|
+
end: 25
|
97
|
+
}
|
98
|
+
@formatted_opts = Viddl::Video::Clip::Cut.send(:options_formatted, @options)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "returns hash with start time and duration" do
|
102
|
+
expect(@formatted_opts[:start]).not_to(be_nil)
|
103
|
+
expect(@formatted_opts[:duration]).not_to(be_nil)
|
104
|
+
expect(@formatted_opts.values.compact.count).to(eq(2))
|
105
|
+
end
|
106
|
+
|
107
|
+
it "has correct values" do
|
108
|
+
expect(@formatted_opts[:start]).to(eq(22))
|
109
|
+
expect(@formatted_opts[:duration]).to(eq(3))
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
context "with start time and duration" do
|
115
|
+
|
116
|
+
before(:each) do
|
117
|
+
@options = {
|
118
|
+
start: 2,
|
119
|
+
duration: 6
|
120
|
+
}
|
121
|
+
@formatted_opts = Viddl::Video::Clip::Cut.send(:options_formatted, @options)
|
122
|
+
end
|
123
|
+
|
124
|
+
it "returns hash with start time and duration" do
|
125
|
+
expect(@formatted_opts[:start]).not_to(be_nil)
|
126
|
+
expect(@formatted_opts[:duration]).not_to(be_nil)
|
127
|
+
expect(@formatted_opts.values.compact.count).to(eq(2))
|
128
|
+
end
|
129
|
+
|
130
|
+
it "has correct values" do
|
131
|
+
expect(@formatted_opts[:start]).to(eq(2))
|
132
|
+
expect(@formatted_opts[:duration]).to(eq(6))
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
context "with start time and end time and duration" do
|
138
|
+
|
139
|
+
it "raises" do
|
140
|
+
options = {
|
141
|
+
start: 10,
|
142
|
+
duration: 3,
|
143
|
+
end: 15
|
144
|
+
}
|
145
|
+
expect {
|
146
|
+
Viddl::Video::Clip::Cut.send(:options_formatted, options)
|
147
|
+
}.to(raise_error(RuntimeError))
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
context ".duration" do
|
155
|
+
|
156
|
+
context "with no options" do
|
157
|
+
|
158
|
+
it "returns nil" do
|
159
|
+
options = {}
|
160
|
+
args = Viddl::Video::Clip::Cut.send(:duration, options)
|
161
|
+
expect(args).to(be_nil)
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
context "with duration" do
|
167
|
+
|
168
|
+
it "has correct duration" do
|
169
|
+
options = {
|
170
|
+
duration: 12
|
171
|
+
}
|
172
|
+
args = Viddl::Video::Clip::Cut.send(:duration, options)
|
173
|
+
expect(args).to(eq(12))
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
context "with end time" do
|
179
|
+
|
180
|
+
it "has correct duration" do
|
181
|
+
options = {
|
182
|
+
start: 10,
|
183
|
+
end: 15
|
184
|
+
}
|
185
|
+
args = Viddl::Video::Clip::Cut.send(:duration, options)
|
186
|
+
expect(args).to(eq(5))
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
context "with end time and duration" do
|
192
|
+
|
193
|
+
it "raises" do
|
194
|
+
options = {
|
195
|
+
duration: 3,
|
196
|
+
end: 15
|
197
|
+
}
|
198
|
+
expect {
|
199
|
+
Viddl::Video::Clip::Cut.send(:duration, options)
|
200
|
+
}.to(raise_error(RuntimeError))
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
context ".args" do
|
208
|
+
|
209
|
+
context "with no options" do
|
210
|
+
|
211
|
+
it "return nil" do
|
212
|
+
options = {}
|
213
|
+
args = Viddl::Video::Clip::Cut.send(:args, options)
|
214
|
+
expect(args).to(be_nil)
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
context "with only start time" do
|
220
|
+
|
221
|
+
it "has correct args" do
|
222
|
+
options = {
|
223
|
+
start: 10
|
224
|
+
}
|
225
|
+
args = Viddl::Video::Clip::Cut.send(:args, options)
|
226
|
+
expect(args).to(eq("-ss 10"))
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
context "with start time and duration" do
|
232
|
+
|
233
|
+
it "has correct args" do
|
234
|
+
options = {
|
235
|
+
start: 10,
|
236
|
+
duration: 15
|
237
|
+
}
|
238
|
+
args = Viddl::Video::Clip::Cut.send(:args, options)
|
239
|
+
expect(args).to(eq("-ss 10 -t 15"))
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe Viddl::Video::Clip::Resize do
|
4
|
+
|
5
|
+
context ".options_formatted" do
|
6
|
+
|
7
|
+
context "with no options" do
|
8
|
+
|
9
|
+
it "returns empty hash" do
|
10
|
+
options = {}
|
11
|
+
opts = Viddl::Video::Clip::Resize.send(:options_formatted, options)
|
12
|
+
expect(opts).to(be_empty)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with width" do
|
18
|
+
|
19
|
+
it "returns only width" do
|
20
|
+
options = {
|
21
|
+
width: 640
|
22
|
+
}
|
23
|
+
opts = Viddl::Video::Clip::Resize.send(:options_formatted, options)
|
24
|
+
expect(opts).to_not(be_empty)
|
25
|
+
expect(opts[:width]).to_not(be_nil)
|
26
|
+
expect(opts[:width]).to(eq(640))
|
27
|
+
expect(opts.values.compact.count).to(eq(1))
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with height" do
|
33
|
+
|
34
|
+
it "returns only height" do
|
35
|
+
options = {
|
36
|
+
height: 480
|
37
|
+
}
|
38
|
+
opts = Viddl::Video::Clip::Resize.send(:options_formatted, options)
|
39
|
+
expect(opts).to_not(be_empty)
|
40
|
+
expect(opts[:height]).to_not(be_nil)
|
41
|
+
expect(opts[:height]).to(eq(480))
|
42
|
+
expect(opts.values.compact.count).to(eq(1))
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with both width and height" do
|
48
|
+
|
49
|
+
it "returns only height" do
|
50
|
+
options = {
|
51
|
+
width: 1024,
|
52
|
+
height: 768
|
53
|
+
}
|
54
|
+
opts = Viddl::Video::Clip::Resize.send(:options_formatted, options)
|
55
|
+
expect(opts).to_not(be_empty)
|
56
|
+
expect(opts[:width]).to_not(be_nil)
|
57
|
+
expect(opts[:width]).to(eq(1024))
|
58
|
+
expect(opts[:height]).to_not(be_nil)
|
59
|
+
expect(opts[:height]).to(eq(768))
|
60
|
+
expect(opts.values.compact.count).to(eq(2))
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "with mixed types" do
|
66
|
+
|
67
|
+
it "returns only ints" do
|
68
|
+
options = {
|
69
|
+
width: "1920",
|
70
|
+
height: 1280
|
71
|
+
}
|
72
|
+
opts = Viddl::Video::Clip::Resize.send(:options_formatted, options)
|
73
|
+
expect(opts).to_not(be_empty)
|
74
|
+
expect(opts[:width]).to_not(be_nil)
|
75
|
+
expect(opts[:width]).to(eq(1920))
|
76
|
+
expect(opts[:height]).to_not(be_nil)
|
77
|
+
expect(opts[:height]).to(eq(1280))
|
78
|
+
expect(opts.values.compact.count).to(eq(2))
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context ".filter_args" do
|
86
|
+
|
87
|
+
context "with no options" do
|
88
|
+
|
89
|
+
it "returns blank string" do
|
90
|
+
options = {}
|
91
|
+
args = Viddl::Video::Clip::Resize.send(:filter_args, options)
|
92
|
+
expect(args).to(be_nil)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
context "with only width" do
|
98
|
+
|
99
|
+
it "returns width and -1 height" do
|
100
|
+
options = {
|
101
|
+
width: 1024
|
102
|
+
}
|
103
|
+
args = Viddl::Video::Clip::Resize.send(:filter_args, options)
|
104
|
+
expect(args).to(eq("scale=1024:-1"))
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
context "with only height" do
|
110
|
+
|
111
|
+
it "returns height and -1 width" do
|
112
|
+
options = {
|
113
|
+
height: 768
|
114
|
+
}
|
115
|
+
args = Viddl::Video::Clip::Resize.send(:filter_args, options)
|
116
|
+
expect(args).to(eq("scale=-1:768"))
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
context "with width and height" do
|
122
|
+
|
123
|
+
it "returns height and width arg" do
|
124
|
+
options = {
|
125
|
+
width: 1280,
|
126
|
+
height: 720
|
127
|
+
}
|
128
|
+
args = Viddl::Video::Clip::Resize.send(:filter_args, options)
|
129
|
+
expect(args).to(eq("scale=1280:720"))
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|