ruby-ogginfo 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/Manifest.txt +6 -0
- data/README.txt +35 -0
- data/Rakefile +18 -0
- data/lib/ogginfo.rb +145 -0
- data/test/test_ruby-ogginfo.rb +151 -0
- metadata +69 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
= ruby-ogginfo
|
2
|
+
|
3
|
+
http://ruby-ogginfo.rubyforge.org/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
ruby-ogginfo gives you access to low level information on ogg files
|
8
|
+
(bitrate, length, samplerate, encoder, etc... ), as well as tag.
|
9
|
+
It is written in pure ruby.
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS
|
12
|
+
|
13
|
+
* writing tags is not pure ruby yet, need to have "vorbiscomment"
|
14
|
+
command
|
15
|
+
|
16
|
+
== SYNOPSIS:
|
17
|
+
|
18
|
+
require "ogginfo"
|
19
|
+
OggInfo.open("toto.ogg") do |ogg|
|
20
|
+
puts ogg.bitrate
|
21
|
+
puts ogg.artist
|
22
|
+
puts ogg
|
23
|
+
end
|
24
|
+
|
25
|
+
== INSTALL:
|
26
|
+
|
27
|
+
sudo gem install ruby-ogginfo
|
28
|
+
|
29
|
+
== TODO:
|
30
|
+
|
31
|
+
* writing tags in pure-ruby
|
32
|
+
|
33
|
+
== LICENSE:
|
34
|
+
|
35
|
+
Ruby
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require 'lib/ogginfo.rb'
|
6
|
+
|
7
|
+
Hoe.new('ruby-ogginfo', OggInfo::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'ruby-ogginfo'
|
9
|
+
p.author = 'Guillaume Pierronnet'
|
10
|
+
p.email = 'moumar@rubyforge.org'
|
11
|
+
p.summary = 'ruby-ogginfo is a pure-ruby library that gives low level informations on ogg files'
|
12
|
+
p.description = p.paragraphs_of('README.txt', 3).first
|
13
|
+
p.url = p.paragraphs_of('README.txt', 1).first
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
+
p.remote_rdoc_dir = ''
|
16
|
+
end
|
17
|
+
|
18
|
+
# vim: syntax=Ruby
|
data/lib/ogginfo.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# $Id: ogginfo.rb 36 2008-03-15 01:01:51Z moumar $
|
2
|
+
#
|
3
|
+
# see http://www.xiph.org/ogg/vorbis/docs.html for documentation on vorbis format
|
4
|
+
# http://www.xiph.org/ogg/vorbis/doc/v-comment.html
|
5
|
+
|
6
|
+
require "iconv"
|
7
|
+
|
8
|
+
class Hash
|
9
|
+
### lets you specify hash["key"] as hash.key
|
10
|
+
### this came from CodingInRuby on RubyGarden
|
11
|
+
### http://www.rubygarden.org/ruby?CodingInRuby
|
12
|
+
def method_missing(meth,*args)
|
13
|
+
if /=$/=~(meth=meth.id2name) then
|
14
|
+
self[meth[0...-1]] = (args.length<2 ? args[0] : args)
|
15
|
+
else
|
16
|
+
self[meth]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Raised on any kind of error related to ruby-ogginfo
|
22
|
+
class OggInfoError < StandardError ; end
|
23
|
+
|
24
|
+
class OggInfo
|
25
|
+
VERSION = "0.3"
|
26
|
+
attr_reader :channels, :samplerate, :bitrate, :nominal_bitrate, :length
|
27
|
+
|
28
|
+
# +tag+ is a hash containing the vorbis tag like "Artist", "Title", and the like
|
29
|
+
attr_reader :tag
|
30
|
+
|
31
|
+
# create new instance of OggInfo, using +charset+ to convert tags to
|
32
|
+
def initialize(filename, charset = "iso-8859-1")
|
33
|
+
@file = File.new(filename, "rb")
|
34
|
+
if charset !~ /^utf-?8$/i
|
35
|
+
@ic = Iconv.new(charset, "utf8")
|
36
|
+
end
|
37
|
+
|
38
|
+
find_next_page
|
39
|
+
extract_infos
|
40
|
+
find_next_page
|
41
|
+
extract_tag(charset)
|
42
|
+
@saved_tag = @tag.dup
|
43
|
+
extract_end
|
44
|
+
@bitrate = @file.stat.size.to_f*8/@length
|
45
|
+
end
|
46
|
+
|
47
|
+
# "block version" of ::new()
|
48
|
+
def self.open(*args)
|
49
|
+
m = self.new(*args)
|
50
|
+
ret = nil
|
51
|
+
if block_given?
|
52
|
+
begin
|
53
|
+
ret = yield(m)
|
54
|
+
ensure
|
55
|
+
m.close
|
56
|
+
end
|
57
|
+
else
|
58
|
+
ret = m
|
59
|
+
end
|
60
|
+
ret
|
61
|
+
end
|
62
|
+
|
63
|
+
# write any tags to file
|
64
|
+
def close
|
65
|
+
@ic.close
|
66
|
+
@file.close if @file and not @file.closed?
|
67
|
+
if @tag != @saved_tag
|
68
|
+
cmd = %w{vorbiscomment -w}
|
69
|
+
|
70
|
+
@tag.each do |k,v|
|
71
|
+
cmd.concat(["-t", k.upcase+"="+v])
|
72
|
+
end
|
73
|
+
cmd << @file.path
|
74
|
+
system(*cmd)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# check the presence of a tag
|
79
|
+
def hastag?
|
80
|
+
!@tag.empty?
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_s
|
84
|
+
"channels #{@channels} samplerate #{@samplerate} bitrate #{@nominal_bitrate} bitrate #{@bitrate} length #{@length} #{@tag.inspect}"
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def find_next_page
|
89
|
+
header = 'OggS' # 0xf4 . 0x67 . 0x 67 . 0x53
|
90
|
+
bytes = @file.read(4)
|
91
|
+
bytes_read = 4
|
92
|
+
|
93
|
+
while header != bytes
|
94
|
+
#raise OggInfoError if bytes_read > 4096 or @file.eof? #bytes.nil?
|
95
|
+
raise OggInfoError if @file.eof? #bytes.nil?
|
96
|
+
bytes.slice!(0)
|
97
|
+
char = @file.read(1)
|
98
|
+
bytes_read += 1
|
99
|
+
bytes << char
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def extract_infos
|
104
|
+
@file.seek(35, IO::SEEK_CUR) # seek after "vorbis"
|
105
|
+
@channels, @samplerate, up_br, @nominal_bitrate, down_br = @file.read(17).unpack("CV4")
|
106
|
+
if @nominal_bitrate == 0
|
107
|
+
if up == 2**32 - 1 or down == 2**32 - 1
|
108
|
+
@nominal_bitrate = 0
|
109
|
+
else
|
110
|
+
@nominal_bitrate = (up_br + down_br)/2
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def extract_tag(charset)
|
116
|
+
@tag = {}
|
117
|
+
@file.seek(22, IO::SEEK_CUR)
|
118
|
+
segs = @file.read(1).unpack("C")[0]
|
119
|
+
@file.seek(segs + 7, IO::SEEK_CUR)
|
120
|
+
size = @file.read(4).unpack("V")[0]
|
121
|
+
@file.seek(size, IO::SEEK_CUR)
|
122
|
+
tag_size = @file.read(4).unpack("V")[0]
|
123
|
+
|
124
|
+
tag_size.times do |i|
|
125
|
+
size = @file.read(4).unpack("V")[0]
|
126
|
+
comment = @file.read(size)
|
127
|
+
if @ic
|
128
|
+
comment = @ic.iconv( com ) rescue comment
|
129
|
+
end
|
130
|
+
key, val = comment.split(/=/)
|
131
|
+
@tag[key.downcase] = val
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def extract_end
|
136
|
+
begin #Errno::EINVAL
|
137
|
+
@file.seek(-5000, IO::SEEK_END) #FIXME size of seeking
|
138
|
+
find_next_page
|
139
|
+
pos = @file.read(6).unpack("x2 V")[0] #FIXME pos is int64
|
140
|
+
@length = pos.to_f / @samplerate
|
141
|
+
rescue Errno::EINVAL
|
142
|
+
@length = 0
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
|
3
|
+
$:.unshift("lib/")
|
4
|
+
|
5
|
+
require "test/unit"
|
6
|
+
require "ogginfo"
|
7
|
+
require "fileutils"
|
8
|
+
require "tempfile"
|
9
|
+
|
10
|
+
VALID_OGG = <<EOF
|
11
|
+
T2dnUwACAAAAAAAAAADjoIphAAAAAIDpYLkBHgF2b3JiaXMAAAAAAkSsAAAA
|
12
|
+
AAAAAPoAAAAAAAC4AU9nZ1MAAAAAAAAAAAAA46CKYQEAAACKbpIfEC3/////
|
13
|
+
/////////////8EDdm9yYmlzHQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIw
|
14
|
+
MDcwNjIyAAAAAAEFdm9yYmlzIUJDVgEAAAEAGGNUKUaZUtJKiRlzlDFGmWKS
|
15
|
+
SomlhBZCSJ1zFFOpOdeca6y5tSCEEBpTUCkFmVKOUmkZY5ApBZlSEEtJJXQS
|
16
|
+
OiedYxBbScHWmGuLQbYchA2aUkwpxJRSikIIGVOMKcWUUkpCByV0DjrmHFOO
|
17
|
+
SihBuJxzq7WWlmOLqXSSSuckZExCSCmFkkoHpVNOQkg1ltZSKR1zUlJqQegg
|
18
|
+
hBBCtiCEDYLQkFUAAAEAwEAQGrIKAFAAABCKoRiKAoSGrAIAMgAABKAojuIo
|
19
|
+
jiM5kmNJFhAasgoAAAIAEAAAwHAUSZEUybEkS9IsS9NEUVV91TZVVfZ1Xdd1
|
20
|
+
Xdd1IDRkFQAAAQBASKeZpRogwgxkGAgNWQUAIAAAAEYowhADQkNWAQAAAQAA
|
21
|
+
Yig5iCa05nxzjoNmOWgqxeZ0cCLV5kluKubmnHPOOSebc8Y455xzinJmMWgm
|
22
|
+
tOaccxKDZiloJrTmnHOexOZBa6q05pxzxjmng3FGGOecc5q05kFqNtbmnHMW
|
23
|
+
tKY5ai7F5pxzIuXmSW0u1eacc84555xzzjnnnHOqF6dzcE4455xzovbmWm5C
|
24
|
+
F+eccz4Zp3tzQjjnnHPOOeecc84555xzgtCQVQAAEAAAQRg2hnGnIEifo4EY
|
25
|
+
RYhpyKQH3aPDJGgMcgqpR6OjkVLqIJRUxkkpn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UkrnnHPOOSmllM4555yUUkoI
|
72
|
+
nXNOSimlc845JwAAqMABACDARpHNCUaCCg1ZCQCkAgAYHMeyNE3TPE8UNUnS
|
73
|
+
NM/zPFE0TU2yNM3zPE8UTZPneZ4oiqJpqirP8zxRFEXTVFWuK4qmaZqqqqpk
|
74
|
+
WRRF0TRVVXVhmqapqqrqujBNUVRV1XVdyLJpqqrryjJs2zRV1XVlGaiqqsqu
|
75
|
+
LAPXVVXXlWUBAOAJDgBABTasjnBSNBZYaMhKACADAIAgBCGlFEJKKYSUUggp
|
76
|
+
pRASAAAw4AAAEGBCGSg0ZEUAECcAACAkpYJOSiWhlFJKKaWUUkoppZRSSiml
|
77
|
+
lFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSiml
|
78
|
+
lFJKKaWUUkoppZNSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSiml
|
79
|
+
lFJKKaWUUkoppZSSUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkkp
|
80
|
+
pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
|
81
|
+
pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
|
82
|
+
pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
|
83
|
+
pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
|
84
|
+
pZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkop
|
85
|
+
pZRSSimllAoA0I1wANB9MKEMFBqyEgBIBQAAjFGKMQipxVYhxJhzElprrUKI
|
86
|
+
MecktJRiz5hzEEppLbaeMccglJJai72UzklJrbUYeyodo5JSSzH23kspJaXY
|
87
|
+
Yuy9p5BCji3G2HvPMaUWW6ux915jSrHVGGPvvfcYY6ux1t577zG2VmuOBQBg
|
88
|
+
NjgAQCTYsDrCSdFYYKEhKwGAkAAAwhilGGPMOeecc05KyRhzzkEIIYQQSikZ
|
89
|
+
Y8w5CCGEEEIpJWPOOQchhFBCKKVkzDnoIIRQQiillM45Bx2EEEIJpZSSMecg
|
90
|
+
hBBCCaWUUjrnIIQQQiilhFRKKZ2DEEIoIYRSSkkphBBCCKGEUFIpKYUQQggh
|
91
|
+
hFBCSiWlEEIIIYQQSkilpJRSCCGEEEIIpZSUUgollBBCKKGkkkoppYQQSgih
|
92
|
+
pFRSKqmUEkIIJYSSSkoplVRKKCGEUgAAwIEDAECAEXSSUWURNppw4QEoNGQl
|
93
|
+
ABAFAAAZBx2UlhuAkHLUWocchBRbC5FDDFqMnXKMQUopZJAxxqSVkkLHGKTU
|
94
|
+
YkuhgxR7z7mV1AIAACAIAAgwAQQGCAq+EAJiDABAECIzREJhFSwwKIMGh3kA
|
95
|
+
8AARIREAJCYo0i4uoMsAF3Rx14EQghCEIBYHUEACDk644Yk3POEGJ+gUlToQ
|
96
|
+
AAAAAIAFAHgAAEAogIiIZq7C4gIjQ2ODo8PjA0QAAAAAALAA4AMAAAkBIiKa
|
97
|
+
uQqLC4wMjQ2ODo8PkAAAQAABAAAAABBAAAICAgAAAAAAAQAAAAICT2dnUwAE
|
98
|
+
AAAAAAAAAADjoIphAgAAAIr86XUBAQA=
|
99
|
+
====
|
100
|
+
EOF
|
101
|
+
|
102
|
+
class OggInfoTest < Test::Unit::TestCase
|
103
|
+
|
104
|
+
TEMP_FILE = File.join(Dir.tmpdir, "test_mp3info.ogg")
|
105
|
+
|
106
|
+
def setup
|
107
|
+
valid_ogg_file = VALID_OGG.unpack("m*").first
|
108
|
+
File.open(TEMP_FILE, "w") { |f| f.write(valid_ogg_file) }
|
109
|
+
end
|
110
|
+
|
111
|
+
def teardown
|
112
|
+
FileUtils.rm_f(TEMP_FILE)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_infos
|
116
|
+
OggInfo.open(TEMP_FILE) do |ogg|
|
117
|
+
assert_equal 64000, ogg.nominal_bitrate
|
118
|
+
assert_equal 2, ogg.channels
|
119
|
+
assert_equal 44100, ogg.samplerate
|
120
|
+
assert_equal 0, ogg.length
|
121
|
+
#average_bitrate
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_length
|
126
|
+
generate_ogg
|
127
|
+
OggInfo.open("test.ogg") do |ogg|
|
128
|
+
assert_in_delta(17.0, ogg.length, 1)
|
129
|
+
assert_in_delta(67000.0, ogg.bitrate, 5000)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_tag_writing
|
134
|
+
generate_ogg
|
135
|
+
tag = {"title" => "mytitle", "artist" => "myartist" }
|
136
|
+
OggInfo.open("test.ogg") do |ogg|
|
137
|
+
tag.each { |k,v| ogg.tag[k] = v }
|
138
|
+
end
|
139
|
+
|
140
|
+
OggInfo.open("test.ogg") do |ogg|
|
141
|
+
assert_equal tag, ogg.tag
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def generate_ogg
|
146
|
+
unless test(?f, "test.ogg")
|
147
|
+
system("dd if=/dev/urandom bs=1024 count=3000 | oggenc -q0 --raw -o test.ogg -") or
|
148
|
+
flunk("cannot generate \"test.ogg\", tests cannot be fully performed")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-ogginfo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.3"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guillaume Pierronnet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-15 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.1
|
23
|
+
version:
|
24
|
+
description: ruby-ogginfo gives you access to low level information on ogg files (bitrate, length, samplerate, encoder, etc... ), as well as tag. It is written in pure ruby.
|
25
|
+
email: moumar@rubyforge.org
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- History.txt
|
32
|
+
- Manifest.txt
|
33
|
+
- README.txt
|
34
|
+
files:
|
35
|
+
- History.txt
|
36
|
+
- Manifest.txt
|
37
|
+
- README.txt
|
38
|
+
- Rakefile
|
39
|
+
- lib/ogginfo.rb
|
40
|
+
- test/test_ruby-ogginfo.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://ruby-ogginfo.rubyforge.org/
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --main
|
46
|
+
- README.txt
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project: ruby-ogginfo
|
64
|
+
rubygems_version: 1.0.1
|
65
|
+
signing_key:
|
66
|
+
specification_version: 2
|
67
|
+
summary: ruby-ogginfo is a pure-ruby library that gives low level informations on ogg files
|
68
|
+
test_files:
|
69
|
+
- test/test_ruby-ogginfo.rb
|