bulldog 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/VERSION +1 -1
- data/bulldog.gemspec +2 -2
- data/lib/bulldog/processor/ffmpeg.rb +10 -12
- data/spec/unit/processor/ffmpeg_spec.rb +20 -6
- metadata +2 -2
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/bulldog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bulldog}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["George Ogata"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-18}
|
13
13
|
s.description = %q{= Bulldog
|
14
14
|
|
15
15
|
Flexible file attachments for active record.
|
@@ -7,7 +7,6 @@ module Bulldog
|
|
7
7
|
|
8
8
|
def initialize(*args)
|
9
9
|
super
|
10
|
-
@operation = nil
|
11
10
|
@arguments = style_list_map
|
12
11
|
@still_frame_callbacks = style_list_map
|
13
12
|
end
|
@@ -15,13 +14,14 @@ module Bulldog
|
|
15
14
|
def process
|
16
15
|
return if styles.empty?
|
17
16
|
super
|
18
|
-
run_ffmpeg
|
19
17
|
run_still_frame_callbacks
|
20
18
|
end
|
21
19
|
|
22
20
|
def process_style(*args)
|
21
|
+
@operation = nil
|
23
22
|
super
|
24
|
-
|
23
|
+
set_default_operation
|
24
|
+
run_ffmpeg
|
25
25
|
end
|
26
26
|
|
27
27
|
def use_threads(num_threads)
|
@@ -37,6 +37,7 @@ module Bulldog
|
|
37
37
|
style_option '-acodec', params[:audio_codec]
|
38
38
|
preset_option '-vpre', params[:video_preset]
|
39
39
|
preset_option '-apre', params[:audio_preset]
|
40
|
+
preset_option '-spre', params[:subtitle_preset]
|
40
41
|
operate '-s', attachment.dimensions(style.name).join('x') if params[:size]
|
41
42
|
style_option '-r', params[:frame_rate]
|
42
43
|
style_option '-b', params[:video_bit_rate]
|
@@ -50,7 +51,6 @@ module Bulldog
|
|
50
51
|
style_option '-coder', params[:coder]
|
51
52
|
style_option '-v', params[:verbosity]
|
52
53
|
style_option '-flags', params[:flags]
|
53
|
-
preset_option '-spre', params[:subtitle_preset]
|
54
54
|
style_option '-y', output_file(style.name)
|
55
55
|
end
|
56
56
|
|
@@ -91,7 +91,7 @@ module Bulldog
|
|
91
91
|
@arguments[style].concat args.map(&:to_s)
|
92
92
|
end
|
93
93
|
|
94
|
-
def
|
94
|
+
def set_default_operation
|
95
95
|
encode if @operation.nil?
|
96
96
|
end
|
97
97
|
|
@@ -152,13 +152,11 @@ module Bulldog
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def run_ffmpeg
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
record.errors.add name, "convert failed (status #$?)"
|
161
|
-
end
|
155
|
+
command = [self.class.ffmpeg_path]
|
156
|
+
command << '-i' << input_file
|
157
|
+
command.concat(@arguments[style])
|
158
|
+
Bulldog.run(*command) or
|
159
|
+
record.errors.add name, "convert failed (status #$?)"
|
162
160
|
end
|
163
161
|
|
164
162
|
def run_still_frame_callbacks
|
@@ -29,8 +29,8 @@ describe Processor::Ffmpeg do
|
|
29
29
|
"#{temporary_directory}/video.original.mov"
|
30
30
|
end
|
31
31
|
|
32
|
-
def output_video_path
|
33
|
-
"#{temporary_directory}/video.
|
32
|
+
def output_video_path(style=:output)
|
33
|
+
"#{temporary_directory}/video.#{style}.mov"
|
34
34
|
end
|
35
35
|
|
36
36
|
def original_frame_path
|
@@ -55,16 +55,14 @@ describe Processor::Ffmpeg do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "#process" do
|
58
|
-
before do
|
59
|
-
video_style :output
|
60
|
-
end
|
61
|
-
|
62
58
|
it "should run ffmpeg" do
|
59
|
+
video_style :output
|
63
60
|
Bulldog.expects(:run).once.with(ffmpeg, '-i', original_video_path, '-y', output_video_path)
|
64
61
|
process_video
|
65
62
|
end
|
66
63
|
|
67
64
|
it "should log the command run" do
|
65
|
+
video_style :output
|
68
66
|
log_path = "#{temporary_directory}/log"
|
69
67
|
open(log_path, 'w') do |file|
|
70
68
|
Bulldog.logger = Logger.new(file)
|
@@ -95,6 +93,14 @@ describe Processor::Ffmpeg do
|
|
95
93
|
process_video{encode}
|
96
94
|
end
|
97
95
|
|
96
|
+
it "should run ffmpeg once for each style" do
|
97
|
+
video_style :one
|
98
|
+
video_style :two
|
99
|
+
Bulldog.expects(:run).once.with(ffmpeg, '-i', original_video_path, '-y', output_video_path(:one))
|
100
|
+
Bulldog.expects(:run).once.with(ffmpeg, '-i', original_video_path, '-y', output_video_path(:two))
|
101
|
+
process_video
|
102
|
+
end
|
103
|
+
|
98
104
|
it "should allow overriding style attributes from parameters" do
|
99
105
|
video_style :output, :video_codec => 'libx264'
|
100
106
|
Bulldog.expects(:run).once.with(ffmpeg, '-i', original_video_path, '-vcodec', 'libtheora', '-y', output_video_path)
|
@@ -216,6 +222,14 @@ describe Processor::Ffmpeg do
|
|
216
222
|
end
|
217
223
|
|
218
224
|
describe "encoding style attributes" do
|
225
|
+
it "should add arguments for style attributes to the relevant invocation" do
|
226
|
+
video_style :one, :verbosity => 1
|
227
|
+
video_style :two, :verbosity => 2
|
228
|
+
Bulldog.expects(:run).once.with(ffmpeg, '-i', original_video_path, '-v', '1', '-y', output_video_path(:one))
|
229
|
+
Bulldog.expects(:run).once.with(ffmpeg, '-i', original_video_path, '-v', '2', '-y', output_video_path(:two))
|
230
|
+
process_video{encode}
|
231
|
+
end
|
232
|
+
|
219
233
|
describe "video" do
|
220
234
|
it "should interpret '30fps' as a frame rate of 30fps" do
|
221
235
|
video_style :output, :video => '30fps'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulldog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Ogata
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-18 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|