paperclip-ffmpeg 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/paperclip-ffmpeg.rb +14 -12
- data/lib/paperclip-ffmpeg/version.rb +1 -1
- metadata +2 -2
data/lib/paperclip-ffmpeg.rb
CHANGED
@@ -47,17 +47,19 @@ module Paperclip
|
|
47
47
|
target_width = $1
|
48
48
|
target_height = $2
|
49
49
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
unless @meta[:size].nil?
|
51
|
+
current_geometry = @meta[:size].split('x')
|
52
|
+
current_width = current_geometry[0]
|
53
|
+
current_height = current_geometry[1]
|
54
|
+
if @keep_aspect
|
55
|
+
# Correct size to keep aspect
|
56
|
+
if current_width.to_i > target_width.to_i
|
57
|
+
# Scaling down
|
58
|
+
width = target_width.to_i
|
59
|
+
height = (width.to_f / (@meta[:aspect].to_f)).to_i
|
60
|
+
else
|
61
|
+
# TODO: Padding
|
62
|
+
end
|
61
63
|
end
|
62
64
|
@convert_options[:s] = "#{width.to_i}x#{height.to_i}" unless width.nil? || height.nil?
|
63
65
|
else
|
@@ -96,7 +98,7 @@ module Paperclip
|
|
96
98
|
meta[:fps] = $1.to_i
|
97
99
|
end
|
98
100
|
# Matching lines like:
|
99
|
-
# Video:
|
101
|
+
# Video: h264, yuvj420p, 640x480 [PAR 72:72 DAR 4:3], 10301 kb/s, 30 fps, 30 tbr, 600 tbn, 600 tbc
|
100
102
|
if line =~ /Video:(\s.?(\w*),\s.?(\w*),\s(\d*x\d*)\s.?PAR\s.?(\d*):(\d*)\s.?DAR\s(\d*):(\d*))/
|
101
103
|
meta[:size] = $4
|
102
104
|
meta[:aspect] = $7.to_f / $8.to_f
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: paperclip-ffmpeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Omar Abdel-Wahab
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-05 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|