paperclip-ffmpeg 0.9.4 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -1
- data/README.md +22 -14
- data/Rakefile +4 -0
- data/lib/paperclip_processors/ffmpeg.rb +9 -5
- data/paperclip-ffmpeg.gemspec +1 -2
- metadata +8 -18
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -17,26 +17,32 @@ directory to its path.
|
|
17
17
|
|
18
18
|
In development mode, you might add this line to `config/environments/development.rb)`:
|
19
19
|
|
20
|
-
|
20
|
+
```ruby
|
21
|
+
Paperclip.options[:command_path] = "/usr/local/bin/"
|
22
|
+
```
|
21
23
|
|
22
24
|
Installation
|
23
25
|
------------
|
24
26
|
|
25
27
|
Include the gem in your Gemfile:
|
26
28
|
|
27
|
-
|
29
|
+
```ruby
|
30
|
+
gem "paperclip-ffmpeg"
|
31
|
+
```
|
28
32
|
|
29
33
|
Quick Start
|
30
34
|
-----------
|
31
35
|
|
32
36
|
In your model:
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
```ruby
|
39
|
+
class User < ActiveRecord::Base
|
40
|
+
has_attached_file :avatar, :styles => {
|
41
|
+
:medium => { :geometry => "640x480", :format => 'flv' }
|
42
|
+
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
|
43
|
+
}, :processors => [:ffmpeg]
|
44
|
+
end
|
45
|
+
```
|
40
46
|
|
41
47
|
This will produce:
|
42
48
|
|
@@ -52,15 +58,17 @@ When ffmpeg produces mp4 files, it places the moov atom at the end which makes i
|
|
52
58
|
|
53
59
|
In your model:
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
```ruby
|
62
|
+
class Lesson < ActiveRecord::Base
|
63
|
+
has_attached_file :video, :styles => {
|
64
|
+
:mobile => {:geometry => "400x300", :format => 'mp4', :streaming => true}
|
65
|
+
}, :processors => [:ffmpeg, :qtfaststart]
|
66
|
+
end
|
67
|
+
```
|
60
68
|
|
61
69
|
See [danielgtaylor/qtfaststart](https://github.com/danielgtaylor/qtfaststart) for instructions on how to setup qtfaststart.
|
62
70
|
|
63
71
|
License
|
64
72
|
-------
|
65
73
|
|
66
|
-
Licensed under BSD license.
|
74
|
+
Licensed under BSD license.
|
data/Rakefile
CHANGED
@@ -96,10 +96,13 @@ module Paperclip
|
|
96
96
|
height = (width.to_f / (@meta[:aspect].to_f)).to_i
|
97
97
|
# We should add half the delta as a padding offset Y
|
98
98
|
pad_y = (target_height.to_f - height.to_f) / 2
|
99
|
+
# There could be options already set
|
100
|
+
@convert_options[:output][:vf][/\A/] = ',' if @convert_options[:output][:vf]
|
101
|
+
@convert_options[:output][:vf] ||= ''
|
99
102
|
if pad_y > 0
|
100
|
-
@convert_options[:output][:vf] = "scale=#{width}:-1,pad=#{width.to_i}:#{target_height.to_i}:0:#{pad_y}:#@pad_color"
|
103
|
+
@convert_options[:output][:vf][/\A/] = "scale=#{width}:-1,pad=#{width.to_i}:#{target_height.to_i}:0:#{pad_y}:#@pad_color"
|
101
104
|
else
|
102
|
-
@convert_options[:output][:vf] = "scale=#{width}:-1,crop=#{width.to_i}:#{height.to_i}"
|
105
|
+
@convert_options[:output][:vf][/\A/] = "scale=#{width}:-1,crop=#{width.to_i}:#{height.to_i}"
|
103
106
|
end
|
104
107
|
Ffmpeg.log("Convert Options: #{@convert_options[:output][:s]}") if @whiny
|
105
108
|
else
|
@@ -130,10 +133,11 @@ module Paperclip
|
|
130
133
|
|
131
134
|
Ffmpeg.log("Adding Source") if @whiny
|
132
135
|
# Add source
|
133
|
-
|
136
|
+
# Validations on the values. These could be either nil.
|
137
|
+
parameters << @convert_options[:input].map { |k,v| "-#{k.to_s} #{v} " if !v.nil? && (v.is_a?(Numeric) || !v.empty?) }
|
134
138
|
parameters << "-i :source"
|
135
|
-
parameters << @convert_options[:output].map { |k,v| "-#{k.to_s} #{v} "}
|
136
|
-
parameters << ":dest"
|
139
|
+
parameters << @convert_options[:output].map { |k,v| "-#{k.to_s} #{v} " if !v.nil? && (v.is_a?(Numeric) || !v.empty?) }
|
140
|
+
parameters << "-y :dest"
|
137
141
|
|
138
142
|
Ffmpeg.log("Building Parameters") if @whiny
|
139
143
|
parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
|
data/paperclip-ffmpeg.gemspec
CHANGED
@@ -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.
|
6
|
+
s.version = '0.10.0'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Omar Abdel-Wahab"]
|
9
9
|
s.email = ["owahab@gmail.com"]
|
@@ -19,5 +19,4 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_dependency('paperclip', '>=2.5.2')
|
22
|
-
s.add_dependency('paperclip', '>=0.9.2')
|
23
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-ffmpeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.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:
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 2.5.2
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: paperclip
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.9.2
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.9.2
|
46
30
|
description: Process your attachments with FFMPEG
|
47
31
|
email:
|
48
32
|
- owahab@gmail.com
|
@@ -70,12 +54,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
54
|
- - ! '>='
|
71
55
|
- !ruby/object:Gem::Version
|
72
56
|
version: '0'
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
hash: -1147482643793522172
|
73
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
61
|
none: false
|
75
62
|
requirements:
|
76
63
|
- - ! '>='
|
77
64
|
- !ruby/object:Gem::Version
|
78
65
|
version: '0'
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
hash: -1147482643793522172
|
79
69
|
requirements: []
|
80
70
|
rubyforge_project: paperclip-ffmpeg
|
81
71
|
rubygems_version: 1.8.24
|