marcandre-flvedit 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -38,8 +38,8 @@ begin
38
38
  EOS
39
39
  gem.authors = ["Marc-André Lafortune"]
40
40
  gem.rubyforge_project = "flvedit"
41
- gem.add_dependency "packable", ">=1.2"
42
- gem.add_dependency "backports", ">=1.6.8"
41
+ gem.add_dependency "packable", ">=1.3.2"
42
+ gem.add_dependency "backports", ">=1.7.1"
43
43
  gem.has_rdoc = true
44
44
  gem.rdoc_options << '--title' << 'FLV::Edit' <<
45
45
  '--main' << 'README.rdoc' <<
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 7
4
- :patch: 0
4
+ :patch: 1
data/flvedit.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{flvedit}
5
- s.version = "0.7.0"
5
+ s.version = "0.7.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marc-Andr\303\251 Lafortune"]
9
- s.date = %q{2009-08-18}
9
+ s.date = %q{2009-08-20}
10
10
  s.default_executable = %q{flvedit}
11
11
  s.description = %q{flvedit allows you to: * compute metadata for FLV files * merge, split or cut FLVs * insert / remote cue points or other events flvedit is meant as a replacement for FLVTool2, FLVMeta, FLVTool++ It can be used as a command line tool or as a Ruby library.}
12
12
  s.email = %q{github@marc-andre.ca}
@@ -97,14 +97,14 @@ Gem::Specification.new do |s|
97
97
  s.specification_version = 2
98
98
 
99
99
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
100
- s.add_runtime_dependency(%q<packable>, [">= 1.2"])
101
- s.add_runtime_dependency(%q<backports>, [">= 1.6.8"])
100
+ s.add_runtime_dependency(%q<packable>, [">= 1.3.2"])
101
+ s.add_runtime_dependency(%q<backports>, [">= 1.7.1"])
102
102
  else
103
- s.add_dependency(%q<packable>, [">= 1.2"])
104
- s.add_dependency(%q<backports>, [">= 1.6.8"])
103
+ s.add_dependency(%q<packable>, [">= 1.3.2"])
104
+ s.add_dependency(%q<backports>, [">= 1.7.1"])
105
105
  end
106
106
  else
107
- s.add_dependency(%q<packable>, [">= 1.2"])
108
- s.add_dependency(%q<backports>, [">= 1.6.8"])
107
+ s.add_dependency(%q<packable>, [">= 1.3.2"])
108
+ s.add_dependency(%q<backports>, [">= 1.7.1"])
109
109
  end
110
110
  end
@@ -17,7 +17,7 @@ module FLV
17
17
 
18
18
  TYPE_TO_CLASS = Hash.new do |h, type|
19
19
  #EndOfList
