siskel 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ tmp/*
@@ -0,0 +1,3 @@
1
+ == 0.0.1 2009-07-18
2
+
3
+ * Initial release.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jonathan Dahl
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,171 @@
1
+ = Siskel
2
+
3
+ A video/audio file inspector, powered by MediaInfo (http://mediainfo.sourceforge.net/).
4
+
5
+ Siskel grew out of the RVideo project, and may replace the RVideo::Inspector library within RVideo. Head to http://groups.google.com/group/rvideo for more info.
6
+
7
+ == Install Siskel
8
+
9
+ gem install siskel
10
+
11
+ == Install MediaInfo
12
+
13
+ MediaInfo comes in a few versions, including a CLI (command-line interface) and a GUI version. You want the CLI.
14
+
15
+ Download for most platforms at http://mediainfo.sourceforge.net/en/Download.
16
+
17
+ Or build from source: http://mediainfo.sourceforge.net/en/Download/Source.
18
+
19
+ == Basic usage
20
+
21
+ results = Siskel.review(:file => 'path/to/myfile.mp4')
22
+
23
+ results[:format] # "MPEG-4"
24
+ results[:duration] # "208ms"
25
+ results[:audio][:format] # "AAC"
26
+ results[:video][:width] # "640 pixels"
27
+
28
+ == Details
29
+
30
+ Siskel just parses the results of MediaInfo and returns a hash of the results.
31
+
32
+ MediaInfo itself returns results like this (abbreviated):
33
+
34
+ General
35
+ Complete name : tmp/videos/triple_figures.mov
36
+ Format : MPEG-4
37
+
38
+ Video
39
+ Format : MPEG-4 Visual
40
+ Width : 624 pixels
41
+ Height : 352 pixels
42
+ Bits/(Pixel*Frame) : 0.299
43
+
44
+ Audio
45
+ Format : AAC
46
+ Bit rate : 128 Kbps
47
+ Sampling rate : 48.0 KHz
48
+ Channel(s) : 2 channels
49
+
50
+ "General" options appear at top level.
51
+
52
+ results[:complete_name] # "tmp/videos/triple_figures.mov"
53
+ results[:format] # "MPEG-4"
54
+
55
+ "Video" and "Audio" options are nested.
56
+
57
+ results[:video][:format] # "MPEG-4 Visual"
58
+ results[:video][:width] # "624 pixels"
59
+ results[:video][:height] # "352 pixels"
60
+ results[:video][:bits_pixel_frame] # "0.299"
61
+
62
+ results[:audio][:format] # "AAC"
63
+ results[:audio][:bit_rate] # "128 Kbps"
64
+ results[:audio][:sampling_rate] # "48.0 KHz"
65
+ results[:audio][:channels] # "2 channels"
66
+
67
+ Keys are downcased, cleaned up, and turned into symbols. Parentheses are ignored, and spaces and punctuation become underscores. So "Complete Name" becomes :complete_name, "Format Settings, BVOP" becomes :format_settings_bvop, and "Bits/(Pixel*Frame)" becomes :bits_pixel_frame.
68
+
69
+ == Sample MediaInfo output
70
+
71
+ General
72
+ Complete name : tmp/videos/triple_figures.mov
73
+ Format : MPEG-4
74
+ Format profile : QuickTime
75
+ Codec ID : qt
76
+ File size : 10.1 MiB
77
+ Duration : 40s 240ms
78
+ Overall bit rate : 2 104 Kbps
79
+ Performer : Flight Of The Conchords
80
+ Genre : TV Shows
81
+ Encoded date : UTC 2007-12-04 22:14:21
82
+ Tagged date : UTC 2007-12-04 22:14:22
83
+ Writing application : VisualHub 1.23
84
+ Writing library : Apple QuickTime 7.3.0
85
+ com.apple.quicktime.player.movie : (Binary)
86
+ tvsh : Flight Of The Conchords
87
+ tvsn : 1
88
+ tves : 1
89
+
90
+ Video
91
+ ID : 1
92
+ Format : MPEG-4 Visual
93
+ Format profile : Simple@L1
94
+ Format settings, BVOP : No
95
+ Format settings, QPel : No
96
+ Format settings, GMC : No warppoints
97
+ Format settings, Matrix : Default (H.263)
98
+ Codec ID : 20
99
+ Duration : 40s 240ms
100
+ Bit rate mode : Variable
101
+ Bit rate : 1 971 Kbps
102
+ Width : 624 pixels
103
+ Height : 352 pixels
104
+ Display aspect ratio : 16/9
105
+ Frame rate mode : Constant
106
+ Frame rate : 29.970 fps
107
+ Resolution : 24 bits
108
+ Colorimetry : 4:2:0
109
+ Scan type : Progressive
110
+ Bits/(Pixel*Frame) : 0.299
111
+ Stream size : 9.45 MiB (94%)
112
+ Writing library : Lavc51.38.0
113
+ Encoded date : UTC 1970-01-01 00:00:00
114
+ Tagged date : UTC 2007-12-04 22:14:22
115
+
116
+ Audio
117
+ ID : 2
118
+ Format : AAC
119
+ Format/Info : Advanced Audio Codec
120
+ Format version : Version 4
121
+ Format profile : LC
122
+ Format settings, SBR : No
123
+ Codec ID : 40
124
+ Duration : 40s 234ms
125
+ Bit rate mode : Variable
126
+ Bit rate : 128 Kbps
127
+ Channel(s) : 2 channels
128
+ Channel positions : L R
129
+ Sampling rate : 48.0 KHz
130
+ Resolution : 16 bits
131
+ Stream size : 629 KiB (6%)
132
+ Encoded date : UTC 1970-01-01 00:00:00
133
+ Tagged date : UTC 2007-12-04 22:14:22
134
+
135
+ == Why MediaInfo?
136
+
137
+ RVideo used ffmpeg for file inspection, via "ffmpeg -i /path/to/file.mp4". This is sort of a hack; the -i flag is not "inspect", but "input file". So this command just calls ffmpeg with a file but doesn't tell ffmpeg what to do, and ffmpeg returns a bunch of data as a result.
138
+
139
+ But the biggest problem with using ffmpeg for file inspection is that the data returned by "ffmpeg -i" changes every few months. So the library is highly coupled to a particular version of SVN checkout of ffmpeg, which sucks.
140
+
141
+ MediaInfo has only one purpose: to return this sort of data. Its text output doesn't change nearly as frequently as ffmpeg's, and if it does, it will be far easier to keep Siskel up to date with these changes. (MediaInfo has very little syntax: just headers and key/value pairs separated by colons. ffmpeg's output is verbose and unstructured.)
142
+
143
+ A few other reasons for using MediaInfo for file inspection: it's reportedly faster than ffmpeg, and it's far smaller and simpler to install.
144
+
145
+ The downside is that if you're already using ffmpeg, you need to install yet another video/audio tool. But MediaInfo is simple and small enough that this isn't a big deal.
146
+
147
+ == Help out!
148
+
149
+ For questions, bug reports, or improvements, head over to the RVideo Google Group: http://groups.google.com/group/rvideo.
150
+
151
+ == LICENSE
152
+
153
+ (The MIT License)
154
+
155
+ Copyright © 2009 Jonathan Dahl
156
+
157
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
158
+
159
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
160
+
161
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
162
+
163
+ == Shameless Plugs
164
+
165
+ Check out Zencoder (http://zencoder.com), a scalable video transcoding product.
166
+
167
+ * Blog: http://railspikes.com
168
+ * GitHub: jondahl (http://github.com/jondahl)
169
+ * Twitter: @jondahl (http://twitter.com/jondahl)
170
+ * Other Startup: http://tumblon.com
171
+ * Consulting: http://phronos.com
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "siskel"
8
+ gem.summary = %Q{A nippy video metadata inspector library}
9
+ gem.description = %Q{Inspect a video/audio file for properties and metadata, using mediainfo}
10
+ gem.email = "jphastings@gmail.com"
11
+ gem.homepage = "http://github.com/jphastings/AirVideo"
12
+ gem.authors = ["JP Hastings-Spital","Jon Dahl"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ task :default => :build
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
@@ -0,0 +1,44 @@
1
+ class Siskel
2
+
3
+ # results = Siskel.review(:file => 'path/to/myfile.mov')
4
+ # results[:format] # => 'MPEG-4'
5
+ # results[:video][:frame_rate] # => '29.970 fps'
6
+
7
+ class << self
8
+ def review(options = {})
9
+ raise ArgumentError, "Must supply either an input file or a pregenerated response" if options[:raw_response].nil? and options[:file].nil?
10
+ raise ArgumentError, "File not found: #{options[:file]}" if options[:file] and !FileTest.exist?(options[:file])
11
+ parse_results(options[:raw_response] || `mediainfo "#{options[:file]}"`)
12
+ end
13
+
14
+ def parse_results(mediainfo_results)
15
+ mediainfo_results.split("\n").inject({}) do |siskel_results, row|
16
+ result = parse_row(row)
17
+ if result.is_a?(Symbol)
18
+ @prefix = result
19
+ siskel_results[@prefix] ||= {}
20
+ elsif result.is_a?(Hash)
21
+ if @prefix.nil?
22
+ siskel_results[result.keys.first] = result.values.first
23
+ else
24
+ siskel_results[@prefix][result.keys.first] = result.values.first
25
+ end
26
+ end
27
+ siskel_results
28
+ end
29
+ end
30
+
31
+ def parse_row(row)
32
+ results = /(.*) : (.*)/.match(row)
33
+ if results
34
+ return { make_key(results[1]) => results[2].strip }
35
+ elsif row =~ /\w+/ && row !=~ /General/i
36
+ return row.strip.downcase.to_sym
37
+ end
38
+ end
39
+
40
+ def make_key(str)
41
+ str.strip.gsub(/[\(\)]/, "").gsub(/\W+/, "_").gsub(/_$/, "").downcase.to_sym
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{siskel}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["JP Hastings-Spital", "Jon Dahl"]
12
+ s.date = %q{2010-08-01}
13
+ s.description = %q{Inspect a video/audio file for properties and metadata, using mediainfo}
14
+ s.email = %q{jphastings@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "CHANGELOG",
21
+ "MIT-LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/siskel.rb",
26
+ "siskel.gemspec",
27
+ "test/fixtures/test_mediainfo_results.rb",
28
+ "test/fixtures/tiny.mp4",
29
+ "test/siskel_test.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/jphastings/AirVideo}
32
+ s.rdoc_options = ["--charset=UTF-8"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{A nippy video metadata inspector library}
36
+ s.test_files = [
37
+ "test/fixtures/test_mediainfo_results.rb",
38
+ "test/siskel_test.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ else
47
+ end
48
+ else
49
+ end
50
+ end
51
+
@@ -0,0 +1,67 @@
1
+ class TestMediainfoResults
2
+ def self.triple_figures
3
+ "General
4
+ Complete name : tmp/videos/triple_figures.mov
5
+ Format : MPEG-4
6
+ Format profile : QuickTime
7
+ Codec ID : qt
8
+ File size : 10.1 MiB
9
+ Duration : 40s 240ms
10
+ Overall bit rate : 2 104 Kbps
11
+ Performer : Flight Of The Conchords
12
+ Genre : TV Shows
13
+ Encoded date : UTC 2007-12-04 22:14:21
14
+ Tagged date : UTC 2007-12-04 22:14:22
15
+ Writing application : VisualHub 1.23
16
+ Writing library : Apple QuickTime 7.3.0
17
+ com.apple.quicktime.player.movie : (Binary)
18
+ tvsh : Flight Of The Conchords
19
+ tvsn : 1
20
+ tves : 1
21
+
22
+ Video
23
+ ID : 1
24
+ Format : MPEG-4 Visual
25
+ Format profile : Simple@L1
26
+ Format settings, BVOP : No
27
+ Format settings, QPel : No
28
+ Format settings, GMC : No warppoints
29
+ Format settings, Matrix : Default (H.263)
30
+ Codec ID : 20
31
+ Duration : 40s 240ms
32
+ Bit rate mode : Variable
33
+ Bit rate : 1 971 Kbps
34
+ Width : 624 pixels
35
+ Height : 352 pixels
36
+ Display aspect ratio : 16/9
37
+ Frame rate mode : Constant
38
+ Frame rate : 29.970 fps
39
+ Resolution : 24 bits
40
+ Colorimetry : 4:2:0
41
+ Scan type : Progressive
42
+ Bits/(Pixel*Frame) : 0.299
43
+ Stream size : 9.45 MiB (94%)
44
+ Writing library : Lavc51.38.0
45
+ Encoded date : UTC 1970-01-01 00:00:00
46
+ Tagged date : UTC 2007-12-04 22:14:22
47
+
48
+ Audio
49
+ ID : 2
50
+ Format : AAC
51
+ Format/Info : Advanced Audio Codec
52
+ Format version : Version 4
53
+ Format profile : LC
54
+ Format settings, SBR : No
55
+ Codec ID : 40
56
+ Duration : 40s 234ms
57
+ Bit rate mode : Variable
58
+ Bit rate : 128 Kbps
59
+ Channel(s) : 2 channels
60
+ Channel positions : L R
61
+ Sampling rate : 48.0 KHz
62
+ Resolution : 16 bits
63
+ Stream size : 629 KiB (6%)
64
+ Encoded date : UTC 1970-01-01 00:00:00
65
+ Tagged date : UTC 2007-12-04 22:14:22"
66
+ end
67
+ end
Binary file
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'fixtures/test_mediainfo_results'
5
+ require 'lib/siskel'
6
+
7
+ class SiskelTest < Test::Unit::TestCase
8
+
9
+ context "Siskel reviewer" do
10
+ should "return a results hash with raw results" do
11
+ results = Siskel.review(:raw_response => TestMediainfoResults.triple_figures)
12
+ assert_equal Hash, results.class
13
+ end
14
+
15
+ should "return a results hash when passed a file" do
16
+ results = Siskel.review(:file => 'fixtures/tiny.mp4')
17
+ assert_equal Hash, results.class
18
+ end
19
+
20
+ should "raise an exception if neither file nor raw results are provided" do
21
+ assert_raises ArgumentError do
22
+ results = Siskel.review
23
+ end
24
+ end
25
+
26
+ should "raise an exception if file not found" do
27
+ assert_raises ArgumentError do
28
+ results = Siskel.review(:file => 'fixtures/not_there.mp4')
29
+ end
30
+ end
31
+
32
+ context "results" do
33
+ setup do
34
+ @results = Siskel.review(:raw_response => TestMediainfoResults.triple_figures)
35
+ end
36
+
37
+ should "have general attributes" do
38
+ assert @results[:general]
39
+ assert @results[:video]
40
+ assert @results[:audio][:format]
41
+ end
42
+ end
43
+
44
+ context "compatibility" do
45
+ # TODO: add suite of compatibility tests
46
+ # should_inspect_media :file => 'file'
47
+ # should_inspect_media :response => 'response'
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: siskel
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 1
10
+ version: 1.0.1
11
+ platform: ruby
12
+ authors:
13
+ - JP Hastings-Spital
14
+ - Jon Dahl
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-08-01 00:00:00 +01:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description: Inspect a video/audio file for properties and metadata, using mediainfo
24
+ email: jphastings@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files:
30
+ - README.rdoc
31
+ files:
32
+ - .gitignore
33
+ - CHANGELOG
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION
38
+ - lib/siskel.rb
39
+ - siskel.gemspec
40
+ - test/fixtures/test_mediainfo_results.rb
41
+ - test/fixtures/tiny.mp4
42
+ - test/siskel_test.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/jphastings/AirVideo
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --charset=UTF-8
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.7
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: A nippy video metadata inspector library
77
+ test_files:
78
+ - test/fixtures/test_mediainfo_results.rb
79
+ - test/siskel_test.rb