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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 95679b1b2e16fb661650f03586f126d8477be156
4
- data.tar.gz: 81715a2918564e59d20910e33ddaa27f2d135def
2
+ SHA256:
3
+ metadata.gz: 9d5424a24ecf4eaf711a8ca2b1a779fcb6222fc2ade93a3106a1fcbdc04ad569
4
+ data.tar.gz: 2edb861101e2f2ee30215e9ef0e1368f61c0dc0f6a470186cf873783a2eb4a61
5
5
  SHA512:
6
- metadata.gz: 9d470bc9348adbaeaff769cdee8f00af8d2df9f006eefb514b96c09667664f789f2c5883f89f25e415979859328cea7a73937aa829234dcc8053d8c39b3b74bb
7
- data.tar.gz: d00292a59ad84837b73847619b685c67b9312857a3ba081dcc7fdafd087285930b32b6bd515ca98332b1a5326a60a0150a61ee3b1965325c424ba37b691dc5d1
6
+ metadata.gz: 1f11f72d4eb912467bff4d7ce002b33aa7471acf063e18a3db3b18fbad324a127d257000eea4a7dfbe19b35e57e4d09a85444c9af8eec431e8ea1bfcdcd78edd
7
+ data.tar.gz: b942ea38e90e46b240d73141fc9424dbf25f26f3c4e8a519cfeffa628fc7550f4fd1cde55621d91de7da05a865c57f9a3da1d7076be5f9dc8775a5b1f630a674
@@ -0,0 +1 @@
1
+ carrierwave-video
@@ -0,0 +1 @@
1
+ 2.3.1
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
3
+ - 2.3.1
@@ -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: '-b 1500k'
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 => '-qscale 0 -vpre slow -vpre baseline -g 30')
161
+ encode_video(:mp4, :custom => %w(-qscale 0 -vpre slow -vpre baseline -g 30))
154
162
 
@@ -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", ">= 2.10.0"
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, libfaac, libtheora, libvorbid, libvpx enabled'
29
+ s.requirements << 'ffmpeg, version 0.11.1 or greater with libx256, libfdk-aac, libtheora, libvorbid, libvpx enabled'
30
30
  end
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Video
3
- VERSION = "0.5.6"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -90,7 +90,8 @@ module CarrierWave
90
90
  end
91
91
  end
92
92
 
93
- raise CarrierWave::ProcessingError.new("Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: #{e}")
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: :width }
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] = [params[:custom], watermark_params].compact.join(' ')
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 nil unless watermark?
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: '640x360', watermark: {} }.tap do |h|
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] = 'libfaac'
84
- h[:custom] = '-qscale 0 -preset slow -g 30'
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] = '-b 1500k -ab 160000 -g 30'
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] = '-b 1500k -ab 160000 -f webm -g 30'
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.should_receive(:process).with(encode_video: ["format", :opts])
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.should_receive(:process).with(encode_video: ["format", {}])
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.should_receive(:process).with(encode_ogv: [:opts])
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.should_receive(:process).with(encode_ogv: [{}])
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) { mock }
43
+ let(:movie) { double }
44
44
 
45
45
  before do
46
- converter.stub(:current_path).and_return('video/path/file.mov')
46
+ allow(converter).to receive(:current_path).and_return('video/path/file.mov')
47
47
 
48
- FFMPEG::Movie.should_receive(:new).and_return(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.should_receive(:rename) }
52
+ before { expect(File).to receive(:rename) }
53
53
 
54
54
  it "calls transcode with correct format options" do
55
- movie.should_receive(:transcode) do |path, opts, codec_opts|
56
- codec_opts.should == {preserve_aspect_ratio: :width}
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].should == 'libvpx'
59
- opts[:audio_codec].should == 'libvorbis'
60
- opts[:custom].should == '-b 1500k -ab 160000 -f webm -g 30'
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.should == "video/path/tmpfile.#{format}"
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.should_receive(:transcode) do |path, opts, codec_opts|
70
- opts[:resolution].should == '640x360'
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.should_receive(:transcode) }
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.should_receive(:rename) }
90
+ before { expect(File).to receive(:rename) }
91
91
 
92
92
  it "calls before_transcode, after_transcode, and ensure" do
93
- converter.model.should_receive(:method1).with(format, opts).ordered
94
- converter.model.should_receive(:method2).with(format, opts).ordered
95
- converter.model.should_not_receive(:method3)
96
- converter.model.should_receive(:method4).with(format, opts).ordered
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.should_receive(:rename).and_raise(e) }
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.should_receive(:method1).with(format, opts).ordered
109
- converter.model.should_not_receive(:method2)
110
- converter.model.should_receive(:method3).with(format, opts).ordered
111
- converter.model.should_receive(:method4).with(format, opts).ordered
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
- lambda do
112
+ expect do
114
113
  converter.encode_video(format, opts)
115
- end.should raise_exception(CarrierWave::ProcessingError)
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) { mock }
120
+ let(:logger) { double }
122
121
  before do
123
- converter.model.stub(:logger).and_return(logger)
124
- movie.should_receive(:transcode)
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.should_receive(:rename) }
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.should_receive(:logger=).with(logger).ordered
133
- ::FFMPEG.should_receive(:logger=).with(old_logger).ordered
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.should_receive(:rename).and_raise(e) }
139
+ before { expect(File).to receive(:rename).and_raise(e) }
141
140
 
142
141
  it "logs exception" do
143
- logger.should_receive(:error).with("#{e.class}: #{e.message}")
144
- logger.should_receive(:error).any_number_of_times #backtrace
142
+ expect(logger).to receive(:error).with("#{e.class}: #{e.message}")
143
+ allow(logger).to receive(:error) #backtrace
145
144
 
