paperclip-av-transcoder 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b96b030b3b02bf3b54a25b1a83941cecf68ae1
|
4
|
+
data.tar.gz: 488f2c30830a67a17f2d99517df1ed7ffafdd25f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 651815d9159d9b32ee83f9df60bca189b89bd482fce62077a93b12b448a7e1298461e5c87ab78b460f812a480d6b2e61fa18c7804542d7949fe3adc0820fb25e
|
7
|
+
data.tar.gz: 89b6a56b799aade2aab07399dcf46d7c49c81ce67f8dd6b009d50703583bc90fb7123224d1147bca76c4cbe9aa54ff379a499ef5b207d6cb8aae99cd266ac8d1
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ In your model:
|
|
34
34
|
has_attached_file :avatar, :styles => {
|
35
35
|
:medium => { :geometry => "640x480", :format => 'flv' },
|
36
36
|
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
|
37
|
-
}, :processors => [:
|
37
|
+
}, :processors => [:transcoder]
|
38
38
|
end
|
39
39
|
|
40
40
|
This will produce:
|
@@ -44,6 +44,13 @@ This will produce:
|
|
44
44
|
|
45
45
|
You may optionally add `<attachment>_meta` to your model and it will get populated with information about the processed video.
|
46
46
|
|
47
|
+
The geometry parameters are:
|
48
|
+
|
49
|
+
1. '!' - Keep the same aspect of the image/video, but with the passed dimesion.
|
50
|
+
2. '#' - Pad the image/video.
|
51
|
+
3. '<' - Enlarge the image/video.
|
52
|
+
4. '>' - Shrink the image/video.
|
53
|
+
|
47
54
|
## Contributing
|
48
55
|
|
49
56
|
1. Fork it ( https://github.com/ruby-av/paperclip-av-transcoder/fork )
|
@@ -11,6 +11,7 @@ module Paperclip
|
|
11
11
|
@file = file
|
12
12
|
@current_format = File.extname(@file.path)
|
13
13
|
@basename = File.basename(@file.path, @current_format)
|
14
|
+
@cli = ::Av.cli
|
14
15
|
@meta = ::Av.cli.identify(@file.path)
|
15
16
|
@whiny = options[:whiny].nil? ? true : options[:whiny]
|
16
17
|
|
@@ -38,39 +39,42 @@ module Paperclip
|
|
38
39
|
# Performs the transcoding of the +file+ into a thumbnail/video. Returns the Tempfile
|
39
40
|
# that contains the new image/video.
|
40
41
|
def make
|
41
|
-
::Av.
|
42
|
+
::Av.logger = Paperclip.logger
|
43
|
+
@cli.add_source @file
|
42
44
|
dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
|
43
45
|
dst.binmode
|
44
46
|
|
45
47
|
if @meta
|
46
48
|
log "Transocding supported file #{@file.path}"
|
47
|
-
cli
|
48
|
-
cli.
|
49
|
-
cli.
|
50
|
-
cli.reset_input_filters
|
49
|
+
@cli.add_source(@file.path)
|
50
|
+
@cli.add_destination(dst.path)
|
51
|
+
@cli.reset_input_filters
|
51
52
|
if @convert_options.present?
|
52
53
|
if @convert_options[:input]
|
53
54
|
@convert_options[:input].each do |h|
|
54
|
-
cli.add_input_param h
|
55
|
+
@cli.add_input_param h
|
55
56
|
end
|
56
57
|
end
|
57
58
|
if @convert_options[:output]
|
58
59
|
@convert_options[:output].each do |h|
|
59
|
-
cli.add_output_param h
|
60
|
+
@cli.add_output_param h
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
65
|
begin
|
65
|
-
cli.run
|
66
|
-
log "Successfully transcoded #{@
|
67
|
-
return dst
|
66
|
+
@cli.run
|
67
|
+
log "Successfully transcoded #{@basename} to #{dst}"
|
68
68
|
rescue Cocaine::ExitStatusError => e
|
69
69
|
raise Paperclip::Error, "error while transcoding #{@basename}: #{e}" if @whiny
|
70
70
|
end
|
71
|
+
else
|
72
|
+
log "Unsupported file #{@file.path}"
|
73
|
+
# If the file is not supported, just return it
|
74
|
+
dst << @file.read
|
75
|
+
dst.close
|
71
76
|
end
|
72
|
-
|
73
|
-
@file
|
77
|
+
dst
|
74
78
|
end
|
75
79
|
|
76
80
|
def log message
|
@@ -7,7 +7,7 @@ describe Paperclip::Transcoder do
|
|
7
7
|
let(:destination) { Pathname.new("#{Dir.tmpdir}/transcoder/") }
|
8
8
|
|
9
9
|
describe "supported formats" do
|
10
|
-
let(:subject) { Paperclip::
|
10
|
+
let(:subject) { Paperclip::Transcoder.new(supported) }
|
11
11
|
let(:document) { Document.create(video: Rack::Test::UploadedFile.new(supported, 'video/mp4')) }
|
12
12
|
|
13
13
|
describe ".transcode" do
|
@@ -16,7 +16,7 @@ describe Paperclip::Transcoder do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "unsupported formats" do
|
19
|
-
let(:subject) { Paperclip::
|
19
|
+
let(:subject) { Paperclip::Transcoder.new(unsupported) }
|
20
20
|
let(:document) { Document.create(image: Rack::Test::UploadedFile.new(unsupported, 'image/png')) }
|
21
21
|
describe ".transcode" do
|
22
22
|
it { expect(File.exists?(document.image.path(:small))).to eq true }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-av-transcoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Abdel-Wahab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.7.1
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.7.1
|
125
125
|
description: Audio/Video Transcoder for Paperclip using FFMPEG/Avconv
|
126
126
|
email:
|
127
127
|
- owahab@gmail.com
|