audio_monster 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/audio_monster/monster.rb +59 -35
- data/lib/audio_monster/version.rb +1 -1
- data/test/files/test.gif +0 -0
- data/test/files/test.jpg +0 -0
- data/test/files/test.png +0 -0
- data/test/files/test.txt +44 -0
- data/test/monster_test.rb +37 -32
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4381409b28c95625a20cf1c8268cfd848c702a51
|
4
|
+
data.tar.gz: 01e78e0d037c96af6437526888ec645b33484a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d9fee35c7054c62b1392c8930ef0657d3b0848baf91b83e4859d8548816b0beccaaf853e01527c5a4229780873d5a3aeea1271c30ec91a043cc6dab770437f
|
7
|
+
data.tar.gz: 9bfb0af609185bc6ed874715f2c5c79882851143f98d7b6281e66a769a9b07ee13cc2d13c1c9f561b55c7deadac5c27f4fb501070a7cfbfbd8b95f098c72d2f0
|
@@ -19,6 +19,17 @@ module AudioMonster
|
|
19
19
|
include Configuration
|
20
20
|
include ::NuWav
|
21
21
|
|
22
|
+
# when we want to be sure a format string is chosen
|
23
|
+
# esp. when mimemagic has multiple options
|
24
|
+
COMMON_EXTENSIONS = {
|
25
|
+
'application/xml' => 'xml',
|
26
|
+
'audio/mpeg' => 'mp3',
|
27
|
+
'audio/mp4' => 'm4a',
|
28
|
+
'audio/ogg' => 'ogg',
|
29
|
+
'image/jpeg' => 'jpg',
|
30
|
+
'text/plain' => 'txt'
|
31
|
+
}
|
32
|
+
|
22
33
|
def initialize(options={})
|
23
34
|
apply_configuration(options)
|
24
35
|
check_binaries if ENV['AUDIO_MONSTER_DEBUG']
|
@@ -215,54 +226,67 @@ module AudioMonster
|
|
215
226
|
return [out, err]
|
216
227
|
end
|
217
228
|
|
218
|
-
def
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
:bit_rate => info.bitrate,
|
227
|
-
:length => [info.length.to_i, length.to_i].max,
|
228
|
-
:sample_rate => info.samplerate,
|
229
|
-
:version => info.mpeg_version, # mpeg specific
|
230
|
-
:layer => info.layer # mpeg specific
|
231
|
-
}
|
232
|
-
|
233
|
-
# indicate this can be GC'd
|
234
|
-
info = nil
|
235
|
-
|
236
|
-
result
|
229
|
+
def info_for(path)
|
230
|
+
ct = content_type(path)
|
231
|
+
mm = MimeMagic.new(ct)
|
232
|
+
if respond_to?("info_for_#{mm.mediatype}")
|
233
|
+
send("info_for_#{mm.mediatype}", path)
|
234
|
+
else
|
235
|
+
basic_info_for_file(path)
|
236
|
+
end
|
237
237
|
end
|
238
238
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
def info_for_wav(wav_file_path)
|
243
|
-
wf = WaveFile.parse(wav_file_path)
|
244
|
-
fmt = wf.chunks[:fmt]
|
239
|
+
def basic_info_for_file(path)
|
240
|
+
ct = content_type(path)
|
241
|
+
mm = MimeMagic.new(ct)
|
245
242
|
{
|
246
|
-
:
|
247
|
-
:
|
248
|
-
:
|
249
|
-
:bit_rate => (fmt.byte_rate * 8) / 1000, #kilo bytes per sec
|
250
|
-
:length => wf.duration,
|
251
|
-
:sample_rate => fmt.sample_rate
|
243
|
+
size: File.size(path),
|
244
|
+
content_type: ct,
|
245
|
+
format: common_extensions(ct) || mm.extensions.first
|
252
246
|
}
|
253
247
|
end
|
254
248
|
|
249
|
+
def common_extensions(content_type)
|
250
|
+
COMMON_EXTENSIONS[content_type]
|
251
|
+
end
|
252
|
+
|
255
253
|
def info_for_audio(path)
|
256
254
|
info = audio_file_info_ffprobe(path)
|
257
|
-
{
|
258
|
-
size: info['format']['size'].to_i,
|
259
|
-
content_type: (MimeMagic.by_path(path) || MimeMagic.by_magic(path)).to_s,
|
255
|
+
audio_info = {
|
260
256
|
format: audio_file_format(path, info),
|
261
257
|
channel_mode: audio_file_channels(path, info) <= 1 ? 'Mono' : 'Stereo',
|
258
|
+
channels: audio_file_channels(path, info),
|
262
259
|
bit_rate: audio_file_bit_rate(path, info),
|
263
260
|
length: audio_file_duration(path, info),
|
264
261
|
sample_rate: audio_file_sample_rate(path, info)
|
265
262
|
}
|
263
|
+
basic_info_for_file(path).merge(audio_info)
|
264
|
+
end
|
265
|
+
|
266
|
+
def info_for_mpeg(path, info = nil)
|
267
|
+
info = info_for_audio(path)
|
268
|
+
mp3_info ||= Mp3Info.new(path)
|
269
|
+
info[:version] = mp3_info.mpeg_version
|
270
|
+
info[:layer] = mp3_info.layer
|
271
|
+
info[:padding] = mp3_info.header[:padding]
|
272
|
+
info
|
273
|
+
end
|
274
|
+
|
275
|
+
alias info_for_mp2 info_for_mpeg
|
276
|
+
alias info_for_mp3 info_for_mpeg
|
277
|
+
|
278
|
+
def content_type(path)
|
279
|
+
mime_magic_content_type(path) || file_content_type(path)
|
280
|
+
end
|
281
|
+
|
282
|
+
def mime_magic_content_type(path)
|
283
|
+
(MimeMagic.by_path(path) || MimeMagic.by_magic(path)).to_s
|
284
|
+
end
|
285
|
+
|
286
|
+
def file_content_type(path)
|
287
|
+
check_local_file(path)
|
288
|
+
out, err = run_command("#{bin(:file)} --brief --mime-type '#{path}'", nice: 'n', echo_return: false)
|
289
|
+
out.chomp
|
266
290
|
end
|
267
291
|
|
268
292
|
def audio_file_format(path, info = nil)
|
@@ -1006,7 +1030,7 @@ module AudioMonster
|
|
1006
1030
|
if name.to_s.starts_with?('encode_wav_pcm_from_')
|
1007
1031
|
decode_audio(*args)
|
1008
1032
|
elsif name.to_s.starts_with?('info_for_')
|
1009
|
-
|
1033
|
+
info_for(*args)
|
1010
1034
|
else
|
1011
1035
|
super
|
1012
1036
|
end
|
data/test/files/test.gif
ADDED
Binary file
|
data/test/files/test.jpg
ADDED
Binary file
|
data/test/files/test.png
ADDED
Binary file
|
data/test/files/test.txt
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Authorities arrested a suspect Wednesday in the fatal bombings at the Boston Marathon, a federal law enforcement source told CNN's Fran Townsend.
|
2
|
+
Details about the suspect's identity and motive were not immediately available. News of the arrest was first reported by CNN.
|
3
|
+
Investigators identified the suspect based on two videos taken before Monday's attack, the federal law enforcement source told Townsend.
|
4
|
+
One of the videos was surveillance footage taken at the nearby Lord & Taylor department store, the other was shot by a Boston television station, a source who has has been briefed on the investigation exclusively told CNN's John King.
|
5
|
+
The development came after a chaotic day in which investigators revealed more details about the makeup of the bombs and apparently unrelated scares over letters containing ricin gripped the nation's capital.
|
6
|
+
The bombs exploded 12 seconds apart near the finish line of the Boston Marathon, killing three people and wounding about 180 others.
|
7
|
+
One of the bombs was housed in a pressure cooker hidden inside a backpack, the FBI said in a joint intelligence bulletin. The device also had fragments that may have included nails, BBs and ball bearings, the agency said.
|
8
|
+
The second bomb was also housed in a metal container, but it was not clear whether it too was in a pressure cooker, the FBI said.
|
9
|
+
The U.S. government has warned federal agencies in the past that terrorists could turn pressure cookers into bombs by packing them with explosives and shrapnel and detonating them with blasting caps.
|
10
|
+
The bombs
|
11
|
+
Photos obtained by CNN show the remains of a pressure cooker found at the scene, along with a shredded black backpack and what appear to be metal pellets or ball bearings.
|
12
|
+
Scraps of at least one pressure cooker, nails and nylon bags found at the scene were sent to the FBI's national laboratory in Virginia, where technicians will try to reconstruct the devices, the agent leading the investigation said Tuesday.
|
13
|
+
The pieces suggest each of the devices was 6 liters (about 1.6 gallons) in volume, a Boston law enforcement source said. The recovered parts include part of a circuit board, which might have been used to detonate a device.
|
14
|
+
A law enforcement official said Monday's bombs were probably detonated by timers. But the FBI said details of the detonating system were unknown.
|
15
|
+
While the clues moved the investigation forward, they did not make it immediately apparent whether the attack was an act of domestic or foreign terrorism.
|
16
|
+
Tracking suspects in the Boston bombings New clues in Boston Marathon attack
|
17
|
+
Photos: Nation mourns Boston bomb victims
|
18
|
+
Photos: Deadly attack at Boston Marathon
|
19
|
+
"If your experience and your expertise is Middle East terrorism, it has the hallmarks of al Qaeda or a Middle East group," former FBI Assistant Director Tom Fuentes said. "If your experience is domestic groups and bombings that have occurred here, it has the hallmarks of a domestic terrorist like Eric Rudolph in the 1996 Atlanta Summer Olympics bombings."
|
20
|
+
Things we know
|
21
|
+
Fuentes said he has investigated both types of terrorism -- from Iraq to the United States -- and finds the Boston attack has elements of both. "It has the hallmarks of both domestic and international (attacks), and you can see either side of that."
|
22
|
+
Opinion: Why is this so rare?
|
23
|
+
Third victim identified
|
24
|
+
Boston University identified graduate student Lingzu Lu as the third person who died in Monday's bombings.
|
25
|
+
Previously identified were Krystle Campbell, 29, of Arlington, Massachusetts, and Martin Richard, 8, of Dorchester, Massachusetts.
|
26
|
+
"She was the best," Campbell's distraught mother, Patty, told reporters Tuesday. "You couldn't ask for a better daughter."
|
27
|
+
Martin "was a bright, energetic young boy who had big dreams and high hopes for his future," his school said in a statement. "We are heartbroken by this loss."
|
28
|
+
Source: Bomb was in pressure cooker Boston doctor: 'Everyone was my patient' Remembering 8-year-old Martin Richard
|
29
|
+
The hunt for the attacker
|
30
|
+
The attack left Boston police with "the most complex crime scene that we've dealt with in the history of our department," Commissioner Ed Davis said Tuesday.
|
31
|
+
Authorities sifted through thousands of pieces of evidence and a mass of digital photos and video clips leading up to Wednesday's arrest. They had pleaded for the public's help in providing additional leads and images.
|
32
|
+
"Someone knows who did this," said Rick DesLauriers, the special agent in charge of the FBI's Boston office said prior to the arrest. "Cooperation from the community will play a crucial role in this investigation."
|
33
|
+
Medical personnel treating the wounded found evidence suggesting the bombmaker or bombmakers sought to maximize the suffering.
|
34
|
+
Dr. George Velmahos, head of trauma care at Massachusetts General Hospital, said his team found metal pellets and nails inside patients' bodies.
|
35
|
+
"They are numerous. There are people who have 10, 20, 30, 40 of them in their body, or more," Velmahos said.
|
36
|
+
While most of the patients treated at Brigham and Women's Hospital were wounded by "ordinary debris," three were struck by "perfectly round objects" that were uniform, consistent and metallic, the hospital's chairman of emergency medicine said.
|
37
|
+
'Human spirit' still alive
|
38
|
+
Dr. Ron Walls also said one patient had more than 12 carpenter-type nails.
|
39
|
+
"There is no question some of these objects were implanted in the device for the purpose of being exploded forward," he said.
|
40
|
+
Victims continue recovery
|
41
|
+
As investigators closed in on the suspect, those wounded in the incident continued to recover.
|
42
|
+
Boston Medical Center has two patients in critical condition, down from 11 just after the bombings, Dr. Peter Burke, chief of trauma care, told reporters Wednesday. Ten patients are in serious condition and seven are in fair condition, he said.
|
43
|
+
The incident deeply affected thousands, including Candace Rispoli, who was cheering on a friend when the festive atmosphere turned into a "terrifying hell." She suffered minor injuries.
|
44
|
+
"I personally will never participate in an event of this nature in a city in fear that something like this could happen again," she said. "I keep replaying the moments of terror over and over in my head and am just still in utter shock. Always seeing terrible things of this nature happen all over the world on TV, my heart would always go out to those directly affected. But I never imagined in a million years I would be a spectator at the Boston Marathon running for my life."
|
data/test/monster_test.rb
CHANGED
@@ -28,13 +28,13 @@ describe AudioMonster::Monster do
|
|
28
28
|
|
29
29
|
it 'can validate an mpeg audio file\'s attributes' do
|
30
30
|
validations = {
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
31
|
+
version: 2,
|
32
|
+
layer: 3,
|
33
|
+
channel_mode: ['Joint Stereo', 'Stereo'],
|
34
|
+
channels: 2,
|
35
|
+
sample_rate: '<= 44000',
|
36
|
+
bit_rate: '< 100',
|
37
|
+
per_channel_bit_rate: '>= 256'
|
38
38
|
}
|
39
39
|
|
40
40
|
errors, info = monster.validate_mpeg(in_file('test_long.mp2'), validations)
|
@@ -75,7 +75,7 @@ describe AudioMonster::Monster do
|
|
75
75
|
|
76
76
|
it 'should get the length using soxi' do
|
77
77
|
info = monster.info_for_mpeg(in_file('test_long.mp2'))
|
78
|
-
info[:length].must_equal 48
|
78
|
+
info[:length].to_i.must_equal 48
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should get info for ogg file' do
|
@@ -129,14 +129,14 @@ describe AudioMonster::Monster do
|
|
129
129
|
File.extname(file.path).must_equal '.exten'
|
130
130
|
end
|
131
131
|
|
132
|
-
describe 'test info' do
|
132
|
+
describe 'test audio file info' do
|
133
133
|
let(:audio_files) do
|
134
134
|
{
|
135
|
-
'test_short.mp2' => ['mp2', 5, 2, 48000, 256],
|
136
|
-
'test_long.mp3' => ['mp3', 48, 1, 44100, 128],
|
137
|
-
'test.ogg' => ['ogg', 12, 2, 44100, 128],
|
138
|
-
'test.flac' => ['flac', 15, 2, 44100, 246],
|
139
|
-
'test_short.wav' => ['wav', 5, 2, 48000, 1536]
|
135
|
+
'test_short.mp2' => ['mp2', 5, 2, 48000, 256, 'audio/mp2'],
|
136
|
+
'test_long.mp3' => ['mp3', 48, 1, 44100, 128, 'audio/mpeg'],
|
137
|
+
'test.ogg' => ['ogg', 12, 2, 44100, 128, 'audio/ogg'],
|
138
|
+
'test.flac' => ['flac', 15, 2, 44100, 246, 'audio/flac'],
|
139
|
+
'test_short.wav' => ['wav', 5, 2, 48000, 1536, 'audio/x-wav']
|
140
140
|
}
|
141
141
|
end
|
142
142
|
|
@@ -151,31 +151,36 @@ describe AudioMonster::Monster do
|
|
151
151
|
|
152
152
|
it 'can get the format of a file' do
|
153
153
|
audio_files.keys.each do |file|
|
154
|
-
monster.
|
154
|
+
info = monster.info_for_audio(in_file(file))
|
155
|
+
|
156
|
+
info[:format].must_equal audio_files[file][0]
|
157
|
+
info[:length].to_i.must_equal audio_files[file][1]
|
158
|
+
info[:channels].must_equal audio_files[file][2]
|
159
|
+
info[:sample_rate].must_equal audio_files[file][3]
|
160
|
+
info[:bit_rate].must_equal audio_files[file][4]
|
161
|
+
info[:content_type].must_equal audio_files[file][5]
|
155
162
|
end
|
156
163
|
end
|
164
|
+
end
|
157
165
|
|
158
|
-
|
159
|
-
audio_files.keys.each do |file|
|
160
|
-
monster.audio_file_duration(in_file(file)).to_i.must_equal audio_files[file][1]
|
161
|
-
end
|
162
|
-
end
|
166
|
+
describe 'test audio file info' do
|
163
167
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
+
let(:other_files) do
|
169
|
+
{
|
170
|
+
'test.txt' => ['txt', 'text/plain', 6463],
|
171
|
+
'test.gif' => ['gif', 'image/gif', 708713],
|
172
|
+
'test.jpg' => ['jpg', 'image/jpeg', 823925],
|
173
|
+
'test.png' => ['png', 'image/png', 2035485]
|
174
|
+
}
|
168
175
|
end
|
169
176
|
|
170
|
-
it '
|
171
|
-
|
172
|
-
monster.
|
173
|
-
end
|
174
|
-
end
|
177
|
+
it 'gets the format, content type, and size' do
|
178
|
+
other_files.keys.each do |file|
|
179
|
+
info = monster.info_for(in_file(file))
|
175
180
|
|
176
|
-
|
177
|
-
|
178
|
-
|
181
|
+
info[:format].must_equal other_files[file][0]
|
182
|
+
info[:content_type].must_equal other_files[file][1]
|
183
|
+
info[:size].must_equal other_files[file][2]
|
179
184
|
end
|
180
185
|
end
|
181
186
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: audio_monster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kuklewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nu_wav
|
@@ -142,7 +142,11 @@ files:
|
|
142
142
|
- lib/audio_monster/version.rb
|
143
143
|
- test/audio_monster_test.rb
|
144
144
|
- test/files/test.flac
|
145
|
+
- test/files/test.gif
|
146
|
+
- test/files/test.jpg
|
145
147
|
- test/files/test.ogg
|
148
|
+
- test/files/test.png
|
149
|
+
- test/files/test.txt
|
146
150
|
- test/files/test_long.mp2
|
147
151
|
- test/files/test_long.mp3
|
148
152
|
- test/files/test_long.wav
|
@@ -179,7 +183,11 @@ summary: audio_monster manipulates and transcodes audio
|
|
179
183
|
test_files:
|
180
184
|
- test/audio_monster_test.rb
|
181
185
|
- test/files/test.flac
|
186
|
+
- test/files/test.gif
|
187
|
+
- test/files/test.jpg
|
182
188
|
- test/files/test.ogg
|
189
|
+
- test/files/test.png
|
190
|
+
- test/files/test.txt
|
183
191
|
- test/files/test_long.mp2
|
184
192
|
- test/files/test_long.mp3
|
185
193
|
- test/files/test_long.wav
|