146
- lambda do
145
+ expect do
147
146
  converter.encode_video(format, logger: :logger)
148
- end.should raise_exception(CarrierWave::ProcessingError)
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.should_receive(:rename)
156
- movie.stub(:transcode).and_yield(0.0).and_yield(1.0)
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.should_receive(:progress).with(0.0)
162
- converter.model.should_receive(:progress).with(1.0)
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.stub_chain(:method, :arity).and_return(3)
168
- converter.model.should_receive(:progress).with(format, hash_including(opts), 0.0)
169
- converter.model.should_receive(:progress).with(format, hash_including(opts), 1.0)
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.should_receive(:rename) }
174
+ before { expect(File).to receive(:rename) }
176
175
 
177
176
  it "appends watermark params to custom params for ffmpeg" do
178
- movie.should_receive(:transcode) do |path, opts, codec_opts|
179
- codec_opts.should == {preserve_aspect_ratio: :width}
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].should == 'libvpx'
182
- opts[:audio_codec].should == 'libvorbis'
183
- opts[:custom].should == "-b 1500k -ab 160000 -f webm -g 30 -vf \"movie=path/to/file.png [logo]; [in][logo] overlay=5:main_h-overlay_h-5 [out]\""
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.should == "video/path/tmpfile.#{format}"
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.should_receive(:transcode) do |path, opts, codec_opts|
197
- codec_opts.should == {preserve_aspect_ratio: :width}
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].should == 'libvpx'
200
- opts[:audio_codec].should == 'libvorbis'
201
- opts[:custom].should == "-b 1500k -ab 160000 -f webm -g 30 -vf \"movie=path/to/file.png [logo]; [in][logo] overlay= [out]\""
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.should == "video/path/tmpfile.#{format}"
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.should_receive(:transcode) do |path, opts, codec_opts|
213
- opts.should_not have_key(:watermark)
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.should_receive(:rename)
227
- movie.stub(:resolution).and_return('1280x720')
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.should_receive(:transcode) do |path, opts, codec_opts|
232
- opts[:resolution].should == '1280x720'
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.should_receive(:rename)
240
+ expect(File).to receive(:rename)
242
241
  end
243
242
 
244
243
  it "takes the provided custom param" do
245
- movie.should_receive(:transcode) do |path, opts, codec_opts|
246
- opts[:custom].should == '-preset slow' # a la changes in ffmpeg 0.11.1
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: '-preset slow')
248
+ converter.encode_video(format, custom: %w(-preset slow))
250
249
  end
251
250
 
252
251
  it "maintains the watermark params" do
253
- movie.should_receive(:transcode) do |path, opts, codec_opts|
254
- opts[:custom].should == "-preset slow -vf \"movie=path/to/file.png [logo]; [in][logo] overlay= [out]\""
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: '-preset slow', watermark: {
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) { mock }
263
+ let(:movie) { double }
265
264
  let(:opts) { {} }
266
- let(:params) { { resolution: "640x360", watermark: {}, video_codec: "libvpx", audio_codec: "libvorbis", custom: "-b 1500k -ab 160000 -f webm -g 30" } }
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.should_receive(:rename)
270
- movie.stub(:resolution).and_return('1280x720')
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.should_receive(:transcode) do |path, format_opts, codec_opts|
275
- format_opts[:video_codec].should == 'libvpx'
276
- format_opts[:audio_codec].should == 'libvorbis'
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] = '-preset slow' }
284
+ block = Proc.new { |input, params| params[:custom] = %w(-preset slow) }
286
285
 
287
- movie.should_receive(:transcode) do |path, format_opts, codec_opts|
288
- format_opts[:custom].should == '-preset slow'
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] = '-preset slow'
295
+ params[:custom] = %w(-preset slow)
297
296
  params[:watermark][:path] = 'customized/path'
298
297
  end
299
298
 
300
- movie.should_receive(:transcode) do |path, format_opts, codec_opts|
301
- format_opts[:custom].should == '-preset slow -vf "movie=customized/path [logo]; [in][logo] overlay= [out]"'
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.should_receive(:transcode) do |path, format_opts, codec_opts|
315
- format_opts[:resolution].should == '1x1'
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) { mock }
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) { mock(:logger) }
326
+ let(:logger) { double(:logger) }
328
327
 
329
328
 
330
329
  before do
331
- converter.model.stub(:logger).and_return(logger)
332
- File.should_receive(:rename)
333
- converter.stub(:current_path).and_return('video/path/input.mov')
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 = mock(:transcoder)
339
- CarrierWave::Video::FfmpegTheora.should_receive(:new).with(movie_path, output_path).and_return(transcoder)
340
- transcoder.should_receive(:run)
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.stub(:logger).and_return(logger)
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 = mock(:transcoder)
353
- CarrierWave::Video::FfmpegTheora.should_receive(:new).with(movie_path, output_path).and_return(transcoder)
354
- transcoder.should_receive(:run).with(logger)
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.should_receive(:popen3).with(command)
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) { mock(: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.should_receive(:popen3).with(command)
28
- logger.should_receive(:info).with("Running....#{command}")
29
- logger.should_receive(:error).with("Failure!")
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
@@ -2,5 +2,6 @@ require 'streamio-ffmpeg'
2
2
  require 'carrierwave/video'
3
3
 
4
4
  RSpec.configure do |config|
5
+ config.raise_errors_for_deprecations!
5
6
  config.mock_with :rspec
6
7
  end
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.5.6
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: 2014-05-16 00:00:00.000000000 Z
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: 2.10.0
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: 2.10.0
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, libfaac, libtheora, libvorbid, libvpx
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.2.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: