paperclip-ffmpeg 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in paperclip-ffmpeg.gemspec
4
- gemspec
4
+ gemspec
5
+ rake
@@ -1,3 +1,3 @@
1
1
  require "paperclip"
2
- require "processors/ffmpeg"
3
- require "processors/qtfaststart"
2
+ require "paperclip_processors/ffmpeg"
3
+ require "paperclip_processors/qtfaststart"
@@ -40,13 +40,19 @@ module Paperclip
40
40
  # Performs the transcoding of the +file+ into a thumbnail/video. Returns the Tempfile
41
41
  # that contains the new image/video.
42
42
  def make
43
+ Ffmpeg.log("Making...") if @whiny
43
44
  src = @file
45
+ Ffmpeg.log("Building Destination File: '#{@basename}' + '#{@format}'") if @whiny
44
46
  dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
47
+ Ffmpeg.log("Destination File Built") if @whiny
45
48
  dst.binmode
46
49
 
47
50
  parameters = []
51
+
52
+ Ffmpeg.log("Adding Geometry") if @whiny
48
53
  # Add geometry
49
54
  if @geometry
55
+ Ffmpeg.log("Extracting Target Dimensions") if @whiny
50
56
  # Extract target dimensions
51
57
  if @geometry =~ /(\d*)x(\d*)/
52
58
  target_width = $1
@@ -54,30 +60,37 @@ module Paperclip
54
60
  end
55
61
  # Only calculate target dimensions if we have current dimensions
56
62
  unless @meta[:size].nil?
57
- current_geometry = @meta[:size].split('x')
63
+ Ffmpeg.log("Target Size is Available") if @whiny
64
+ current_width, current_height = @meta[:size].split('x')
58
65
  # Current width and height
59
- current_width = current_geometry[0]
60
- current_height = current_geometry[1]
61
66
  if @keep_aspect
67
+ Ffmpeg.log("Keeping Aspect Ratio") if @whiny
62
68
  if @enlarge_only
69
+ Ffmpeg.log("Enlarge Only") if @whiny
63
70
  if current_width.to_i < target_width.to_i
64
71
  # Keep aspect ratio
65
72
  width = target_width.to_i
66
73
  height = (width.to_f / (@meta[:aspect].to_f)).to_i
67
74
  @convert_options[:output][:s] = "#{width.to_i/2*2}x#{height.to_i/2*2}"
75
+ Ffmpeg.log("Convert Options: #{@convert_options[:output][:s]}") if @whiny
68
76
  else
69
- return nil
77
+ Ffmpeg.log("Source is Larger than Destination, Doing Nothing") if @whiny
78
+ #return nil
70
79
  end
71
80
  elsif @shrink_only
81
+ Ffmpeg.log("Shrink Only") if @whiny
72
82
  if current_width.to_i > target_width.to_i
73
83
  # Keep aspect ratio
74
84
  width = target_width.to_i
75
85
  height = (width.to_f / (@meta[:aspect].to_f)).to_i
76
86
  @convert_options[:output][:s] = "#{width.to_i/2*2}x#{height.to_i/2*2}"
87
+ Ffmpeg.log("Convert Options: #{@convert_options[:output][:s]}") if @whiny
77
88
  else
78
- return nil
89
+ Ffmpeg.log("Source is Smaller than Destination, Doing Nothing") if @whiny
90
+ #return nil
79
91
  end
80
92
  elsif @pad_only
93
+ Ffmpeg.log("Pad Only") if @whiny
81
94
  # Keep aspect ratio
82
95
  width = target_width.to_i
83
96
  height = (width.to_f / (@meta[:aspect].to_f)).to_i
@@ -88,18 +101,25 @@ module Paperclip
88
101
  else
89
102
  @convert_options[:output][:vf] = "scale=#{width}:-1,crop=#{width.to_i}:#{height.to_i}"
90
103
  end
104
+ Ffmpeg.log("Convert Options: #{@convert_options[:output][:s]}") if @whiny
91
105
  else
106
+ Ffmpeg.log("Resize") if @whiny
92
107
  # Keep aspect ratio
93
108
  width = target_width.to_i
94
109
  height = (width.to_f / (@meta[:aspect].to_f)).to_i
95
110
  @convert_options[:output][:s] = "#{width.to_i/2*2}x#{height.to_i/2*2}"
111
+ Ffmpeg.log("Convert Options: #{@convert_options[:output][:s]}") if @whiny
96
112
  end
97
113
  else
114
+ Ffmpeg.log("Not Keeping Aspect Ratio") if @whiny
98
115
  # Do not keep aspect ratio
99
116
  @convert_options[:output][:s] = "#{target_width.to_i/2*2}x#{target_height.to_i/2*2}"
117
+ Ffmpeg.log("Convert Options: #{@convert_options[:output][:s]}") if @whiny
100
118
  end
101
119
  end
102
120
  end
121
+
122
+ Ffmpeg.log("Adding Format") if @whiny
103
123
  # Add format
104
124
  case @format
105
125
  when 'jpg', 'jpeg', 'png', 'gif' # Images
@@ -107,20 +127,22 @@ module Paperclip
107
127
  @convert_options[:output][:vframes] = 1
108
128
  @convert_options[:output][:f] = 'image2'
109
129
  end
110
-
130
+
131
+ Ffmpeg.log("Adding Source") if @whiny
111
132
  # Add source
112
133
  parameters << @convert_options[:input].map { |k,v| "-#{k.to_s} #{v} "}
113
134
  parameters << "-i :source"
114
135
  parameters << @convert_options[:output].map { |k,v| "-#{k.to_s} #{v} "}
115
136
  parameters << ":dest"
116
137
 
138
+ Ffmpeg.log("Building Parameters") if @whiny
117
139
  parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
118
-
119
- Paperclip.log("[ffmpeg] #{parameters}")
140
+
141
+ Ffmpeg.log(parameters)
120
142
  begin
121
143
  success = Paperclip.run("ffmpeg", parameters, :source => "#{File.expand_path(src.path)}", :dest => File.expand_path(dst.path))
122
144
  rescue Cocaine::ExitStatusError => e
123
- raise PaperclipError, "error while processing video for #{@basename}: #{e}" if @whiny
145
+ raise Paperclip::Error, "error while processing video for #{@basename}: #{e}" if @whiny
124
146
  end
125
147
 
126
148
  dst
@@ -129,7 +151,7 @@ module Paperclip
129
151
  def identify
130
152
  meta = {}
131
153
  command = "ffmpeg -i \"#{File.expand_path(@file.path)}\" 2>&1"
132
- Paperclip.log(command)
154
+ Paperclip.log("[ffmpeg] #{command}")
133
155
  ffmpeg = IO.popen(command)
134
156
  ffmpeg.each("\r") do |line|
135
157
  if line =~ /((\d*)\s.?)fps,/
@@ -148,8 +170,14 @@ module Paperclip
148
170
  meta[:length] = $2.to_s + ":" + $3.to_s + ":" + $4.to_s
149
171
  end
150
172
  end
173
+ Paperclip.log("[ffmpeg] Command Success") if @whiny
151
174
  meta
152
175
  end
176
+
177
+
178
+ def self.log message
179
+ Paperclip.log "[ffmpeg] #{message}"
180
+ end
153
181
  end
154
182
 
155
183
  class Attachment
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "paperclip-ffmpeg"
6
- s.version = '0.9.1'
6
+ s.version = '0.9.3'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Omar Abdel-Wahab"]
9
9
  s.email = ["owahab@gmail.com"]
metadata CHANGED
@@ -1,72 +1,69 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: paperclip-ffmpeg
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
4
5
  prerelease:
5
- version: 0.9.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Omar Abdel-Wahab
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-08-15 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: paperclip
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 2.5.2
24
22
  type: :runtime
25
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.5.2
26
30
  description: Process your attachments with FFMPEG
27
- email:
31
+ email:
28
32
  - owahab@gmail.com
29
33
  executables: []
30
-
31
34
  extensions: []
32
-
33
35
  extra_rdoc_files: []
34
-
35
- files:
36
+ files:
36
37
  - .gitignore
37
38
  - Gemfile
38
39
  - README.md
39
40
  - Rakefile
40
41
  - lib/paperclip-ffmpeg.rb
41
- - lib/processors/ffmpeg.rb
42
- - lib/processors/qtfaststart.rb
42
+ - lib/paperclip_processors/ffmpeg.rb
43
+ - lib/paperclip_processors/qtfaststart.rb
43
44
  - paperclip-ffmpeg.gemspec
44
45
  homepage: http://github.com/owahab/paperclip-ffmpeg
45
46
  licenses: []
46
-
47
47
  post_install_message:
48
48
  rdoc_options: []
49
-
50
- require_paths:
49
+ require_paths:
51
50
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
51
+ required_ruby_version: !ruby/object:Gem::Requirement
53
52
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
58
- required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
58
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: "0"
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
64
63
  requirements: []
65
-
66
64
  rubyforge_project: paperclip-ffmpeg
67
65
  rubygems_version: 1.8.24
68
66
  signing_key:
69
67
  specification_version: 3
70
68
  summary: Process your attachments with FFMPEG
71
69
  test_files: []
72
-