dragonfly-ffmpeg 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,6 +28,11 @@ module EnMasse
|
|
|
28
28
|
e.output_directory = opts[:output_directory] if opts.has_key?(:output_directory)
|
|
29
29
|
e.encoder_profiles = opts[:encoder_profiles] if opts.has_key?(:encoder_profiles)
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
c.job :html5 do |format, options|
|
|
33
|
+
options = options || {}
|
|
34
|
+
encode(format, :html5, options)
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
end
|
|
33
38
|
|
|
@@ -29,7 +29,7 @@ module EnMasse
|
|
|
29
29
|
|
|
30
30
|
configurable_attr :encoder_profiles, {
|
|
31
31
|
:mp4 => [
|
|
32
|
-
Profile.new(:
|
|
32
|
+
Profile.new(:html5,
|
|
33
33
|
:video_codec => "libx264",
|
|
34
34
|
:resolution => "1280x720",
|
|
35
35
|
:frame_rate => 29.97,
|
|
@@ -41,7 +41,7 @@ module EnMasse
|
|
|
41
41
|
)
|
|
42
42
|
],
|
|
43
43
|
:ogv => [
|
|
44
|
-
Profile.new(:
|
|
44
|
+
Profile.new(:html5,
|
|
45
45
|
:video_codec => "libtheora",
|
|
46
46
|
:resolution => "1280x720",
|
|
47
47
|
:frame_rate => 29.97,
|
|
@@ -52,7 +52,7 @@ module EnMasse
|
|
|
52
52
|
)
|
|
53
53
|
],
|
|
54
54
|
:webm => [
|
|
55
|
-
Profile.new(:
|
|
55
|
+
Profile.new(:html5,
|
|
56
56
|
:video_codec => "libvpx",
|
|
57
57
|
:resolution => "1280x720",
|
|
58
58
|
:frame_rate => 29.97,
|
|
@@ -67,25 +67,31 @@ module EnMasse
|
|
|
67
67
|
|
|
68
68
|
configurable_attr :output_directory, '/tmp'
|
|
69
69
|
|
|
70
|
-
def encode(temp_object, format,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
raise UnknownEncoderProfile unless profile_defined?(format,
|
|
75
|
-
profile = get_profile(format,
|
|
70
|
+
def encode(temp_object, format, profile = :html5, options = {})
|
|
71
|
+
format = format.to_sym
|
|
72
|
+
raise UnsupportedFormat, "Format not supported - #{format}" unless supported_format?(format)
|
|
73
|
+
unless profile.is_a?(Profile)
|
|
74
|
+
raise UnknownEncoderProfile unless profile_defined?(format, profile.to_sym)
|
|
75
|
+
profile = get_profile(format, profile.to_sym)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
options.merge!(profile.encoding_options)
|
|
79
79
|
|
|
80
80
|
origin = ::FFMPEG::Movie.new(temp_object.path)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
transcoded
|
|
84
|
-
::Dragonfly::TempObject.new(File.read(transcoded.path))
|
|
81
|
+
tempfile = new_tempfile(format)
|
|
82
|
+
transcoded = origin.transcode(tempfile.path, options)
|
|
83
|
+
::Dragonfly::TempObject.new(File.new(transcoded.path))
|
|
85
84
|
end
|
|
86
|
-
|
|
85
|
+
|
|
87
86
|
private
|
|
88
87
|
|
|
88
|
+
def new_tempfile(ext = nil)
|
|
89
|
+
tempfile = ext ? Tempfile.new(["dragonfy-video", ".#{ext}"]) : Tempfile.new("dragonfly-video")
|
|
90
|
+
tempfile.binmode
|
|
91
|
+
tempfile.close
|
|
92
|
+
tempfile
|
|
93
|
+
end
|
|
94
|
+
|
|
89
95
|
def profiles(format)
|
|
90
96
|
encoder_profiles[format]
|
|
91
97
|
end
|
|
@@ -95,6 +101,10 @@ module EnMasse
|
|
|
95
101
|
result.first
|
|
96
102
|
end
|
|
97
103
|
|
|
104
|
+
def supported_format?(format)
|
|
105
|
+
encoder_profiles.has_key?(format)
|
|
106
|
+
end
|
|
107
|
+
|
|
98
108
|
def profile_defined?(format, profile_name)
|
|
99
109
|
return false if profiles(format).nil?
|
|
100
110
|
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: dragonfly-ffmpeg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.0.
|
|
5
|
+
version: 0.0.4
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Jamie Winsor
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-07-
|
|
13
|
+
date: 2011-07-14 00:00:00 -07:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|