20
- raise IOError, "Invalid type for a flash variable. #{type.inspect} is not in #{h.keys.sort.inspect}" #todo: handle error for corrupted da
20
+ raise IOError, "Invalid type for a flash variable. #{type.inspect} is not in #{h.keys}" #todo: handle error for corrupted da
21
21
  end.merge!(
22
22
  0 => Numeric ,
23
23
  1 => TrueClass , # There really should be a Boolean class!
@@ -110,7 +110,14 @@ module FLV
110
110
  packer.read do |io|
111
111
  Hash[
112
112
  io.each([String, :flv], :flv_value).
113
- take_while {|str, val| val != EndOfList.instance }.
113
+ # take_while {|str, val| val != EndOfList.instance }.
114
+ take_while do |str, val|
115
+ if str == "" && val != EndOfList.instance
116
+ p "***Warning: read #{val.inspect} as end of list!?"
117
+ end
118
+ val != EndOfList.instance
119
+ str != ""
120
+ end.
114
121
  map{|k,v| [k.to_sym, v]}
115
122
  ]
116
123
  end
@@ -126,14 +133,9 @@ module FLV
126
133
 
127
134
  class EndOfList # :nodoc:
128
135
  include Singleton, Packable
129
- packers.set :flv, {}
130
-
131
- def write_packed(*)
132
- # no data to write
133
- end
134
-
135
- def self.read_packed(*)
136
- self.instance
136
+ packers.set(:flv) do |packer|
137
+ packer.write {} # no data to write
138
+ packer.read {EndOfList.instance}
137
139
  end
138
140
  end
139
141
 
@@ -22,7 +22,7 @@ module FLV
22
22
  end
23
23
  end
24
24
  puts (["Processed successfully:"] + ok).join("\n") unless ok.empty?
25
- puts (["**** Processed with errors: ****"] + errors.map{|path, err| "#{path}: #{err}"}).join("\n") unless errors.empty?
25
+ puts (["**** Processed with errors: ****"] + errors.map{|path, err| "#{path}: #{err}"}+ err.backtrace).join("\n") unless errors.empty?
26
26
  end
27
27
  end
28
28
  end
@@ -23,7 +23,11 @@ module FLV
23
23
  p "Opening #{@sources.first}"
24
24
  FLV::File.open(@sources.shift) do |f|
25
25
  @source = f
26
- super
26
+ begin
27
+ super
28
+ rescue EOFError
29
+ p "*** Warning: unexpected EOF for file #{f.path}"
30
+ end
27
31
  end
28
32
  end
29
33
 
data/test/test_flv.rb CHANGED
@@ -16,7 +16,7 @@ class TestFlv < Test::Unit::TestCase
16
16
  assert_equal n, FLV::Timestamp.try_convert(s).in_milliseconds
17
17
  end
18
18
  end
19
-
19
+
20
20
  { "0" => 0 ,
21
21
  "1" => 1000,
22
22
  "1.0" => 1000,
@@ -31,7 +31,7 @@ class TestFlv < Test::Unit::TestCase
31
31
  end
32
32
  end
33
33
  end
34
-
34
+
35
35
  context "TimestampRange" do
36
36
  context "conversion" do
37
37
  { "1:02-" => 62..(1/0.0),
@@ -45,7 +45,7 @@ class TestFlv < Test::Unit::TestCase
45
45
  end
46
46
  end
47
47
  end
48
-
48
+
49
49
 
50
50
  BIT_TEST = "\x01\x02\xff"
51
51
  context "Bit reading from #{BIT_TEST.inspect}" do
@@ -72,7 +72,7 @@ class TestFlv < Test::Unit::TestCase
72
72
  end
73
73
  end
74
74
  end
75
-
75
+
76
76
  context "Packing" do
77
77
  context "a header" do
78
78
  setup do
@@ -116,6 +116,26 @@ class TestFlv < Test::Unit::TestCase
116
116
  end
117
117
  end
118
118
 
119
+ context "Packing + Unpacking" do
120
+ should "return the same object" do
121
+ obj = {
122
+ :event => "onMetaData" ,
123
+ :audiocodecid => 2 ,
124
+ :audiodatarate => 15.7066666666667 ,
125
+ :canSeekToEnd => false ,
126
+ :hasAudio => true ,
127
+ :cuePoints => [] ,
128
+ :keyframes => {:filepositions=>[846, 1968], :times=>[0.0, 0.2]},
129
+ :metadatadate => Time.gm(2000,"jan",1,20,15,1)
130
+ }
131
+ io = StringIO.new("").packed
132
+ io.write(obj, :flv_value)
133
+ io.rewind
134
+ assert_equal(obj, io.read(:flv_value))
135
+ assert io.eof?
136
+ end
137
+ end
138
+
119
139
  context "Typematch" do
120
140
  setup do
121
141
  @chunks = FLV::File.open(SHORT_FLV).each.first(4)
@@ -141,5 +161,5 @@ class TestFlv < Test::Unit::TestCase
141
161
  end
142
162
  end
143
163
  end
144
-
164
+
145
165
  end
@@ -128,5 +128,4 @@ Header| ./test/fixtures/short.flv
128
128
  3.343 | FLV::Audio tag
129
129
  3.395 | FLV::Audio tag
130
130
  3.400 | FLV::Video tag (interframe)
131
- 3.448 | FLV::Audio tag
132
- 3.500 | FLV::Video tag (interframe)
131
+ 3.448 | FLV::Audio tag
@@ -110,5 +110,4 @@ Header| ./test/fixtures/short.flv
110
110
  3.187 | FLV::Audio tag
111
111
  3.239 | FLV::Audio tag
112
112
  3.244 | FLV::Video tag (interframe)
113
- 3.292 | FLV::Audio tag
114
- 3.344 | FLV::Video tag (interframe)
113
+ 3.292 | FLV::Audio tag
@@ -128,5 +128,4 @@ Header| ./test/fixtures/short.flv
128
128
  3.343 | FLV::Audio tag
129
129
  3.395 | FLV::Audio tag
130
130
  3.400 | FLV::Video tag (interframe)
131
- 3.448 | FLV::Audio tag
132
- 3.500 | FLV::Video tag (interframe)
131
+ 3.448 | FLV::Audio tag
@@ -3,32 +3,32 @@
3
3
  *** result:
4
4
  Header| ./test/fixtures/short.flv
5
5
  | extra :
6
+ | version : 1
6
7
  | has_audio : true
7
8
  | has_video : true
8
- | version : 1
9
9
  0.000 | FLV::Event tag
10
10
  | event : onMetaData
11
- | audiocodecid : 2
12
- | audiodatarate : 16
13
- | audiodelay : 0
11
+ | videocodecid : 4
14
12
  | canSeekToEnd : 1
15
- | creationdate : Fri Feb 03 122553 2006\n
16
- | duration : 16.9
17
- | framerate : 10
13
+ | width : 192
14
+ | audiodatarate : 16
18
15
  | height : 154
19
- | videocodecid : 4
16
+ | framerate : 10
17
+ | audiocodecid : 2
18
+ | duration : 16.9
19
+ | creationdate : Fri Feb 03 122553 2006\n
20
20
  | videodatarate : 40
21
- | width : 192
21
+ | audiodelay : 0
22
22
  0.000 | FLV::Audio tag
23
- | channel : mono
24
- | codec_id : 2
25
- | format : MP3
26
23
  | rate : 11000
24
+ | format : MP3
25
+ | codec_id : 2
26
+ | channel : mono
27
27
  | sample_size : 16
28
28
  0.000 | FLV::Video tag (keyframe)
29
- | codec : on2_vp6
30
- | codec_id : 4
31
29
  | dimensions : nil
30
+ | codec_id : 4
31
+ | codec : on2_vp6
32
32
  0.052 | FLV::Audio tag
33
33
  0.100 | FLV::Video tag (interframe)
34
34
  0.104 | FLV::Audio tag
@@ -129,109 +129,107 @@ Header| ./test/fixtures/short.flv
129
129
  3.395 | FLV::Audio tag
130
130
  3.400 | FLV::Video tag (interframe)
131
131
  3.448 | FLV::Audio tag
132
- 3.500 | FLV::Video tag (interframe)
133
- 3.500 | FLV::Event tag
132
+ 3.448 | FLV::Event tag
134
133
  | event : onNextSegment
135
134
  | file : short.flv
136
- 3.600 | FLV::Video tag (keyframe)
137
- 3.652 | FLV::Audio tag
138
- 3.700 | FLV::Video tag (interframe)
139
- 3.704 | FLV::Audio tag
140
- 3.756 | FLV::Audio tag
141
- 3.800 | FLV::Video tag (keyframe)
142
- 3.808 | FLV::Audio tag
143
- 3.861 | FLV::Audio tag
135
+ 3.500 | FLV::Video tag (keyframe)
136
+ 3.552 | FLV::Audio tag
137
+ 3.600 | FLV::Video tag (interframe)
138
+ 3.604 | FLV::Audio tag
139
+ 3.656 | FLV::Audio tag
140
+ 3.700 | FLV::Video tag (keyframe)
141
+ 3.708 | FLV::Audio tag
142
+ 3.761 | FLV::Audio tag
143
+ 3.800 | FLV::Video tag (interframe)
144
+ 3.813 | FLV::Audio tag
145
+ 3.865 | FLV::Audio tag
144
146
  3.900 | FLV::Video tag (interframe)
145
- 3.913 | FLV::Audio tag
146
- 3.965 | FLV::Audio tag
147
+ 3.917 | FLV::Audio tag
148
+ 3.970 | FLV::Audio tag
147
149
  4.000 | FLV::Video tag (interframe)
148
- 4.017 | FLV::Audio tag
149
- 4.070 | FLV::Audio tag
150
+ 4.022 | FLV::Audio tag
151
+ 4.074 | FLV::Audio tag
150
152
  4.100 | FLV::Video tag (interframe)
151
- 4.122 | FLV::Audio tag
152
- 4.174 | FLV::Audio tag
153
+ 4.126 | FLV::Audio tag
154
+ 4.179 | FLV::Audio tag
153
155
  4.200 | FLV::Video tag (interframe)
154
- 4.226 | FLV::Audio tag
155
- 4.279 | FLV::Audio tag
156
+ 4.231 | FLV::Audio tag
157
+ 4.283 | FLV::Audio tag
156
158
  4.300 | FLV::Video tag (interframe)
157
- 4.331 | FLV::Audio tag
158
- 4.383 | FLV::Audio tag
159
+ 4.335 | FLV::Audio tag
160
+ 4.388 | FLV::Audio tag
159
161
  4.400 | FLV::Video tag (interframe)
160
- 4.435 | FLV::Audio tag
161
- 4.488 | FLV::Audio tag
162
+ 4.440 | FLV::Audio tag
163
+ 4.492 | FLV::Audio tag
162
164
  4.500 | FLV::Video tag (interframe)
163
- 4.540 | FLV::Audio tag
164
- 4.592 | FLV::Audio tag
165
+ 4.544 | FLV::Audio tag
166
+ 4.597 | FLV::Audio tag
165
167
  4.600 | FLV::Video tag (interframe)
166
- 4.644 | FLV::Audio tag
167
- 4.697 | FLV::Audio tag
168
+ 4.649 | FLV::Audio tag
168
169
  4.700 | FLV::Video tag (interframe)
169
- 4.749 | FLV::Audio tag
170
+ 4.701 | FLV::Audio tag
171
+ 4.753 | FLV::Audio tag
170
172
  4.800 | FLV::Video tag (interframe)
171
- 4.801 | FLV::Audio tag
172
- 4.853 | FLV::Audio tag
173
+ 4.806 | FLV::Audio tag
174
+ 4.858 | FLV::Audio tag
173
175
  4.900 | FLV::Video tag (interframe)
174
- 4.906 | FLV::Audio tag
175
- 4.958 | FLV::Audio tag
176
+ 4.910 | FLV::Audio tag
177
+ 4.962 | FLV::Audio tag
176
178
  5.000 | FLV::Video tag (interframe)
177
- 5.010 | FLV::Audio tag
178
- 5.062 | FLV::Audio tag
179
+ 5.015 | FLV::Audio tag
180
+ 5.067 | FLV::Audio tag
179
181
  5.100 | FLV::Video tag (interframe)
180
- 5.115 | FLV::Audio tag
181
- 5.167 | FLV::Audio tag
182
+ 5.119 | FLV::Audio tag
183
+ 5.171 | FLV::Audio tag
182
184
  5.200 | FLV::Video tag (interframe)
183
- 5.219 | FLV::Audio tag
184
- 5.271 | FLV::Audio tag
185
+ 5.224 | FLV::Audio tag
186
+ 5.276 | FLV::Audio tag
185
187
  5.300 | FLV::Video tag (interframe)
186
- 5.324 | FLV::Audio tag
187
- 5.376 | FLV::Audio tag
188
+ 5.328 | FLV::Audio tag
189
+ 5.380 | FLV::Audio tag
188
190
  5.400 | FLV::Video tag (interframe)
189
- 5.428 | FLV::Audio tag
190
- 5.480 | FLV::Audio tag
191
+ 5.433 | FLV::Audio tag
192
+ 5.485 | FLV::Audio tag
191
193
  5.500 | FLV::Video tag (interframe)
192
- 5.533 | FLV::Audio tag
193
- 5.585 | FLV::Audio tag
194
+ 5.537 | FLV::Audio tag
195
+ 5.589 | FLV::Audio tag
194
196
  5.600 | FLV::Video tag (interframe)
195
- 5.637 | FLV::Audio tag
196
- 5.689 | FLV::Audio tag
197
+ 5.642 | FLV::Audio tag
198
+ 5.694 | FLV::Audio tag
197
199
  5.700 | FLV::Video tag (interframe)
198
- 5.742 | FLV::Audio tag
199
- 5.794 | FLV::Audio tag
200
+ 5.746 | FLV::Audio tag
201
+ 5.798 | FLV::Audio tag
200
202
  5.800 | FLV::Video tag (interframe)
201
- 5.846 | FLV::Audio tag
202
- 5.898 | FLV::Audio tag
203
+ 5.851 | FLV::Audio tag
203
204
  5.900 | FLV::Video tag (interframe)
204
- 5.951 | FLV::Audio tag
205
+ 5.903 | FLV::Audio tag
206
+ 5.955 | FLV::Audio tag
205
207
  6.000 | FLV::Video tag (interframe)
206
- 6.003 | FLV::Audio tag
207
- 6.055 | FLV::Audio tag
208
+ 6.007 | FLV::Audio tag
209
+ 6.059 | FLV::Audio tag
208
210
  6.100 | FLV::Video tag (interframe)
209
- 6.107 | FLV::Audio tag
210
- 6.159 | FLV::Audio tag
211
+ 6.112 | FLV::Audio tag
212
+ 6.164 | FLV::Audio tag
211
213
  6.200 | FLV::Video tag (interframe)
212
- 6.212 | FLV::Audio tag
213
- 6.264 | FLV::Audio tag
214
+ 6.216 | FLV::Audio tag
215
+ 6.268 | FLV::Audio tag
214
216
  6.300 | FLV::Video tag (interframe)
215
- 6.316 | FLV::Audio tag
216
- 6.368 | FLV::Audio tag
217
+ 6.321 | FLV::Audio tag
218
+ 6.373 | FLV::Audio tag
217
219
  6.400 | FLV::Video tag (interframe)
218
- 6.421 | FLV::Audio tag
219
- 6.473 | FLV::Audio tag
220
+ 6.425 | FLV::Audio tag
221
+ 6.477 | FLV::Audio tag
220
222
  6.500 | FLV::Video tag (interframe)
221
- 6.525 | FLV::Audio tag
222
- 6.577 | FLV::Audio tag
223
+ 6.530 | FLV::Audio tag
224
+ 6.582 | FLV::Audio tag
223
225
  6.600 | FLV::Video tag (interframe)
224
- 6.630 | FLV::Audio tag
225
- 6.682 | FLV::Audio tag
226
+ 6.634 | FLV::Audio tag
227
+ 6.686 | FLV::Audio tag
226
228
  6.700 | FLV::Video tag (interframe)
227
- 6.734 | FLV::Audio tag
228
- 6.786 | FLV::Audio tag
229
+ 6.739 | FLV::Audio tag
230
+ 6.791 | FLV::Audio tag
229
231
  6.800 | FLV::Video tag (interframe)
230
- 6.839 | FLV::Audio tag
231
- 6.891 | FLV::Audio tag
232
+ 6.843 | FLV::Audio tag
233
+ 6.895 | FLV::Audio tag
232
234
  6.900 | FLV::Video tag (interframe)
233
- 6.943 | FLV::Audio tag
234
- 6.995 | FLV::Audio tag
235
- 7.000 | FLV::Video tag (interframe)
236
- 7.048 | FLV::Audio tag
237
- 7.100 | FLV::Video tag (interframe)
235
+ 6.948 | FLV::Audio tag
@@ -4,16 +4,16 @@
4
4
  0.000 | FLV::Event tag
5
5
  | event : onMetaData
6
6
  | audiocodecid : 2
7
- | audiodatarate : 15.7066666666667
7
+ | audiodatarate : 15.9368658399098
8
8
  | audiodelay : 0.0
9
9
  | audiosamplerate: 11000
10
10
  | audiosamplesize: 16
11
11
  | audiosize : 7805
12
12
  | canSeekToEnd : false
13
13
  | cuePoints : []
14
- | datasize : 25001
15
- | duration : 3.6
16
- | filesize : 25430
14
+ | datasize : 24860
15
+ | duration : 3.548
16
+ | filesize : 25285
17
17
  | framerate : 10.0
18
18
  | hasAudio : true
19
19
  | hasCuePoints : false
@@ -23,11 +23,11 @@
23
23
  | height : 154
24
24
  | keyframes : {filepositions=>[846, 1968], times=>[0.0, 0.2]}
25
25
  | lastkeyframetimestamp: 0.2
26
- | lasttimestamp : 3.5
26
+ | lasttimestamp : 3.448
27
27
  | metadatacreator: flvedit........................................................
28
28
  | metadatadate : Sat Dec 20 000000 UTC 2008
29
29
  | stereo : false
30
30
  | videocodecid : 4
31
- | videodatarate : 35.7577777777778
32
- | videosize : 16487
31
+ | videodatarate : 35.988726042841
32
+ | videosize : 16346
33
33
  | width : 192
@@ -5,16 +5,16 @@
5
5
  | event : onMetaData
6
6
  | answer : 42
7
7
  | audiocodecid : 2
8
- | audiodatarate : 15.7066666666667
8
+ | audiodatarate : 15.9368658399098
9
9
  | audiodelay : 0.0
10
10
  | audiosamplerate: 11000
11
11
  | audiosamplesize: 16
12
12
  | audiosize : 7805
13
13
  | canSeekToEnd : false
14
14
  | cuePoints : []
15
- | datasize : 25001
16
- | duration : 3.6
17
- | filesize : 25430
15
+ | datasize : 24860
16
+ | duration : 3.548
17
+ | filesize : 25285
18
18
  | framerate : 10.0
19
19
  | hasAudio : true
20
20
  | hasCuePoints : false
@@ -24,13 +24,13 @@
24
24
  | height : 154
25
25
  | keyframes : {filepositions=>[846, 1968], times=>[0.0, 0.2]}
26
26
  | lastkeyframetimestamp: 0.2
27
- | lasttimestamp : 3.5
27
+ | lasttimestamp : 3.448
28
28
  | metadatacreator: flvedit........................................................
29
29
  | metadatadate : Sat Dec 20 000000 UTC 2008
30
30
  | pills : [red, blue]
31
31
  | stereo : false
32
32
  | testing : Hello, world!
33
33
  | videocodecid : 4
34
- | videodatarate : 35.7577777777778
35
- | videosize : 16487
34
+ | videodatarate : 35.988726042841
35
+ | videosize : 16346
36
36
  | width : 192
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcandre-flvedit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Marc-Andr\xC3\xA9 Lafortune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-18 00:00:00 -07:00
12
+ date: 2009-08-20 00:00:00 -07:00
13
13
  default_executable: flvedit
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "1.2"
23
+ version: 1.3.2
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: backports
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.8
33
+ version: 1.7.1
34
34
  version:
35
35
  description: "flvedit allows you to: * compute metadata for FLV files * merge, split or cut FLVs * insert / remote cue points or other events flvedit is meant as a replacement for FLVTool2, FLVMeta, FLVTool++ It can be used as a command line tool or as a Ruby library."
36
36
  email: github@marc-andre.ca