flvedit 0.6.2 → 0.6.3
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.
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/bin/flvedit +7 -3
- data/lib/{flv → flvedit/flv}/audio.rb +5 -2
- data/lib/{flv → flvedit/flv}/base.rb +8 -6
- data/lib/{flv → flvedit/flv}/body.rb +4 -3
- data/lib/{flv → flvedit/flv}/header.rb +1 -1
- data/lib/{flv → flvedit/flv}/packing.rb +6 -3
- data/lib/{flv/edit → flvedit}/options.rb +2 -1
- data/lib/{flv/edit → flvedit}/processor/base.rb +5 -1
- data/lib/{flv/edit → flvedit}/processor/cut.rb +1 -1
- data/lib/{flv/edit → flvedit}/processor/meta_data_maker.rb +1 -1
- data/lib/{flv/edit → flvedit}/processor/printer.rb +1 -1
- data/lib/{flv/edit → flvedit}/processor/reader.rb +4 -3
- data/lib/{flv/edit → flvedit}/processor/save.rb +5 -10
- data/lib/{flv/edit → flvedit}/processor/update.rb +6 -4
- data/lib/{flv/edit → flvedit}/runner.rb +1 -1
- data/lib/{flv/edit → flvedit}/version.rb +1 -1
- data/lib/{flv/edit.rb → flvedit.rb} +6 -6
- data/test/test_flv_edit.rb +1 -1
- data/test/test_flv_edit_results.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +35 -35
- /data/lib/{flv → flvedit/flv}/event.rb +0 -0
- /data/lib/{flv → flvedit/flv}/file.rb +0 -0
- /data/lib/{flv → flvedit/flv}/tag.rb +0 -0
- /data/lib/{flv → flvedit/flv}/timestamp.rb +0 -0
- /data/lib/{flv → flvedit/flv}/util/double_check.rb +0 -0
- /data/lib/{flv → flvedit/flv}/video.rb +0 -0
- /data/lib/{flv.rb → flvedit/flv.rb} +0 -0
- /data/lib/{flv/edit → flvedit}/processor/add.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/command_line.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/debug.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/dispatcher.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/filter.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/head.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/join.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor/print.rb +0 -0
- /data/lib/{flv/edit → flvedit}/processor.rb +0 -0
data/Rakefile
CHANGED
@@ -39,7 +39,7 @@ begin
|
|
39
39
|
gem.authors = ["Marc-André Lafortune"]
|
40
40
|
gem.rubyforge_project = "flvedit"
|
41
41
|
gem.add_dependency "packable", ">=1.2"
|
42
|
-
gem.add_dependency "backports"
|
42
|
+
gem.add_dependency "backports", ">=1.6.8"
|
43
43
|
gem.has_rdoc = true
|
44
44
|
gem.rdoc_options << '--title' << 'FLV::Edit' <<
|
45
45
|
'--main' << 'README.rdoc' <<
|
data/VERSION.yml
CHANGED
data/bin/flvedit
CHANGED
@@ -6,9 +6,13 @@
|
|
6
6
|
#++
|
7
7
|
|
8
8
|
begin
|
9
|
-
require '
|
9
|
+
require 'flvedit'
|
10
10
|
rescue LoadError
|
11
|
-
|
12
|
-
|
11
|
+
begin
|
12
|
+
require 'rubygems'
|
13
|
+
require 'flvedit'
|
14
|
+
rescue LoadError
|
15
|
+
require 'lib/flvedit'
|
16
|
+
end
|
13
17
|
end
|
14
18
|
FLV::Edit::Runner.new(ARGV).run
|
@@ -6,7 +6,7 @@ module FLV
|
|
6
6
|
class Audio < String
|
7
7
|
include Body
|
8
8
|
|
9
|
-
FORMATS = Hash.new{|h, key| "Unknown audio format: #{key}"}.merge(
|
9
|
+
FORMATS = Hash.new{|h, key| "Unknown audio format: #{key}"}.merge!(
|
10
10
|
0 => :"Linear PCM, platform endian" ,
|
11
11
|
1 => :ADPCM ,
|
12
12
|
2 => :MP3 ,
|
@@ -29,7 +29,10 @@ module FLV
|
|
29
29
|
:"MP3 8-kHz" => {:rate => 8000}
|
30
30
|
).freeze
|
31
31
|
|
32
|
-
CHANNELS = {
|
32
|
+
CHANNELS = {
|
33
|
+
0 => :mono,
|
34
|
+
1 => :stereo
|
35
|
+
}.freeze
|
33
36
|
|
34
37
|
def codec_id
|
35
38
|
read_bits(0..3)
|
@@ -13,15 +13,17 @@ module FLV
|
|
13
13
|
def getters(of=self)
|
14
14
|
of.class.ancestors.
|
15
15
|
map{|k| k.instance_methods(false)}.
|
16
|
-
inject
|
16
|
+
inject(:-). # cute and tricky! remember that the first ancestor is of.class itself, so that's what we start with
|
17
17
|
select{|m| of.class.instance_method(m).arity.between?(-1,0)}
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
Hash[
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
def to_hash(attributes = getters)
|
21
|
+
Hash[
|
22
|
+
attributes.map do |a|
|
23
|
+
a = a.to_s.delete("@").to_sym
|
24
|
+
[a, send(a)]
|
25
|
+
end
|
26
|
+
]
|
25
27
|
end
|
26
28
|
|
27
29
|
def is?(what)
|
@@ -11,9 +11,9 @@ module FLV
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
module InstanceMethods
|
14
|
+
module InstanceMethods
|
15
15
|
def debug(format, *) #:nodoc
|
16
|
-
format.values(
|
16
|
+
format.values(to_hash)
|
17
17
|
end
|
18
18
|
|
19
19
|
def is?(what)
|
@@ -35,11 +35,12 @@ module FLV
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
module InstanceMethodsWhenString
|
38
|
+
module InstanceMethodsWhenString
|
39
39
|
# Returns an +Integer+ computed from bits specified by +which+.
|
40
40
|
# The 0th bit is the most significant bit of the first character.
|
41
41
|
# +which+ can designate a range of bits or a single bit
|
42
42
|
def read_bits(which)
|
43
|
+
# :reading_this => :headache, sorry
|
43
44
|
which = which..which if which.is_a? Integer
|
44
45
|
first_byte, last_byte = which.first >> 3, which.max >> 3
|
45
46
|
return (getbyte(first_byte) >> (7 & ~which.max)) & ~(~1 << which.max-which.first) if(first_byte == last_byte)
|
@@ -31,7 +31,7 @@ module FLV
|
|
31
31
|
|
32
32
|
def debug(format, *)
|
33
33
|
format.header("Header", path)
|
34
|
-
format.values(
|
34
|
+
format.values(to_hash.tap{|h| [:path, :timestamp, :body].each{|key| h.delete(key)}})
|
35
35
|
end
|
36
36
|
|
37
37
|
def timestamp
|
@@ -26,11 +26,13 @@ module FLV
|
|
26
26
|
8 => [Hash, :flv_with_size],
|
27
27
|
9 => EndOfList ,
|
28
28
|
10 => Array ,
|
29
|
-
11 => Time
|
29
|
+
11 => Time ,
|
30
|
+
nil => NilClass
|
30
31
|
).freeze
|
31
32
|
|
32
33
|
CLASS_TO_TYPE = Hash.new do |h, klass|
|
33
|
-
|
34
|
+
# Makes it such that CLASS_TO_TYPE[Fixnum] = CLASS_TO_TYPE[Integer], etc.
|
35
|
+
h[klass] = h[klass.superclass]
|
34
36
|
end.merge!(TYPE_TO_CLASS.invert).merge!(
|
35
37
|
Event => TYPE_TO_CLASS.key([Hash, :flv_with_size]), # Write Events as hashes with size
|
36
38
|
FalseClass => TYPE_TO_CLASS.key(TrueClass)
|
@@ -40,6 +42,7 @@ module FLV
|
|
40
42
|
Object.packers.set(:flv_value) do |packer|
|
41
43
|
packer.write do |io|
|
42
44
|
type_nb = CLASS_TO_TYPE[self.class]
|
45
|
+
raise "Trying to write #{self.inspect}" unless type_nb
|
43
46
|
klass, format = TYPE_TO_CLASS[type_nb]
|
44
47
|
io << [type_nb, :char] << [self, format || :flv]
|
45
48
|
end
|
@@ -100,7 +103,7 @@ module FLV
|
|
100
103
|
Hash.packers.set(:flv) do |packer|
|
101
104
|
packer.write do |io|
|
102
105
|
each do |key, value|
|
103
|
-
io << [key.to_s, :flv] << [value, :flv_value]
|
106
|
+
io << [key.to_s, :flv] << [value, :flv_value] rescue raise "Hash[#{key}] is set to #{value.inspect}"
|
104
107
|
end
|
105
108
|
io << ["", :flv] << [EndOfList.instance, :flv_value]
|
106
109
|
end
|
@@ -40,7 +40,8 @@ module FLV
|
|
40
40
|
parser.separator "Switches:"
|
41
41
|
[
|
42
42
|
[:keyframe_mode, "Keyframe mode slides on_cue_point(navigation) tags added by the",
|
43
|
-
"add command to nearest keyframe position"]
|
43
|
+
"add command to nearest keyframe position"],
|
44
|
+
[:trace, "Show backtrace for errors"]
|
44
45
|
].each do |switch, *desc|
|
45
46
|
shortcut = desc.first.is_a?(Symbol) ? desc.shift.to_s : switch.to_s[0..0]
|
46
47
|
full = desc.first.is_a?(Class) ? "--#{switch.to_s} N" : "--#{switch.to_s}"
|
@@ -5,7 +5,7 @@ module FLV
|
|
5
5
|
# Cut is a Processor class (see Base and desc)
|
6
6
|
class Cut < Base
|
7
7
|
desc ["Cuts selects the tags within RANGE.",
|
8
|
-
"The timestamps are offset so that the first tag
|
8
|
+
"The timestamps are offset so that the first tag has timestamp 0"],
|
9
9
|
:param => {:class => TimestampRange, :name => "RANGE"}, :shortcut => "x"
|
10
10
|
|
11
11
|
include Filter
|
@@ -95,7 +95,7 @@ module FLV
|
|
95
95
|
:canSeekToEnd => @info[Video].last.frame_type == :keyframe,
|
96
96
|
:lastkeyframetimestamp => @key_frames.last.first || 0
|
97
97
|
) if meta[:hasVideo]
|
98
|
-
|
98
|
+
|
99
99
|
meta.merge!(
|
100
100
|
:stereo => @info[Audio].first.channel == :stereo,
|
101
101
|
:audiosamplerate => @info[Audio].first.rate,
|
@@ -17,7 +17,7 @@ module FLV
|
|
17
17
|
|
18
18
|
# Prints out a hash (or any list of key-value pairs) in two columns
|
19
19
|
def values(hash)
|
20
|
-
hash.
|
20
|
+
hash.each do |key, value|
|
21
21
|
@io.puts "#{@margin_left}#{key.to_s.ljust(@options[:column_width])}: #{value.inspect.delete(':"')}"
|
22
22
|
end
|
23
23
|
end
|
@@ -10,23 +10,24 @@ module FLV
|
|
10
10
|
raise "Invalid filenames: #{options[:files].inspect}" unless options[:files].all?
|
11
11
|
raise "Please specify at least one filename" if options[:files].empty?
|
12
12
|
raise NotImplemented, "Reader can't have a source (other than options[:files])" if source
|
13
|
-
|
13
|
+
rewind_source
|
14
14
|
end
|
15
15
|
|
16
16
|
def each_source
|
17
17
|
return to_enum(:each_source) unless block_given?
|
18
|
-
|
18
|
+
rewind_source
|
19
19
|
yield until @sources.empty?
|
20
20
|
end
|
21
21
|
|
22
22
|
def each
|
23
|
+
p "Opening #{@sources.first}"
|
23
24
|
FLV::File.open(@sources.shift) do |f|
|
24
25
|
@source = f
|
25
26
|
super
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
def
|
30
|
+
def rewind_source
|
30
31
|
@sources = options[:files].dup
|
31
32
|
end
|
32
33
|
end
|
@@ -6,22 +6,17 @@ module FLV
|
|
6
6
|
class Save < Base
|
7
7
|
desc "Saves the result to PATH", :param => {:class => String, :name => "PATH"}
|
8
8
|
|
9
|
-
def each_source
|
10
|
-
return to_enum(:each_source) unless block_given?
|
11
|
-
@out = FLV::File::open(options[:save] || (h.path+".temp"), "w+b")
|
12
|
-
super
|
13
|
-
ensure
|
14
|
-
@out.close
|
15
|
-
finalpath = @out.path.sub(/\.temp$/, '')
|
16
|
-
FileUtils.mv(@out.path, finalpath) unless finalpath == @out.path
|
17
|
-
end
|
18
|
-
|
19
9
|
def each
|
20
10
|
return to_enum unless block_given?
|
11
|
+
@out = FLV::File::open(options[:save] || (h.path+".temp"), "w+b")
|
21
12
|
super do |chunk|
|
22
13
|
@out << chunk
|
23
14
|
yield chunk
|
24
15
|
end
|
16
|
+
ensure
|
17
|
+
@out.close
|
18
|
+
finalpath = @out.path.sub(/\.temp$/, '')
|
19
|
+
FileUtils.mv(@out.path, finalpath) unless finalpath == @out.path
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
@@ -10,17 +10,19 @@ module FLV
|
|
10
10
|
desc "Updates FLV with an onMetaTag event containing all the relevant information."
|
11
11
|
def initialize(source=nil, options={})
|
12
12
|
super
|
13
|
-
@meta_data_maker = MetaDataMaker.new(source.
|
13
|
+
@meta_data_maker = MetaDataMaker.new(source.clone, options)
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
|
-
def each
|
17
|
+
def each
|
18
18
|
return to_enum unless block_given?
|
19
19
|
begin
|
20
20
|
@meta_data_maker.each {}
|
21
|
-
|
21
|
+
rescue Exception => e # even if each throws, we better call super otherwise we won't be synchronized anymore!
|
22
22
|
super rescue nil
|
23
|
-
raise
|
23
|
+
raise e
|
24
|
+
else
|
25
|
+
super
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -13,7 +13,7 @@ module FLV
|
|
13
13
|
def run
|
14
14
|
commands = [*@commands].map{|c| c.is_a?(Class) ? c : Processor.const_get(c.to_s.camelize)}
|
15
15
|
commands.unshift Processor::Reader
|
16
|
-
commands << Processor::CommandLine unless options[:
|
16
|
+
commands << Processor::CommandLine unless options[:trace]
|
17
17
|
Processor.chain(commands, @options).process_all
|
18
18
|
end
|
19
19
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'backports'
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
3
|
+
require_relative 'flvedit/flv'
|
4
|
+
require_relative 'flvedit/version'
|
5
|
+
require_relative 'flvedit/options'
|
6
|
+
require_relative 'flvedit/processor'
|
7
|
+
require_relative 'flvedit/runner'
|
8
8
|
|
9
9
|
#todo Change bin/flvedit
|
10
10
|
#todo Auto write to files
|
@@ -17,4 +17,4 @@ require_relative 'edit/runner'
|
|
17
17
|
#todo in|out pipe
|
18
18
|
#todo recursive?
|
19
19
|
#todo fix offset, both 24bit issue & apparent skips
|
20
|
-
#todo bug join & time for audio vs video
|
20
|
+
#todo bug join & time for audio vs video
|
data/test/test_flv_edit.rb
CHANGED
@@ -20,7 +20,7 @@ class TestFlvEdit < Test::Unit::TestCase
|
|
20
20
|
should "save" do
|
21
21
|
assert !File.exist?(TEMP_FLV)
|
22
22
|
runner = FLV::Edit::Runner.new([SHORT_FLV, "--Update", "--Save", TEMP_FLV])
|
23
|
-
runner.options[:
|
23
|
+
runner.options[:trace] = true
|
24
24
|
runner.run
|
25
25
|
assert File.exist?(TEMP_FLV)
|
26
26
|
end
|
@@ -12,7 +12,7 @@ class TestFlvEdit < Test::Unit::TestCase
|
|
12
12
|
Time.stubs(:now).returns(Time.utc(2008,"dec",20))
|
13
13
|
@result = ""
|
14
14
|
runner = FLV::Edit::Runner.new(args)
|
15
|
-
runner.options[:
|
15
|
+
runner.options[:trace] = true
|
16
16
|
runner.options[:out] = StringIO.new(@result)
|
17
17
|
runner.run
|
18
18
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'backports'
|
4
|
-
require_relative '../lib/flv/edit'
|
5
4
|
require 'shoulda'
|
6
5
|
require 'mocha'
|
6
|
+
require_relative '../lib/flvedit'
|
7
7
|
|
8
8
|
SHORT_FLV = File.dirname(__FILE__) + "/fixtures/short.flv"
|
9
9
|
TEMP_FLV = File.dirname(__FILE__) + "/fixtures/short_temp.flv"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flvedit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
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-
|
12
|
+
date: 2009-05-01 00:00:00 -04:00
|
13
13
|
default_executable: flvedit
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.6.8
|
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
|
@@ -48,38 +48,38 @@ files:
|
|
48
48
|
- Rakefile
|
49
49
|
- VERSION.yml
|
50
50
|
- bin/flvedit
|
51
|
-
- lib/
|
52
|
-
- lib/flv
|
53
|
-
- lib/flv/
|
54
|
-
- lib/flv/
|
55
|
-
- lib/flv/
|
56
|
-
- lib/flv/
|
57
|
-
- lib/flv/
|
58
|
-
- lib/flv/
|
59
|
-
- lib/flv/
|
60
|
-
- lib/flv/
|
61
|
-
- lib/flv/
|
62
|
-
- lib/flv/
|
63
|
-
- lib/flv/
|
64
|
-
- lib/
|
65
|
-
- lib/
|
66
|
-
- lib/
|
67
|
-
- lib/
|
68
|
-
- lib/
|
69
|
-
- lib/
|
70
|
-
- lib/
|
71
|
-
- lib/
|
72
|
-
- lib/
|
73
|
-
- lib/
|
74
|
-
- lib/
|
75
|
-
- lib/
|
76
|
-
- lib/
|
77
|
-
- lib/
|
78
|
-
- lib/
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- lib/
|
82
|
-
- lib/
|
51
|
+
- lib/flvedit.rb
|
52
|
+
- lib/flvedit/flv.rb
|
53
|
+
- lib/flvedit/flv/audio.rb
|
54
|
+
- lib/flvedit/flv/base.rb
|
55
|
+
- lib/flvedit/flv/body.rb
|
56
|
+
- lib/flvedit/flv/event.rb
|
57
|
+
- lib/flvedit/flv/file.rb
|
58
|
+
- lib/flvedit/flv/header.rb
|
59
|
+
- lib/flvedit/flv/packing.rb
|
60
|
+
- lib/flvedit/flv/tag.rb
|
61
|
+
- lib/flvedit/flv/timestamp.rb
|
62
|
+
- lib/flvedit/flv/util/double_check.rb
|
63
|
+
- lib/flvedit/flv/video.rb
|
64
|
+
- lib/flvedit/options.rb
|
65
|
+
- lib/flvedit/processor.rb
|
66
|
+
- lib/flvedit/processor/add.rb
|
67
|
+
- lib/flvedit/processor/base.rb
|
68
|
+
- lib/flvedit/processor/command_line.rb
|
69
|
+
- lib/flvedit/processor/cut.rb
|
70
|
+
- lib/flvedit/processor/debug.rb
|
71
|
+
- lib/flvedit/processor/dispatcher.rb
|
72
|
+
- lib/flvedit/processor/filter.rb
|
73
|
+
- lib/flvedit/processor/head.rb
|
74
|
+
- lib/flvedit/processor/join.rb
|
75
|
+
- lib/flvedit/processor/meta_data_maker.rb
|
76
|
+
- lib/flvedit/processor/print.rb
|
77
|
+
- lib/flvedit/processor/printer.rb
|
78
|
+
- lib/flvedit/processor/reader.rb
|
79
|
+
- lib/flvedit/processor/save.rb
|
80
|
+
- lib/flvedit/processor/update.rb
|
81
|
+
- lib/flvedit/runner.rb
|
82
|
+
- lib/flvedit/version.rb
|
83
83
|
- test/fixtures/corrupted.flv
|
84
84
|
- test/fixtures/short.flv
|
85
85
|
- test/fixtures/tags.xml
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|