mini_mediainfo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 816cdb2d585902ded6c9f53fdca680d401045c6f
4
- data.tar.gz: 2ae6b4e586e26f8a73d6555d1461cf9a8a9dd27a
3
+ metadata.gz: 539cdca6b0af104abee626c213bae61c52c4de6c
4
+ data.tar.gz: dc5b92dc43a29f30b8f5798f1b679d1b4103c6f5
5
5
  SHA512:
6
- metadata.gz: 7eb28facd822f662ab267efe7b44d3f45788abc92d44c405ca71d7648cad932ce7a4128111e519e87ab847df41456051e598bfd07f1a29cd3d8e70275d92e387
7
- data.tar.gz: 1c182010720b7b559efa77970ca7b657a14cf4cbcec6a85fe0277edb0866f8de0251df061af8e75d1578914e6ccd09d3d23daed757c3045a5a5b114c4d90fa73
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'] # => "5s 568ms"
40
+ media.meta['General']['Duration'] # => "12345667"
41
41
  media.meta['Audio']['Compression mode'] # => "Lossy"
42
42
 
43
43
 
@@ -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
- entries.push([key, media_attrs[0], media_attrs[1]])
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
 
@@ -1,3 +1,3 @@
1
1
  module MiniMediainfo
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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/fixtures/napoleon.mp3")
13
+ media = MiniMediainfo::Media.new("spec/support/small.mp4")
14
14
  media.should_not be_nil
15
15
  media.introspect
16
- media.meta.is_a?(Hash).should be_true
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.is_a?(Hash).should be_true
44
- ['General', 'Audio', 'Video'].each do |k|
45
- media.meta.has_key?(k).should be_true
46
- media.meta[k].size.should > 0
47
- end
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.1
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-19 00:00:00.000000000 Z
11
+ date: 2013-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler