one-k-rmov 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +38 -0
- data/LICENSE +20 -0
- data/Manifest +24 -0
- data/README.rdoc +73 -0
- data/Rakefile +16 -0
- data/TODO +15 -0
- data/ext/exporter.c +195 -0
- data/ext/extconf.rb +4 -0
- data/ext/movie.c +457 -0
- data/ext/rmov_ext.c +16 -0
- data/ext/rmov_ext.h +45 -0
- data/ext/track.c +391 -0
- data/lib/quicktime/exporter.rb +10 -0
- data/lib/quicktime/movie.rb +102 -0
- data/lib/quicktime/track.rb +31 -0
- data/lib/rmov.rb +12 -0
- data/rmov.gemspec +32 -0
- data/spec/fixtures/settings.st +0 -0
- data/spec/quicktime/exporter_spec.rb +29 -0
- data/spec/quicktime/movie_spec.rb +189 -0
- data/spec/quicktime/track_spec.rb +86 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +7 -0
- data/tasks/setup.rake +7 -0
- data/tasks/spec.rake +9 -0
- metadata +98 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe QuickTime::Movie do
|
4
|
+
it "should raise an exception when attempting to open a nonexisting file" do
|
5
|
+
lambda { QuickTime::Movie.open('foo.mov') }.should raise_error(QuickTime::Error)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should raise an exception when attempting to open a non movie file" do
|
9
|
+
lambda { QuickTime::Movie.open(__FILE__) }.should raise_error(QuickTime::Error)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "example.mov" do
|
13
|
+
before(:each) do
|
14
|
+
@movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "duration should be 3.1 seconds" do
|
18
|
+
@movie.duration.should == 3.1
|
19
|
+
end
|
20
|
+
|
21
|
+
it "bounds should be a hash of top, left, bottom, and right points" do
|
22
|
+
@movie.bounds.should == { :top => 0, :left => 0, :bottom => 50, :right => 60 }
|
23
|
+
end
|
24
|
+
|
25
|
+
it "width should be 60" do
|
26
|
+
@movie.width.should == 60
|
27
|
+
end
|
28
|
+
|
29
|
+
it "height should be 50" do
|
30
|
+
@movie.height.should == 50
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have 2 tracks" do
|
34
|
+
@movie.tracks.map { |t| t.class }.should == [QuickTime::Track, QuickTime::Track]
|
35
|
+
@movie.tracks.map { |t| t.id }.should == [1, 2]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be able to export into separate file" do
|
39
|
+
path = File.dirname(__FILE__) + '/../output/exported_example.mov'
|
40
|
+
File.delete(path) rescue nil
|
41
|
+
|
42
|
+
progress = 0
|
43
|
+
@movie.export(path) { |p| progress = p }
|
44
|
+
progress.should == 1.0
|
45
|
+
|
46
|
+
exported_movie = QuickTime::Movie.open(path)
|
47
|
+
exported_movie.duration.should == @movie.duration
|
48
|
+
exported_movie.tracks.size == @movie.tracks.size
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have one audio track" do
|
52
|
+
@movie.audio_tracks.should have(1).record
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have one video track" do
|
56
|
+
@movie.video_tracks.should have(1).record
|
57
|
+
end
|
58
|
+
|
59
|
+
it "composite should add another movie's tracks at a given location" do
|
60
|
+
m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
|
61
|
+
@movie.composite_movie(m2, 2)
|
62
|
+
@movie.duration.should == 5.1
|
63
|
+
end
|
64
|
+
|
65
|
+
it "insert should insert another movie's tracks at a given location" do
|
66
|
+
m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
|
67
|
+
@movie.insert_movie(m2, 2)
|
68
|
+
@movie.duration.should == 6.2
|
69
|
+
end
|
70
|
+
|
71
|
+
it "append_movie should insert movie at the end" do
|
72
|
+
m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
|
73
|
+
@movie.append_movie(m2)
|
74
|
+
@movie.duration.should == 6.2
|
75
|
+
end
|
76
|
+
|
77
|
+
it "delete_section should remove a section from a movie" do
|
78
|
+
@movie.delete_section(1, 0.6)
|
79
|
+
@movie.duration.should == 2.5
|
80
|
+
end
|
81
|
+
|
82
|
+
it "clone_section should make a new movie from given section and leave existing movie intact" do
|
83
|
+
mov = @movie.clone_section(1, 0.6)
|
84
|
+
mov.duration.should == 0.6
|
85
|
+
@movie.duration.should == 3.1
|
86
|
+
end
|
87
|
+
|
88
|
+
it "clip_section should make a new movie from given section and remove it form existing movie" do
|
89
|
+
mov = @movie.clip_section(1, 0.6)
|
90
|
+
mov.duration.should == 0.6
|
91
|
+
@movie.duration.should == 2.5
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should have an exporter with this movie" do
|
95
|
+
exporter = @movie.exporter
|
96
|
+
exporter.should be_kind_of(QuickTime::Exporter)
|
97
|
+
exporter.movie.should == @movie
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should say when movie has changed" do
|
101
|
+
@movie.should_not be_changed
|
102
|
+
@movie.delete_section(1, 0.6)
|
103
|
+
@movie.should be_changed
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should be able to clear changed status" do
|
107
|
+
@movie.delete_section(1, 0.6)
|
108
|
+
@movie.clear_changed_status
|
109
|
+
@movie.should_not be_changed
|
110
|
+
end
|
111
|
+
|
112
|
+
it "flatten should save movie into file" do
|
113
|
+
path = File.dirname(__FILE__) + '/../output/flattened_example.mov'
|
114
|
+
File.delete(path) rescue nil
|
115
|
+
@movie.flatten(path)
|
116
|
+
mov = QuickTime::Movie.open(path)
|
117
|
+
mov.duration.should == 3.1
|
118
|
+
end
|
119
|
+
|
120
|
+
it "export_pict should output a pict file at a given duration" do
|
121
|
+
path = File.dirname(__FILE__) + '/../output/example.pct'
|
122
|
+
File.delete(path) rescue nil
|
123
|
+
@movie.export_image(path, 1.2)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "export_png should output a png file at a given duration" do
|
127
|
+
path = File.dirname(__FILE__) + '/../output/example.png'
|
128
|
+
File.delete(path) rescue nil
|
129
|
+
@movie.export_image(path, 1.2)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should default poster time to 0" do
|
133
|
+
@movie.poster_time.should == 0
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should be able to set poster time to 2.1 seconds in" do
|
137
|
+
@movie.poster_time = 2.1
|
138
|
+
@movie.poster_time.should == 2.1
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "empty movie" do
|
143
|
+
before(:each) do
|
144
|
+
@movie = QuickTime::Movie.empty
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should have 0 duration" do
|
148
|
+
@movie.duration.should == 0
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should be able to append an existing movie" do
|
152
|
+
m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
|
153
|
+
@movie.append_movie(m2)
|
154
|
+
@movie.duration.should == 3.1
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should raise MovieAlreadyLoaded exception when attempting to load it again" do
|
158
|
+
lambda { @movie.load_empty }.should raise_error(QuickTime::Error)
|
159
|
+
lambda { @movie.load_from_file('example.mov') }.should raise_error(QuickTime::Error)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be able to create a new track" do
|
163
|
+
track = @movie.new_track(300, 500)
|
164
|
+
track.should be_kind_of(QuickTime::Track)
|
165
|
+
@movie.tracks.should have(1).record
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should be able to create a new video track" do
|
169
|
+
track = @movie.new_video_track(300, 500)
|
170
|
+
track.should be_kind_of(QuickTime::Track)
|
171
|
+
track.should be_video
|
172
|
+
@movie.video_tracks.should have(1).record
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should be able to create a new audio track" do
|
176
|
+
track = @movie.new_audio_track(300, 500)
|
177
|
+
track.should be_kind_of(QuickTime::Track)
|
178
|
+
track.should be_audio
|
179
|
+
@movie.audio_tracks.should have(1).record
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should be able to create a new text track" do
|
183
|
+
track = @movie.new_text_track(300, 500)
|
184
|
+
track.should be_kind_of(QuickTime::Track)
|
185
|
+
track.should be_text
|
186
|
+
@movie.text_tracks.should have(1).record
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe QuickTime::Track do
|
4
|
+
describe "example.mov" do
|
5
|
+
before(:each) do
|
6
|
+
@movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "example.mov video track" do
|
10
|
+
before(:each) do
|
11
|
+
@track = @movie.video_tracks.first
|
12
|
+
end
|
13
|
+
|
14
|
+
it "duration should be 3.1 seconds" do
|
15
|
+
@track.duration.should == 3.1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "frame count should be 31" do
|
19
|
+
@track.frame_count.should == 31
|
20
|
+
end
|
21
|
+
|
22
|
+
it "frame rate should be 10" do
|
23
|
+
@track.frame_rate.should == 10
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a codec of H.264" do
|
27
|
+
@track.codec.should == "H.264"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a codec of nil, if audio" do
|
31
|
+
t = @movie.audio_tracks.first
|
32
|
+
t.codec.should == nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have a width of 60" do
|
36
|
+
@track.width.should == 60
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a height of 50" do
|
40
|
+
@track.height.should == 50
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should be able to delete a track" do
|
44
|
+
@track.delete
|
45
|
+
@movie.video_tracks.should == []
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be able to add a track" do
|
49
|
+
@track.delete
|
50
|
+
@movie.video_tracks.should == []
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to disable and enable a track" do
|
54
|
+
@track.should be_enabled
|
55
|
+
@track.disable
|
56
|
+
@track.should_not be_enabled
|
57
|
+
@track.enable
|
58
|
+
@track.should be_enabled
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should have no offset" do
|
62
|
+
@track.offset.should == 0
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be able to offset by 2.5 seconds" do
|
66
|
+
@track.offset = 2.5
|
67
|
+
@track.offset.should == 2.5
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "example.mov audio track" do
|
72
|
+
before(:each) do
|
73
|
+
@track = @movie.audio_tracks.first
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should have a volume of 1.0" do
|
77
|
+
@track.volume.should == 1.0
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should be able to set volume to 0.5" do
|
81
|
+
@track.volume = 0.5
|
82
|
+
@track.volume.should == 0.5
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
data/tasks/setup.rake
ADDED
data/tasks/spec.rake
ADDED
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: one-k-rmov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Bates
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-24 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ruby wrapper for the QuickTime C API.
|
17
|
+
email: ryan (at) railscasts (dot) com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- CHANGELOG
|
24
|
+
- ext/exporter.c
|
25
|
+
- ext/extconf.rb
|
26
|
+
- ext/movie.c
|
27
|
+
- ext/rmov_ext.c
|
28
|
+
- ext/rmov_ext.h
|
29
|
+
- ext/track.c
|
30
|
+
- lib/quicktime/exporter.rb
|
31
|
+
- lib/quicktime/movie.rb
|
32
|
+
- lib/quicktime/track.rb
|
33
|
+
- lib/rmov.rb
|
34
|
+
- LICENSE
|
35
|
+
- README.rdoc
|
36
|
+
- tasks/setup.rake
|
37
|
+
- tasks/spec.rake
|
38
|
+
- TODO
|
39
|
+
files:
|
40
|
+
- CHANGELOG
|
41
|
+
- ext/exporter.c
|
42
|
+
- ext/extconf.rb
|
43
|
+
- ext/movie.c
|
44
|
+
- ext/rmov_ext.c
|
45
|
+
- ext/rmov_ext.h
|
46
|
+
- ext/track.c
|
47
|
+
- lib/quicktime/exporter.rb
|
48
|
+
- lib/quicktime/movie.rb
|
49
|
+
- lib/quicktime/track.rb
|
50
|
+
- lib/rmov.rb
|
51
|
+
- LICENSE
|
52
|
+
- Manifest
|
53
|
+
- Rakefile
|
54
|
+
- README.rdoc
|
55
|
+
- spec/fixtures/settings.st
|
56
|
+
- spec/quicktime/exporter_spec.rb
|
57
|
+
- spec/quicktime/movie_spec.rb
|
58
|
+
- spec/quicktime/track_spec.rb
|
59
|
+
- spec/spec.opts
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- tasks/setup.rake
|
62
|
+
- tasks/spec.rake
|
63
|
+
- TODO
|
64
|
+
- rmov.gemspec
|
65
|
+
has_rdoc: true
|
66
|
+
homepage: http://github.com/ryanb/rmov
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --line-numbers
|
70
|
+
- --inline-source
|
71
|
+
- --title
|
72
|
+
- Rmov
|
73
|
+
- --main
|
74
|
+
- README.rdoc
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
- ext
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "1.2"
|
89
|
+
version:
|
90
|
+
requirements: []
|
91
|
+
|
92
|
+
rubyforge_project: rmov
|
93
|
+
rubygems_version: 1.2.0
|
94
|
+
signing_key:
|
95
|
+
specification_version: 2
|
96
|
+
summary: Ruby wrapper for the QuickTime C API.
|
97
|
+
test_files: []
|
98
|
+
|