carrierwave-video 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -60,7 +60,10 @@ They will be called with the parameters sent to process.
60
60
  }
61
61
 
62
62
  Logging:
63
- logger: :method #returns object that behaves like Logger
63
+ logger: :method # returns object that behaves like Logger
64
+
65
+ progress: :method # method that accepts a value of progress e.g. 0.2 (20%)
66
+ # from https://github.com/streamio/streamio-ffmpeg#transcoding
64
67
 
65
68
  Custom:
66
69
  streamio-ffmpeg accepts custom params. You may pass these in but keep in mind the watermarking params will be appended if there were any.
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Video
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -53,8 +53,16 @@ module CarrierWave
53
53
 
54
54
  yield(file, @options.format_options) if block_given?
55
55
 
56
+ progress = @options.progress(model)
57
+
56
58
  with_trancoding_callbacks do
57
- file.transcode(tmp_path, @options.format_params, @options.encoder_options)
59
+ if progress
60
+ file.transcode(tmp_path, @options.format_params, @options.encoder_options) {
61
+ |value| progress.call(value)
62
+ }
63
+ else
64
+ file.transcode(tmp_path, @options.format_params, @options.encoder_options)
65
+ end
58
66
  File.rename tmp_path, current_path
59
67
  end
60
68
  end
@@ -10,6 +10,7 @@ module CarrierWave
10
10
  @callbacks = options[:callbacks] || {}
11
11
  @logger = options[:logger]
12
12
  @unparsed = options
13
+ @progress = options[:progress]
13
14
 
14
15
  @format_options = defaults.merge(options)
15
16
  end
@@ -22,6 +23,10 @@ module CarrierWave
22
23
  model.send(@logger) if @logger.present?
23
24
  end
24
25
 
26
+ def progress(model)
27
+ lambda {|val| model.send(@progress, val)}
28
+ end
29
+
25
30
  def encoder_options
26
31
  { preserve_aspect_ratio: :width }
27
32
  end
@@ -150,6 +150,18 @@ describe CarrierWave::Video do
150
150
  end
151
151
  end
152
152
 
153
+ context "with progress set" do
154
+ before do
155
+ File.should_receive(:rename)
156
+ movie.stub(:transcode).and_yield(0.0).and_yield(1.0)
157
+ end
158
+ it "logs progress" do
159
+ converter.model.should_receive(:progress).with(0.0)
160
+ converter.model.should_receive(:progress).with(1.0)
161
+ converter.encode_video(format, progress: :progress)
162
+ end
163
+ end
164
+
153
165
  context "with watermark set" do
154
166
  before { File.should_receive(:rename) }
155
167
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-video
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-04 00:00:00.000000000 Z
12
+ date: 2013-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  segments:
111
111
  - 0
112
- hash: 2425759314384983104
112
+ hash: -223199868145326282
113
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  none: false
115
115
  requirements:
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  segments:
120
120
  - 0
121
- hash: 2425759314384983104
121
+ hash: -223199868145326282
122
122
  requirements:
123
123
  - ruby, version 1.9 or greater
124
124
  - ffmpeg, version 0.11.1 or greater with libx256, libfaac, libtheora, libvorbid, libvpx