carrierwave-video 0.5.6 → 0.6.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 +5 -5
- data/.rbenv-gemsets +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/README.rdoc +10 -2
- data/carrierwave-video.gemspec +2 -2
- data/lib/carrierwave-video/version.rb +1 -1
- data/lib/carrierwave/video.rb +2 -1
- data/lib/carrierwave/video/ffmpeg_options.rb +10 -9
- data/spec/lib/carrierwave_video_spec.rb +100 -101
- data/spec/lib/ffmpeg_theora_spec.rb +5 -5
- data/spec/spec_helper.rb +1 -0
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d5424a24ecf4eaf711a8ca2b1a779fcb6222fc2ade93a3106a1fcbdc04ad569
|
4
|
+
data.tar.gz: 2edb861101e2f2ee30215e9ef0e1368f61c0dc0f6a470186cf873783a2eb4a61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f11f72d4eb912467bff4d7ce002b33aa7471acf063e18a3db3b18fbad324a127d257000eea4a7dfbe19b35e57e4d09a85444c9af8eec431e8ea1bfcdcd78edd
|
7
|
+
data.tar.gz: b942ea38e90e46b240d73141fc9424dbf25f26f3c4e8a519cfeffa628fc7550f4fd1cde55621d91de7da05a865c57f9a3da1d7076be5f9dc8775a5b1f630a674
|
data/.rbenv-gemsets
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
carrierwave-video
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -37,6 +37,14 @@ Pass in options to process:
|
|
37
37
|
Resolution passed to ffmpeg:
|
38
38
|
resolution: "640x360"
|
39
39
|
|
40
|
+
Also, you can preserve initial video's aspect ratio by changing one of result's resolutions:
|
41
|
+
preserve_aspect_ratio: :width
|
42
|
+
to change height of the video, depending on it's width (default value),
|
43
|
+
preserve_aspect_ratio: :height
|
44
|
+
to change width of the video, depending on it's height, or
|
45
|
+
preserve_aspect_ratio: false
|
46
|
+
to leave resolution unchanged
|
47
|
+
|
40
48
|
If you want to keep the same resolution:
|
41
49
|
|
42
50
|
Note: This only works with the edge version of streamio-ffmpeg (as of Feb 28, 2014) https://github.com/streamio/streamio-ffmpeg/issues/72
|
@@ -76,7 +84,7 @@ e.g. `def progress(format, format_options, progress)` would receive something li
|
|
76
84
|
|
77
85
|
Custom:
|
78
86
|
streamio-ffmpeg accepts custom params. You may pass these in but keep in mind the watermarking params will be appended if there were any.
|
79
|
-
custom:
|
87
|
+
custom: %w(-b 1500k)
|
80
88
|
|
81
89
|
= Dynamic Configuration
|
82
90
|
|
@@ -150,5 +158,5 @@ Depending on how you installed ffmpeg, you need to put them in the correct direc
|
|
150
158
|
*NOTE:*
|
151
159
|
For older versions of ffmpeg, the +-preset+ flag was called +-vpre+. If you are using a version prior to 0.11, you must call carrierwave-video using the +custom+ option to change those flags. Something along the lines of:
|
152
160
|
|
153
|
-
encode_video(:mp4, :custom =>
|
161
|
+
encode_video(:mp4, :custom => %w(-qscale 0 -vpre slow -vpre baseline -g 30))
|
154
162
|
|
data/carrierwave-video.gemspec
CHANGED
@@ -20,11 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
# specify any dependencies here; for example:
|
23
|
-
s.add_development_dependency "rspec", ">=
|
23
|
+
s.add_development_dependency "rspec", ">= 3.3.0"
|
24
24
|
s.add_development_dependency "rake"
|
25
25
|
|
26
26
|
s.add_runtime_dependency 'streamio-ffmpeg'
|
27
27
|
s.add_runtime_dependency 'carrierwave'
|
28
28
|
s.requirements << 'ruby, version 1.9 or greater'
|
29
|
-
s.requirements << 'ffmpeg, version 0.11.1 or greater with libx256,
|
29
|
+
s.requirements << 'ffmpeg, version 0.11.1 or greater with libx256, libfdk-aac, libtheora, libvorbid, libvpx enabled'
|
30
30
|
end
|
data/lib/carrierwave/video.rb
CHANGED
@@ -90,7 +90,8 @@ module CarrierWave
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
raise
|
93
|
+
raise e
|
94
|
+
|
94
95
|
ensure
|
95
96
|
reset_logger
|
96
97
|
send_callback(callbacks[:ensure])
|
@@ -11,6 +11,7 @@ module CarrierWave
|
|
11
11
|
@logger = options[:logger]
|
12
12
|
@unparsed = options
|
13
13
|
@progress = options[:progress]
|
14
|
+
@preserve_aspect_ratio = options[:preserve_aspect_ratio] || :width
|
14
15
|
|
15
16
|
@format_options = defaults.merge(options)
|
16
17
|
end
|
@@ -31,7 +32,7 @@ module CarrierWave
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def encoder_options
|
34
|
-
{ preserve_aspect_ratio:
|
35
|
+
{ preserve_aspect_ratio: @preserve_aspect_ratio }
|
35
36
|
end
|
36
37
|
|
37
38
|
# input
|
@@ -43,7 +44,7 @@ module CarrierWave
|
|
43
44
|
def format_params
|
44
45
|
params = @format_options.dup
|
45
46
|
params.delete(:watermark)
|
46
|
-
params[:custom] =
|
47
|
+
params[:custom] = params[:custom] + watermark_params
|
47
48
|
params
|
48
49
|
end
|
49
50
|
|
@@ -52,7 +53,7 @@ module CarrierWave
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def watermark_params
|
55
|
-
return
|
56
|
+
return [] unless watermark?
|
56
57
|
|
57
58
|
@watermark_params ||= begin
|
58
59
|
path = @format_options[:watermark][:path]
|
@@ -69,27 +70,27 @@ module CarrierWave
|
|
69
70
|
"main_w-overlay_w-#{margin}:#{margin}"
|
70
71
|
end
|
71
72
|
|
72
|
-
"-vf \"movie=#{path} [logo]; [in][logo] overlay=#{positioning} [out]\""
|
73
|
+
["-vf", "\"movie=#{path} [logo]; [in][logo] overlay=#{positioning} [out]\""]
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
77
|
private
|
77
78
|
|
78
79
|
def defaults
|
79
|
-
@defaults ||= { resolution:
|
80
|
+
@defaults ||= { resolution: @resolution, watermark: {} }.tap do |h|
|
80
81
|
case format
|
81
82
|
when 'mp4'
|
82
83
|
h[:video_codec] = 'libx264'
|
83
|
-
h[:audio_codec] = '
|
84
|
-
h[:custom] =
|
84
|
+
h[:audio_codec] = 'aac'
|
85
|
+
h[:custom] = %w(-r 30 -strict -2 -map_metadata -1)
|
85
86
|
when 'ogv'
|
86
87
|
h[:video_codec] = 'libtheora'
|
87
88
|
h[:audio_codec] = 'libvorbis'
|
88
|
-
h[:custom] =
|
89
|
+
h[:custom] = %w(-b 1500k -ab 160000 -g 30)
|
89
90
|
when 'webm'
|
90
91
|
h[:video_codec] = 'libvpx'
|
91
92
|
h[:audio_codec] = 'libvorbis'
|
92
|
-
h[:custom] =
|
93
|
+
h[:custom] = %w(-b 1500k -ab 160000 -f webm)
|
93
94
|
end
|
94
95
|
end
|
95
96
|
end
|
@@ -16,58 +16,58 @@ describe CarrierWave::Video do
|
|
16
16
|
|
17
17
|
describe ".encode_video" do
|
18
18
|
it "processes the model" do
|
19
|
-
TestVideoUploader.
|
19
|
+
expect(TestVideoUploader).to receive(:process).with(encode_video: ["format", :opts])
|
20
20
|
TestVideoUploader.encode_video("format", :opts)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "does not require options" do
|
24
|
-
TestVideoUploader.
|
24
|
+
expect(TestVideoUploader).to receive(:process).with(encode_video: ["format", {}])
|
25
25
|
TestVideoUploader.encode_video("format")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe ".encode_ogv" do
|
30
30
|
it "processes the model" do
|
31
|
-
TestVideoUploader.
|
31
|
+
expect(TestVideoUploader).to receive(:process).with(encode_ogv: [:opts])
|
32
32
|
TestVideoUploader.encode_ogv(:opts)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "does not require options" do
|
36
|
-
TestVideoUploader.
|
36
|
+
expect(TestVideoUploader).to receive(:process).with(encode_ogv: [{}])
|
37
37
|
TestVideoUploader.encode_ogv
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "#encode_video" do
|
42
42
|
let(:format) { 'webm' }
|
43
|
-
let(:movie) {
|
43
|
+
let(:movie) { double }
|
44
44
|
|
45
45
|
before do
|
46
|
-
converter.
|
46
|
+
allow(converter).to receive(:current_path).and_return('video/path/file.mov')
|
47
47
|
|
48
|
-
FFMPEG::Movie.
|
48
|
+
expect(FFMPEG::Movie).to receive(:new).and_return(movie)
|
49
49
|
end
|
50
50
|
|
51
51
|
context "with no options set" do
|
52
|
-
before { File.
|
52
|
+
before { expect(File).to receive(:rename) }
|
53
53
|
|
54
54
|
it "calls transcode with correct format options" do
|
55
|
-
movie.
|
56
|
-
codec_opts.
|
55
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
56
|
+
expect(codec_opts).to eq({preserve_aspect_ratio: :width})
|
57
57
|
|
58
|
-
opts[:video_codec].
|
59
|
-
opts[:audio_codec].
|
60
|
-
opts[:custom].
|
58
|
+
expect(opts[:video_codec]).to eq('libvpx')
|
59
|
+
expect(opts[:audio_codec]).to eq('libvorbis')
|
60
|
+
expect(opts[:custom]).to eq(%w(-b 1500k -ab 160000 -f webm))
|
61
61
|
|
62
|
-
path.
|
62
|
+
expect(path).to eq("video/path/tmpfile.#{format}")
|
63
63
|
end
|
64
64
|
|
65
65
|
converter.encode_video(format)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "provides a default for the resolution" do
|
69
|
-
movie.
|
70
|
-
opts[:resolution].
|
69
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
70
|
+
expect(opts[:resolution]).to eq('640x360')
|
71
71
|
end
|
72
72
|
|
73
73
|
converter.encode_video(format)
|
@@ -75,7 +75,7 @@ describe CarrierWave::Video do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
context "with callbacks set" do
|
78
|
-
before { movie.
|
78
|
+
before { expect(movie).to receive(:transcode) }
|
79
79
|
let(:opts) do
|
80
80
|
{ callbacks: {
|
81
81
|
before_transcode: :method1,
|
@@ -87,13 +87,13 @@ describe CarrierWave::Video do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
context "no exceptions raised" do
|
90
|
-
before { File.
|
90
|
+
before { expect(File).to receive(:rename) }
|
91
91
|
|
92
92
|
it "calls before_transcode, after_transcode, and ensure" do
|
93
|
-
converter.model.
|
94
|
-
converter.model.
|
95
|
-
converter.model.
|
96
|
-
converter.model.
|
93
|
+
expect(converter.model).to receive(:method1).with(format, opts).ordered
|
94
|
+
expect(converter.model).to receive(:method2).with(format, opts).ordered
|
95
|
+
expect(converter.model).not_to receive(:method3)
|
96
|
+
expect(converter.model).to receive(:method4).with(format, opts).ordered
|
97
97
|
|
98
98
|
converter.encode_video(format, opts)
|
99
99
|
end
|
@@ -101,88 +101,87 @@ describe CarrierWave::Video do
|
|
101
101
|
|
102
102
|
context "exception raised" do
|
103
103
|
let(:e) { StandardError.new("test error") }
|
104
|
-
before { File.
|
105
|
-
|
104
|
+
before { expect(File).to receive(:rename).and_raise(e) }
|
106
105
|
|
107
106
|
it "calls before_transcode and ensure" do
|
108
|
-
converter.model.
|
109
|
-
converter.model.
|
110
|
-
converter.model.
|
111
|
-
converter.model.
|
107
|
+
expect(converter.model).to receive(:method1).with(format, opts).ordered
|
108
|
+
expect(converter.model).not_to receive(:method2)
|
109
|
+
expect(converter.model).to receive(:method3).with(format, opts).ordered
|
110
|
+
expect(converter.model).to receive(:method4).with(format, opts).ordered
|
112
111
|
|
113
|
-
|
112
|
+
expect do
|
114
113
|
converter.encode_video(format, opts)
|
115
|
-
end.
|
114
|
+
end.to raise_exception(e.class)
|
116
115
|
end
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
120
119
|
context "with logger set" do
|
121
|
-
let(:logger) {
|
120
|
+
let(:logger) { double }
|
122
121
|
before do
|
123
|
-
converter.model.
|
124
|
-
movie.
|
122
|
+
allow(converter.model).to receive(:logger).and_return(logger)
|
123
|
+
expect(movie).to receive(:transcode)
|
125
124
|
end
|
126
125
|
|
127
126
|
context "with no exceptions" do
|
128
|
-
before { File.
|
127
|
+
before { expect(File).to receive(:rename) }
|
129
128
|
|
130
129
|
it "sets FFMPEG logger to logger and resets" do
|
131
130
|
old_logger = ::FFMPEG.logger
|
132
|
-
::FFMPEG.
|
133
|
-
::FFMPEG.
|
131
|
+
expect(::FFMPEG).to receive(:logger=).with(logger).ordered
|
132
|
+
expect(::FFMPEG).to receive(:logger=).with(old_logger).ordered
|
134
133
|
converter.encode_video(format, logger: :logger)
|
135
134
|
end
|
136
135
|
end
|
137
136
|
|
138
137
|
context "with exceptions" do
|
139
138
|
let(:e) { StandardError.new("test error") }
|
140
|
-
before { File.
|
139
|
+
before { expect(File).to receive(:rename).and_raise(e) }
|
141
140
|
|
142
141
|
it "logs exception" do
|
143
|
-
logger.
|
144
|
-
logger.
|
142
|
+
expect(logger).to receive(:error).with("#{e.class}: #{e.message}")
|
143
|
+
allow(logger).to receive(:error) #backtrace
|
145
144
|
|
146
|
-
|
145
|
+
expect do
|
147
146
|
converter.encode_video(format, logger: :logger)
|
148
|
-
end.
|
147
|
+
end.to raise_exception(e.class)
|
149
148
|
end
|
150
149
|
end
|
151
150
|
end
|
152
151
|
|
153
152
|
context "with progress set" do
|
154
153
|
before do
|
155
|
-
File.
|
156
|
-
movie.
|
154
|
+
expect(File).to receive(:rename)
|
155
|
+
allow(movie).to receive(:transcode).and_yield(0.0).and_yield(1.0)
|
157
156
|
end
|
158
157
|
let(:opts) { {progress: :progress} }
|
159
158
|
|
160
159
|
it "logs progress" do
|
161
|
-
converter.model.
|
162
|
-
converter.model.
|
160
|
+
expect(converter.model).to receive(:progress).with(0.0)
|
161
|
+
expect(converter.model).to receive(:progress).with(1.0)
|
163
162
|
converter.encode_video(format, progress: :progress)
|
164
163
|
end
|
165
164
|
|
166
165
|
it "logs progress with format and options" do
|
167
|
-
converter.model.
|
168
|
-
converter.model.
|
169
|
-
converter.model.
|
166
|
+
allow(converter.model).to receive_message_chain(:method, :arity).and_return(3)
|
167
|
+
expect(converter.model).to receive(:progress).with(format, hash_including(opts), 0.0)
|
168
|
+
expect(converter.model).to receive(:progress).with(format, hash_including(opts), 1.0)
|
170
169
|
converter.encode_video(format, opts)
|
171
170
|
end
|
172
171
|
end
|
173
172
|
|
174
173
|
context "with watermark set" do
|
175
|
-
before { File.
|
174
|
+
before { expect(File).to receive(:rename) }
|
176
175
|
|
177
176
|
it "appends watermark params to custom params for ffmpeg" do
|
178
|
-
movie.
|
179
|
-
codec_opts.
|
177
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
178
|
+
expect(codec_opts).to eq({preserve_aspect_ratio: :width})
|
180
179
|
|
181
|
-
opts[:video_codec].
|
182
|
-
opts[:audio_codec].
|
183
|
-
opts[:custom].
|
180
|
+
expect(opts[:video_codec]).to eq('libvpx')
|
181
|
+
expect(opts[:audio_codec]).to eq('libvorbis')
|
182
|
+
expect(opts[:custom]).to eq(["-b","1500k","-ab","160000","-f","webm","-vf","\"movie=path/to/file.png [logo]; [in][logo] overlay=5:main_h-overlay_h-5 [out]\""])
|
184
183
|
|
185
|
-
path.
|
184
|
+
expect(path).to eq("video/path/tmpfile.#{format}")
|
186
185
|
end
|
187
186
|
|
188
187
|
converter.encode_video(format, watermark: {
|
@@ -193,14 +192,14 @@ describe CarrierWave::Video do
|
|
193
192
|
end
|
194
193
|
|
195
194
|
it "only requires path watermark parameter" do
|
196
|
-
movie.
|
197
|
-
codec_opts.
|
195
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
196
|
+
expect(codec_opts).to eq({preserve_aspect_ratio: :width})
|
198
197
|
|
199
|
-
opts[:video_codec].
|
200
|
-
opts[:audio_codec].
|
201
|
-
opts[:custom].
|
198
|
+
expect(opts[:video_codec]).to eq('libvpx')
|
199
|
+
expect(opts[:audio_codec]).to eq('libvorbis')
|
200
|
+
expect(opts[:custom]).to eq(["-b","1500k","-ab","160000","-f","webm","-vf","\"movie=path/to/file.png [logo]; [in][logo] overlay= [out]\""])
|
202
201
|
|
203
|
-
path.
|
202
|
+
expect(path).to eq("video/path/tmpfile.#{format}")
|
204
203
|
end
|
205
204
|
|
206
205
|
converter.encode_video(format, watermark: {
|
@@ -209,8 +208,8 @@ describe CarrierWave::Video do
|
|
209
208
|
end
|
210
209
|
|
211
210
|
it "removes watermark options from common options" do
|
212
|
-
movie.
|
213
|
-
opts.
|
211
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
212
|
+
expect(opts).not_to have_key(:watermark)
|
214
213
|
end
|
215
214
|
|
216
215
|
converter.encode_video(format, watermark: {
|
@@ -223,13 +222,13 @@ describe CarrierWave::Video do
|
|
223
222
|
|
224
223
|
context "with resolution set to :same" do
|
225
224
|
before do
|
226
|
-
File.
|
227
|
-
movie.
|
225
|
+
expect(File).to receive(:rename)
|
226
|
+
allow(movie).to receive(:resolution).and_return('1280x720')
|
228
227
|
end
|
229
228
|
|
230
229
|
it "sets the output resolution to match that of the input" do
|
231
|
-
movie.
|
232
|
-
opts[:resolution].
|
230
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
231
|
+
expect(opts[:resolution]).to eq('1280x720')
|
233
232
|
end
|
234
233
|
|
235
234
|
converter.encode_video(format, resolution: :same)
|
@@ -238,42 +237,42 @@ describe CarrierWave::Video do
|
|
238
237
|
|
239
238
|
context "with custom passed in" do
|
240
239
|
before do
|
241
|
-
File.
|
240
|
+
expect(File).to receive(:rename)
|
242
241
|
end
|
243
242
|
|
244
243
|
it "takes the provided custom param" do
|
245
|
-
movie.
|
246
|
-
opts[:custom].
|
244
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
245
|
+
expect(opts[:custom]).to eq(%w(-preset slow)) # a la changes in ffmpeg 0.11.1
|
247
246
|
end
|
248
247
|
|
249
|
-
converter.encode_video(format, custom:
|
248
|
+
converter.encode_video(format, custom: %w(-preset slow))
|
250
249
|
end
|
251
250
|
|
252
251
|
it "maintains the watermark params" do
|
253
|
-
movie.
|
254
|
-
opts[:custom].
|
252
|
+
expect(movie).to receive(:transcode) do |path, opts, codec_opts|
|
253
|
+
expect(opts[:custom]).to eq(["-preset","slow","-vf","\"movie=path/to/file.png [logo]; [in][logo] overlay= [out]\""])
|
255
254
|
end
|
256
255
|
|
257
|
-
converter.encode_video(format, custom:
|
256
|
+
converter.encode_video(format, custom: %w(-preset slow), watermark: {
|
258
257
|
path: 'path/to/file.png'
|
259
258
|
})
|
260
259
|
end
|
261
260
|
end
|
262
261
|
|
263
262
|
context "given a block" do
|
264
|
-
let(:movie) {
|
263
|
+
let(:movie) { double }
|
265
264
|
let(:opts) { {} }
|
266
|
-
let(:params) { { resolution: "640x360", watermark: {}, video_codec: "libvpx", audio_codec: "libvorbis", custom:
|
265
|
+
let(:params) { { resolution: "640x360", watermark: {}, video_codec: "libvpx", audio_codec: "libvorbis", custom: %w(-b 1500k -ab 160000 -f webm) } }
|
267
266
|
|
268
267
|
before do
|
269
|
-
File.
|
270
|
-
movie.
|
268
|
+
expect(File).to receive(:rename)
|
269
|
+
allow(movie).to receive(:resolution).and_return('1280x720')
|
271
270
|
end
|
272
271
|
|
273
272
|
it "calls the block, with the movie file and params" do
|
274
|
-
movie.
|
275
|
-
format_opts[:video_codec].
|
276
|
-
format_opts[:audio_codec].
|
273
|
+
expect(movie).to receive(:transcode) do |path, format_opts, codec_opts|
|
274
|
+
expect(format_opts[:video_codec]).to eq('libvpx')
|
275
|
+
expect(format_opts[:audio_codec]).to eq('libvorbis')
|
277
276
|
end
|
278
277
|
|
279
278
|
expect {
|
@@ -282,10 +281,10 @@ describe CarrierWave::Video do
|
|
282
281
|
end
|
283
282
|
|
284
283
|
it "allows the block to modify the params" do
|
285
|
-
block = Proc.new { |input, params| params[:custom] =
|
284
|
+
block = Proc.new { |input, params| params[:custom] = %w(-preset slow) }
|
286
285
|
|
287
|
-
movie.
|
288
|
-
format_opts[:custom].
|
286
|
+
expect(movie).to receive(:transcode) do |path, format_opts, codec_opts|
|
287
|
+
expect(format_opts[:custom]).to eq(%w(-preset slow))
|
289
288
|
end
|
290
289
|
|
291
290
|
converter.encode_video(format, opts, &block)
|
@@ -293,12 +292,12 @@ describe CarrierWave::Video do
|
|
293
292
|
|
294
293
|
it "evaluates the final params after any modifications" do
|
295
294
|
block = Proc.new do |input, params|
|
296
|
-
params[:custom] =
|
295
|
+
params[:custom] = %w(-preset slow)
|
297
296
|
params[:watermark][:path] = 'customized/path'
|
298
297
|
end
|
299
298
|
|
300
|
-
movie.
|
301
|
-
format_opts[:custom].
|
299
|
+
expect(movie).to receive(:transcode) do |path, format_opts, codec_opts|
|
300
|
+
expect(format_opts[:custom]).to eq(["-preset","slow","-vf","\"movie=customized/path [logo]; [in][logo] overlay= [out]\""])
|
302
301
|
end
|
303
302
|
|
304
303
|
converter.encode_video(format, opts, &block)
|
@@ -311,8 +310,8 @@ describe CarrierWave::Video do
|
|
311
310
|
params[:resolution] = '1x1'
|
312
311
|
end
|
313
312
|
|
314
|
-
movie.
|
315
|
-
format_opts[:resolution].
|
313
|
+
expect(movie).to receive(:transcode) do |path, format_opts, codec_opts|
|
314
|
+
expect(format_opts[:resolution]).to eq('1x1')
|
316
315
|
end
|
317
316
|
|
318
317
|
converter.encode_video(format, opts, &block)
|
@@ -321,23 +320,23 @@ describe CarrierWave::Video do
|
|
321
320
|
end
|
322
321
|
|
323
322
|
describe "#encode_ogv" do
|
324
|
-
let(:movie) {
|
323
|
+
let(:movie) { double }
|
325
324
|
let(:output_path) { 'video/path/tmpfile.ogv' }
|
326
325
|
let(:movie_path) { 'video/path/input.mov' }
|
327
|
-
let(:logger) {
|
326
|
+
let(:logger) { double(:logger) }
|
328
327
|
|
329
328
|
|
330
329
|
before do
|
331
|
-
converter.model.
|
332
|
-
File.
|
333
|
-
converter.
|
330
|
+
allow(converter.model).to receive(:logger).and_return(logger)
|
331
|
+
expect(File).to receive(:rename)
|
332
|
+
allow(converter).to receive(:current_path).and_return('video/path/input.mov')
|
334
333
|
end
|
335
334
|
|
336
335
|
context "no options set" do
|
337
336
|
it "calls transcode with correct format options" do
|
338
|
-
transcoder =
|
339
|
-
CarrierWave::Video::FfmpegTheora.
|
340
|
-
transcoder.
|
337
|
+
transcoder = double(:transcoder)
|
338
|
+
expect(CarrierWave::Video::FfmpegTheora).to receive(:new).with(movie_path, output_path).and_return(transcoder)
|
339
|
+
expect(transcoder).to receive(:run)
|
341
340
|
|
342
341
|
converter.encode_ogv({})
|
343
342
|
end
|
@@ -345,13 +344,13 @@ describe CarrierWave::Video do
|
|
345
344
|
|
346
345
|
context "with logger set" do
|
347
346
|
before do
|
348
|
-
converter.model.
|
347
|
+
allow(converter.model).to receive(:logger).and_return(logger)
|
349
348
|
end
|
350
349
|
|
351
350
|
it "calls transcode with correct format options and passes logger to transcoder" do
|
352
|
-
transcoder =
|
353
|
-
CarrierWave::Video::FfmpegTheora.
|
354
|
-
transcoder.
|
351
|
+
transcoder = double(:transcoder)
|
352
|
+
expect(CarrierWave::Video::FfmpegTheora).to receive(:new).with(movie_path, output_path).and_return(transcoder)
|
353
|
+
expect(transcoder).to receive(:run).with(logger)
|
355
354
|
|
356
355
|
converter.encode_ogv({logger: :logger})
|
357
356
|
end
|
@@ -14,19 +14,19 @@ describe CarrierWave::Video::FfmpegTheora do
|
|
14
14
|
|
15
15
|
it "should run the ffmpeg2theora binary" do
|
16
16
|
command = "#{binary} #{input_file_path} -o #{output_file_path}"
|
17
|
-
Open3.
|
17
|
+
expect(Open3).to receive(:popen3).with(command)
|
18
18
|
|
19
19
|
transcoder.run
|
20
20
|
end
|
21
21
|
|
22
22
|
context "given a logger" do
|
23
|
-
let(:logger) {
|
23
|
+
let(:logger) { double(:logger) }
|
24
24
|
|
25
25
|
it "should run and log results" do
|
26
26
|
command = "#{binary} #{input_file_path} -o #{output_file_path}"
|
27
|
-
Open3.
|
28
|
-
logger.
|
29
|
-
logger.
|
27
|
+
expect(Open3).to receive(:popen3).with(command)
|
28
|
+
expect(logger).to receive(:info).with("Running....#{command}")
|
29
|
+
expect(logger).to receive(:error).with("Failure!")
|
30
30
|
|
31
31
|
transcoder.run(logger)
|
32
32
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rheaton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.3.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,6 +74,8 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".rbenv-gemsets"
|
78
|
+
- ".ruby-version"
|
77
79
|
- ".travis.yml"
|
78
80
|
- Gemfile
|
79
81
|
- LICENSE
|
@@ -107,10 +109,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
109
|
version: '0'
|
108
110
|
requirements:
|
109
111
|
- ruby, version 1.9 or greater
|
110
|
-
- ffmpeg, version 0.11.1 or greater with libx256,
|
111
|
-
enabled
|
112
|
+
- ffmpeg, version 0.11.1 or greater with libx256, libfdk-aac, libtheora, libvorbid,
|
113
|
+
libvpx enabled
|
112
114
|
rubyforge_project: carrierwave-video
|
113
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.7.4
|
114
116
|
signing_key:
|
115
117
|
specification_version: 4
|
116
118
|
summary: Carrierwave extension that uses ffmpeg to transcode videos.
|
@@ -118,4 +120,3 @@ test_files:
|
|
118
120
|
- spec/lib/carrierwave_video_spec.rb
|
119
121
|
- spec/lib/ffmpeg_theora_spec.rb
|
120
122
|
- spec/spec_helper.rb
|
121
|
-
has_rdoc:
|