mxfinfo 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ *.lock
4
+ .rspec
5
+ .bundle
6
+ .config
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mxfinfo.gemspec
4
+ gemspec
5
+
6
+ group :test, :development do
7
+ gem "rspec"
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Steve Dierker
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ mxfinfo
2
+ =======
3
+
4
+ MXFinfo is a gem to use avidmxfinfo from http://ingex.sourceforge.net/ directly.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task :default => :spec
@@ -0,0 +1,55 @@
1
+ require 'time'
2
+
3
+ class MXFinfo
4
+ class InfoObject
5
+ module AttrReaders
6
+ # Add attribute reader for AVID MXF INFO attributes
7
+ def mxfinfo_attr_reader(method_name, mxfinfo_key = nil)
8
+ before_type_cast_method_name = "#{method_name}_before_type_cast"
9
+ mxfinfo_key = mxfinfo_key.gsub(/\s+/,"_").downcase if mxfinfo_key
10
+
11
+ # Define before_type_cast method alias {method_name}_before_type_cast
12
+ define_method before_type_cast_method_name do
13
+ if value = instance_variable_get("@#{before_type_cast_method_name}")
14
+ value
15
+ else
16
+ key = mxfinfo_key ? mxfinfo_key : method_name.to_s
17
+ value = @processed_data[key]
18
+
19
+ instance_variable_set "@#{before_type_cast_method_name}", value
20
+ instance_variable_get "@#{before_type_cast_method_name}"
21
+ end
22
+ end
23
+
24
+ # Define after_type_cast method alias {method_name}
25
+ define_method method_name do
26
+ if value = instance_variable_get("@#{method_name}")
27
+ value
28
+ else
29
+ value = send(before_type_cast_method_name)
30
+ value = yield value if value and block_given?
31
+
32
+ instance_variable_set "@#{method_name}", value
33
+ instance_variable_get "@#{method_name}"
34
+ end
35
+ end
36
+
37
+ MXFinfo::InfoObject.supported_attributes << method_name
38
+ end
39
+
40
+ def mxfinfo_date_reader(*a)
41
+ mxfinfo_attr_reader(*a) { |v| Time.parse v }
42
+ end
43
+
44
+ def mxfinfo_duration_reader(*a)
45
+ mxfinfo_attr_reader(*a) { |v|
46
+ value = v.split(" ")[2].gsub(/\(|\)/,"")
47
+ t = 0
48
+ tmp = value.split(":")
49
+ t = (tmp[0].to_i*60*60*1000) + (tmp[1].to_i*60*1000) + (tmp[2].to_i * 1000) + (tmp[3].to_i * 10)
50
+ t
51
+ }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ class MXFinfo
2
+ VERSION = "0.0.1"
3
+ end
data/lib/mxfinfo.rb ADDED
@@ -0,0 +1,111 @@
1
+ require "forwardable"
2
+ require "mxfinfo/version"
3
+ require "mxfinfo/attr_readers"
4
+
5
+ class MXFinfo
6
+ extend Forwardable
7
+ # We assume it's in the path of the user
8
+ @@binary = 'avidmxfinfo'
9
+
10
+ # BINARY CHANGE
11
+ def self.binary; @@binary; end
12
+ def self.binary=(binary); @@binary = binary; end
13
+
14
+ def self.scan(path)
15
+ info = InfoObject.new(path)
16
+ info.valid? ? info : nil
17
+ end
18
+
19
+ def self.import(data)
20
+ InfoObject.new(data, false)
21
+ end
22
+
23
+ class InfoObject
24
+ extend AttrReaders
25
+
26
+ # RAW AVIDMXFINFO OUTPUT
27
+ def raw_data; @mxfinfo; end
28
+
29
+ # Attributes
30
+ def self.supported_attributes; @supported_attributes ||= []; end
31
+
32
+ def initialize(input, process = true)
33
+ if process
34
+ @filepath = File.absolute_path(input)
35
+ File.exists?(@filepath.shellescape) ? @valid = true : @valid = false
36
+ @mxfinfo = mxfinfo if (process && @valid)
37
+ else
38
+ @valid = true
39
+ @mxfinfo = input
40
+ end
41
+ process_data if @valid
42
+ end
43
+
44
+ def valid?
45
+ @valid
46
+ end
47
+
48
+ mxfinfo_attr_reader :filename
49
+ mxfinfo_attr_reader :project_name
50
+ mxfinfo_attr_reader :clip_name
51
+ mxfinfo_date_reader :clip_created_at, "Clip Created"
52
+ mxfinfo_attr_reader :project_edit_rate
53
+ mxfinfo_attr_reader :clip_edit_rate
54
+ mxfinfo_duration_reader :clip_duration
55
+
56
+ mxfinfo_attr_reader :videotracks, "Clip Video Tracks"
57
+ def v_tracks; videotracks.to_i; end
58
+ alias_method :video_tracks, :v_tracks
59
+
60
+ mxfinfo_attr_reader :audiotracks, "Clip Audio Tracks"
61
+ def a_tracks; audiotracks.to_i; end
62
+ alias_method :audio_tracks, :a_tracks
63
+
64
+ mxfinfo_attr_reader :clip_track_string
65
+ mxfinfo_attr_reader :essence_type
66
+ mxfinfo_attr_reader :essence_label
67
+
68
+ mxfinfo_attr_reader :tracknumber, "Track Number"
69
+ def t_number; tracknumber.to_i; end
70
+ alias_method :track_number, :t_number
71
+
72
+ mxfinfo_attr_reader :edit_rate
73
+ mxfinfo_duration_reader :track_duration
74
+ mxfinfo_duration_reader :track_segment_duration
75
+ mxfinfo_duration_reader :track_segment_offset
76
+ mxfinfo_duration_reader :start_timecode
77
+ mxfinfo_attr_reader :audio_sampling_rate
78
+
79
+ mxfinfo_attr_reader :channelcount, "Channel Count"
80
+ def c_count; channelcount.to_i; end
81
+ alias_method :channel_count, :c_count
82
+
83
+ mxfinfo_attr_reader :quantizationbits, "Quantization Bits"
84
+ def q_bits; quantizationbits.to_i; end
85
+ alias_method :quantization_bits, :q_bits
86
+
87
+ mxfinfo_attr_reader :unc_path
88
+ mxfinfo_attr_reader :material_package_uid
89
+ mxfinfo_attr_reader :file_package_uid
90
+ mxfinfo_attr_reader :physical_package_uid
91
+ mxfinfo_attr_reader :physical_package_type
92
+ mxfinfo_attr_reader :physical_package_name
93
+ mxfinfo_attr_reader :physical_package_locator
94
+
95
+ private
96
+ def mxfinfo
97
+ # TODO: - add check if return data is valid
98
+ `#{MXFinfo.binary} #{@filepath.shellescape}`
99
+ end
100
+
101
+ def process_data
102
+ @processed_data = Hash.new
103
+ @mxfinfo.each_line do |line|
104
+ if line.include?("=")
105
+ key, value = line.split("=")[0], line.split("=")[1]
106
+ @processed_data[key.strip.gsub(/\s+/, "_").downcase] = value.strip
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
data/mxfinfo.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/mxfinfo/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Steve Dierker"]
6
+ gem.email = ["steve.dierker@flavoursys.com"]
7
+ gem.description = %q{MXFinfo is a gem to use avidmxfinfo from http://ingex.sourceforge.net/ directly in ruby.}
8
+ gem.summary = %q{MXFinfo is a gem to use avidmxfinfo from http://ingex.sourceforge.net/ directly in ruby.}
9
+ gem.homepage = "http://github.com/bigzed/mxfinfo"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "mxfinfo"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = MXFinfo::VERSION
17
+ gem.required_ruby_version = '>= 1.8.1'
18
+
19
+ end
@@ -0,0 +1,44 @@
1
+
2
+ Filename = /home/steved/Documents/git/mxfinfo/spec/fixtures/IMG_0395.MOV.A14DC7130D.mxf
3
+ Warning: Ignoring non-zero TimecodeComponent::StartTimecode because edit rate combination not supported
4
+ Project name = Ballerinas_zippy
5
+ Project edit rate = 25/1
6
+ Clip name = IMG_0395.MOV
7
+ Clip created = 2011-05-08 22:02:53.000
8
+ Clip edit rate = 25/1
9
+ Clip duration = 287 samples (00:00:11:12)
10
+ Clip video tracks = 1
11
+ Clip audio tracks = 1
12
+ Clip track string = V1 A1
13
+ Audio essence
14
+ Essence type = PCM
15
+ Essence label = 060e2b34040101010d01030102060200
16
+ Track number = 1
17
+ Edit rate = 48000/1
18
+ Track duration = 551040 samples (00:00:11:12)
19
+ Track segment duration = 551040 samples (00:00:11:12)
20
+ Track segment offset = 0 samples (00:00:00:00)
21
+ Start timecode = 0 samples (00:00:00:00)
22
+ Audio sampling rate = 48000/1
23
+ Channel count = 1
24
+ Quantization bits = 16
25
+ User comments:
26
+ UNC Path = Macintosh HD:Users:susannehassepass:Desktop:London 1video:IMG_0395.MOV
27
+ Material package attributes:
28
+ _IMPORTSETTING = __AttributeList
29
+ _DOMINANCE = 1
30
+ _IMPORTPICTSEQ = 0
31
+ _IGNOREALPHA = 0
32
+ _INVERTALPHA = 1
33
+ _ASPECT = 2
34
+ _IMPORTASPECT = 2
35
+ _COLORLEVEL = 1
36
+ _FORMAT = 2
37
+ _SRCFILE = __PortableObject
38
+ _ATN_IMPORT_AUD_BWF_MONO_GROUP = 1
39
+ Material package UID = 060a2b340101010101010f00130000004dc7130d05831a0a060e2b347f7f2a80
40
+ File package UID = 060a2b340101010101010f00130000004dc7130d05841a0a060e2b347f7f2a80
41
+ Physical package UID = 060a2b340101010101010f00130000004dc7130d05851a0a060e2b347f7f2a80
42
+ Physical package type = Import
43
+ Physical package name = IMG_0395.MOV
44
+ Physical package locator = file:///Macintosh%20HD/Users/susannehassepass/Desktop/London%201video/IMG_0395.MOV
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ describe "IMG_0395.MOV.A14DC7130D.mxf" do
4
+ before (:all) do
5
+ infoFile = File.open(name_to_fixture "IMG_0395.MOV.A14DC7130D.mxf.info")
6
+ @info = MXFinfo.import(infoFile.read)
7
+ end
8
+
9
+ it "should have a filename" do
10
+ @info.filename.should == "/home/steved/Documents/git/mxfinfo/spec/fixtures/IMG_0395.MOV.A14DC7130D.mxf"
11
+ end
12
+
13
+ it "should have a project name" do
14
+ @info.project_name.should == "Ballerinas_zippy"
15
+ end
16
+
17
+ it "should have a clip name" do
18
+ @info.clip_name.should == "IMG_0395.MOV"
19
+ end
20
+
21
+ it "should have a clip created at" do
22
+ @info.clip_created_at.should == Time.parse("2011-05-08 22:02:53.000")
23
+ end
24
+
25
+ it "should have a edit rate" do
26
+ @info.project_edit_rate.should == "25/1"
27
+ end
28
+
29
+ it "should have a clip duration" do
30
+ @info.clip_duration.should == 11120
31
+ end
32
+
33
+ it "should have a clip video tracks count" do
34
+ @info.video_tracks.should == 1
35
+ end
36
+
37
+ it "should have a clip audio tracks count" do
38
+ @info.audio_tracks.should == 1
39
+ end
40
+
41
+ it "should have a clip tracks string" do
42
+ @info.clip_track_string.should == "V1 A1"
43
+ end
44
+
45
+ it "should have a essence type" do
46
+ @info.essence_type.should == "PCM"
47
+ end
48
+
49
+ it "should have a essence label" do
50
+ @info.essence_label.should == "060e2b34040101010d01030102060200"
51
+ end
52
+
53
+ it "should have a track number" do
54
+ @info.track_number.should == 1
55
+ end
56
+
57
+ it "should have a edit rate" do
58
+ @info.edit_rate.should == "48000/1"
59
+ end
60
+
61
+ it "should have a track duration" do
62
+ @info.track_duration.should == 11120
63
+ end
64
+
65
+ it "should have a track segment duration" do
66
+ @info.track_segment_duration.should == 11120
67
+ end
68
+
69
+ it "should have a track segment offset" do
70
+ @info.track_segment_offset.should == 0
71
+ end
72
+
73
+ it "should have a start timecode" do
74
+ @info.start_timecode.should == 0
75
+ end
76
+
77
+ it "should have a audio sampling rate" do
78
+ @info.audio_sampling_rate.should == "48000/1"
79
+ end
80
+
81
+ it "should have a channel count" do
82
+ @info.channel_count.should == 1
83
+ end
84
+
85
+ it "should have a quantization bits" do
86
+ @info.quantization_bits.should == 16
87
+ end
88
+
89
+ it "should have a unc path" do
90
+ @info.unc_path.should == "Macintosh HD:Users:susannehassepass:Desktop:London 1video:IMG_0395.MOV"
91
+ end
92
+
93
+ it "should have a material package uid" do
94
+ @info.material_package_uid.should == "060a2b340101010101010f00130000004dc7130d05831a0a060e2b347f7f2a80"
95
+ end
96
+
97
+ it "should have a file package uid" do
98
+ @info.file_package_uid.should == "060a2b340101010101010f00130000004dc7130d05841a0a060e2b347f7f2a80"
99
+ end
100
+
101
+ it "should have a physical package uid" do
102
+ @info.physical_package_uid.should == "060a2b340101010101010f00130000004dc7130d05851a0a060e2b347f7f2a80"
103
+ end
104
+
105
+ it "should have a physical package type" do
106
+ @info.physical_package_type.should == "Import"
107
+ end
108
+
109
+ it "should have a physical package name" do
110
+ @info.physical_package_name.should == "IMG_0395.MOV"
111
+ end
112
+
113
+ it "should have a physical package locator" do
114
+ @info.physical_package_locator.should == "file:///Macintosh%20HD/Users/susannehassepass/Desktop/London%201video/IMG_0395.MOV"
115
+ end
116
+ end
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe MXFinfo do
4
+ before(:each) do
5
+ MXFinfo .class_variable_set :@@binary, 'avidmxfinfo'
6
+ end
7
+
8
+ describe "avidmxfinfo binary change" do
9
+ it "should be default on 'avidmxfinfo'" do
10
+ MXFinfo.binary.should == "avidmxfinfo"
11
+ end
12
+
13
+ it "should be changeable by MXFinfo.binary='new_path' " do
14
+ MXFinfo.binary.should == "avidmxfinfo"
15
+ MXFinfo.binary = "/bin/avidmxfinfo"
16
+ MXFinfo.binary.should == "/bin/avidmxfinfo"
17
+ end
18
+ end
19
+
20
+ it "should be instantiated with valid path" do
21
+ info = MXFinfo.scan(name_to_fixture "IMG_0395.MOV.A14DC7130D.mxf")
22
+ info.nil?.should == false
23
+ info.raw_data.empty?.should == false
24
+ end
25
+
26
+ it "should return nil if file doesn't exist" do
27
+ MXFinfo.scan("imagenary File").should == nil
28
+ end
29
+
30
+ it "should be possible to access raw data" do
31
+ info = MXFinfo.scan(name_to_fixture "IMG_0395.MOV.A14DC7130D.mxf")
32
+ info.nil?.should == false
33
+ infoFile = File.open(name_to_fixture "IMG_0395.MOV.A14DC7130D.mxf.info")
34
+ info.raw_data.should eql infoFile.read
35
+ end
36
+
37
+ it "should be possible to create infoObject from avidmxfinfo dump" do
38
+ infoFile = File.open(name_to_fixture "IMG_0395.MOV.A14DC7130D.mxf.info")
39
+ info = MXFinfo.import(infoFile.read)
40
+ info.valid?.should == true
41
+ end
42
+
43
+ it "should have supported attributes" do
44
+ supported_attributes = [:project_name,
45
+ :filename,
46
+ :clip_name,
47
+ :clip_created_at,
48
+ :project_edit_rate,
49
+ :clip_edit_rate,
50
+ :clip_duration,
51
+ :videotracks,
52
+ :audiotracks,
53
+ :clip_track_string,
54
+ :essence_type,
55
+ :essence_label,
56
+ :tracknumber,
57
+ :edit_rate,
58
+ :track_duration,
59
+ :track_segment_duration,
60
+ :track_segment_offset,
61
+ :start_timecode,
62
+ :audio_sampling_rate,
63
+ :channelcount,
64
+ :quantizationbits,
65
+ :unc_path,
66
+ :material_package_uid,
67
+ :file_package_uid,
68
+ :physical_package_uid,
69
+ :physical_package_type,
70
+ :physical_package_name,
71
+ :physical_package_locator]
72
+ MXFinfo::InfoObject.supported_attributes.each do |a|
73
+ supported_attributes.include?(a).should == true
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,23 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'mxfinfo'
8
+
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
20
+
21
+ def name_to_fixture(file)
22
+ File.join("#{File.dirname(__FILE__)}/fixtures",file)
23
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mxfinfo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Steve Dierker
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-12 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: MXFinfo is a gem to use avidmxfinfo from http://ingex.sourceforge.net/
15
+ directly in ruby.
16
+ email:
17
+ - steve.dierker@flavoursys.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - lib/mxfinfo.rb
28
+ - lib/mxfinfo/attr_readers.rb
29
+ - lib/mxfinfo/version.rb
30
+ - mxfinfo.gemspec
31
+ - spec/fixtures/IMG_0395.MOV.A14DC7130D.mxf
32
+ - spec/fixtures/IMG_0395.MOV.A14DC7130D.mxf.info
33
+ - spec/img_0395.mov.a14dc7130d_spec.rb
34
+ - spec/mxfinfo_spec.rb
35
+ - spec/spec_helper.rb
36
+ homepage: http://github.com/bigzed/mxfinfo
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.1
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 1.8.24
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: MXFinfo is a gem to use avidmxfinfo from http://ingex.sourceforge.net/ directly
60
+ in ruby.
61
+ test_files:
62
+ - spec/fixtures/IMG_0395.MOV.A14DC7130D.mxf
63
+ - spec/fixtures/IMG_0395.MOV.A14DC7130D.mxf.info
64
+ - spec/img_0395.mov.a14dc7130d_spec.rb
65
+ - spec/mxfinfo_spec.rb
66
+ - spec/spec_helper.rb