mini_mediainfo 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/mini_mediainfo/media.rb +8 -2
- data/lib/mini_mediainfo/version.rb +1 -1
- data/spec/media_spec.rb +22 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 539cdca6b0af104abee626c213bae61c52c4de6c
|
4
|
+
data.tar.gz: dc5b92dc43a29f30b8f5798f1b679d1b4103c6f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc930648214e103e0f9f5bbffa03d216e52ba6cc1dd33a864ec941b44bf738a7d84df2a5cee2bf9e89b8953d9e679f17c58385593b7eaba0c51782af3822739b
|
7
|
+
data.tar.gz: 0689e19d43032679a4ebae6ab70671df80bc520ab11a62f78a32d4444ebc0d5da30227d20d3ade84ea175ead30b8ff27d452e161c2785422c8d54df44aad930a
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ Or install it yourself as:
|
|
37
37
|
media = MiniMediainfo::Media.new("http://techslides.com/demos/sample-videos/small.mp4")
|
38
38
|
media.introspect
|
39
39
|
media.meta['General']['Format'] # => "MPEG-4"
|
40
|
-
media.meta['General']['Duration'] # => "
|
40
|
+
media.meta['General']['Duration'] # => "12345667"
|
41
41
|
media.meta['Audio']['Compression mode'] # => "Lossy"
|
42
42
|
|
43
43
|
|
data/lib/mini_mediainfo/media.rb
CHANGED
@@ -4,6 +4,7 @@ require "uri"
|
|
4
4
|
|
5
5
|
module MiniMediainfo
|
6
6
|
|
7
|
+
# Class for parsing output from mediainfo
|
7
8
|
class Media
|
8
9
|
|
9
10
|
attr_reader :uri
|
@@ -26,7 +27,7 @@ module MiniMediainfo
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def introspect()
|
29
|
-
cmd = "mediainfo \"#{@uri}\""
|
30
|
+
cmd = "mediainfo \"#{@uri}\" -f"
|
30
31
|
key = ''
|
31
32
|
lines = []
|
32
33
|
keys = []
|
@@ -55,7 +56,12 @@ module MiniMediainfo
|
|
55
56
|
end
|
56
57
|
|
57
58
|
if (key && key.length > 0) && (media_attrs && media_attrs.length == 2)
|
58
|
-
|
59
|
+
# Only add the attribute if it does not exist already. When we parse
|
60
|
+
# full output from mediainfo we are only interested in the first
|
61
|
+
# entry that is unformatted and easier to work with
|
62
|
+
unless entries.find {|i| i[0] == key && i[1] == media_attrs[0]}
|
63
|
+
entries.push([key, media_attrs[0], media_attrs[1]])
|
64
|
+
end
|
59
65
|
end
|
60
66
|
end
|
61
67
|
|
data/spec/media_spec.rb
CHANGED
@@ -10,14 +10,10 @@ describe MiniMediainfo::Media do
|
|
10
10
|
context "when introspecting files" do
|
11
11
|
|
12
12
|
it "should introspect audio file" do
|
13
|
-
media = MiniMediainfo::Media.new("spec/
|
13
|
+
media = MiniMediainfo::Media.new("spec/support/small.mp4")
|
14
14
|
media.should_not be_nil
|
15
15
|
media.introspect
|
16
|
-
media.meta
|
17
|
-
['General', 'Audio'].each do |k|
|
18
|
-
media.meta.has_key?(k).should be_true
|
19
|
-
media.meta[k].size.should > 0
|
20
|
-
end
|
16
|
+
should_have_proper_data(media.meta)
|
21
17
|
end
|
22
18
|
|
23
19
|
end
|
@@ -40,12 +36,27 @@ describe MiniMediainfo::Media do
|
|
40
36
|
media = MiniMediainfo::Media.new("http://localhost:4567/small.mp4")
|
41
37
|
media.should_not be_nil
|
42
38
|
media.introspect
|
43
|
-
media.meta
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
should_have_proper_data(media.meta)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def should_have_proper_data(meta_data)
|
44
|
+
meta_data.is_a?(Hash).should be_true
|
48
45
|
|
46
|
+
['General', 'Audio', 'Video'].each do |k|
|
47
|
+
meta_data.has_key?(k).should be_true
|
48
|
+
meta_data[k].size.should > 0
|
49
49
|
end
|
50
|
+
# test format for a couple of key properties
|
51
|
+
number_format = /^[\d]+(\.[\d]+){0,1}$/
|
52
|
+
meta_data['General']['Duration'].should match(number_format) #ms
|
53
|
+
meta_data['Video']['Codec ID'].should_not be_nil # avc1
|
54
|
+
meta_data['Video']['Frame rate'].should match(number_format) # (fps)
|
55
|
+
meta_data['Video']['Width'].should match(number_format) # 1280
|
56
|
+
meta_data['Video']['Height'].should match(number_format) # 1280
|
57
|
+
meta_data['Video']['Format profile'].should_not be_nil # Main@L3.2
|
58
|
+
meta_data['Video']['Bit rate'].should match(number_format) # 1280
|
59
|
+
meta_data['Audio']['Bit rate'].should match(number_format) # 1280
|
60
|
+
meta_data['Audio']['Codec'].should_not be_nil # AAC
|
50
61
|
end
|
51
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_mediainfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Forsman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|