one-k-rmov 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.2.5 (March 3, 2009)
2
+
3
+ * adds pixel aspect ratio
4
+ * adds encoded pixel dimensions
5
+ * fixes issue with unsupported audio channel labels
6
+ * adds return value for audio channels of :UnsupportedByRMov for unsupported values
7
+ * adds :message for those unsupported cases
8
+
1
9
  0.2.4 (February 27, 2009)
2
10
 
3
11
  * changes symbols case to match QuickTime constants for channel descriptions (eg. :left becomes :Left)
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
-
5
- Echoe.new('rmov', '0.2.4') do |p|
4
+
5
+ Echoe.new('rmov', '0.2.5') do |p|
6
6
  p.summary = "Ruby wrapper for the QuickTime C API."
7
7
  p.description = "Ruby wrapper for the QuickTime C API. Updates by 1K include exposing some movie properties such as codec and audio channel descriptions"
8
- p.url = "http://github.com/ryanb/rmov"
8
+ p.url = "http://github.com/one-k/rmov"
9
9
  p.author = 'Ryan Bates, with updates by 1K Studios, LLC'
10
10
  p.email = "ryan (at) railscasts (dot) com"
11
11
  p.ignore_pattern = ["script/*", "tmp/*", "spec/output/*", "**/*.o", "**/*.bundle", "**/*.mov"]
data/ext/track.c CHANGED
@@ -478,23 +478,27 @@ static char* track_str_for_AudioChannelLabel(label) {
478
478
  case kAudioChannelLabel_CenterSurroundDirect:
479
479
  trackStr = "CenterSurroundDirect";
480
480
  break;
481
-
482
- default:
483
- rb_raise(eQuickTime, "Not Implemented: AudioChannelLabel in track_get_audio_channel_map : %d", label);
484
- break;
485
481
  }
486
482
 
487
483
  return trackStr;
488
484
  }
489
485
 
486
+ /*
487
+ call-seq: track_get_audio_channel_map() -> array
488
+
489
+ Returns an array n-channels in length
490
+ Array contains Hashes in the form: {:assignment => :description} where :description is a symbol representing an audio channel description. eg. :Left, :Right, :Mono
491
+
492
+ */
490
493
  static VALUE track_get_audio_channel_map(VALUE obj)
491
494
  {
492
495
  AudioChannelLayout *layout = track_get_audio_channel_layout(obj);
493
496
  if (layout == NULL) return Qnil;
494
497
 
495
498
  VALUE channels = Qnil;
496
- UInt32 numChannels, x;
499
+ UInt32 numChannels, x, highLayoutTag;
497
500
  VALUE channel;
501
+ char message[256];
498
502
  AudioChannelLayoutTag layoutTag = layout->mChannelLayoutTag;
499
503
 
500
504
  if (layoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) {
@@ -509,7 +513,16 @@ static VALUE track_get_audio_channel_map(VALUE obj)
509
513
  for (x=0; x < numChannels; x++) {
510
514
  desc = layout->mChannelDescriptions[x];
511
515
  trackStr = track_str_for_AudioChannelLabel(desc.mChannelLabel);
512
- ADD_CHANNEL(channels, channel, trackStr);
516
+
517
+ if (trackStr != NULL) {
518
+ ADD_CHANNEL(channels, channel, trackStr);
519
+
520
+ } else {
521
+ // unsupported audio channel labels
522
+ ADD_CHANNEL(channels, channel, "UnsupportedByRMov");
523
+ sprintf(message, "ChannelLabel unsupported by rmov: %d", desc.mChannelLabel);
524
+ rb_hash_aset(channel, ID2SYM(rb_intern("message")), rb_str_new2(message));
525
+ }
513
526
  }
514
527
 
515
528
 
@@ -520,7 +533,12 @@ static VALUE track_get_audio_channel_map(VALUE obj)
520
533
  if (layoutTag == kAudioChannelLayoutTag_UseChannelBitmap) {
521
534
  // use the bitmap approach
522
535
  // not implemented
523
- rb_raise(eQuickTime, "Not Implemented: kAudioChannelLayoutTag_UseChannelBitmap in track_get_audio_channel_map");
536
+ //rb_raise(eQuickTime, "Not Implemented: kAudioChannelLayoutTag_UseChannelBitmap in track_get_audio_channel_map");
537
+ for (x=0; x < numChannels; x++) {
538
+ ADD_CHANNEL(channels, channel, "UnsupportedByRMov");
539
+ rb_hash_aset(channel, ID2SYM(rb_intern("message")), rb_str_new2("UseChannelBitmap unsupported by rmov"));
540
+ }
541
+
524
542
 
525
543
 
526
544
  } else {
@@ -539,11 +557,17 @@ static VALUE track_get_audio_channel_map(VALUE obj)
539
557
  case kAudioChannelLayoutTag_MatrixStereo :
540
558
  ADD_CHANNEL(channels, channel, "LeftTotal");
541
559
  ADD_CHANNEL(channels, channel, "RightTotal");
542
-
560
+ break;
543
561
 
544
562
  default:
545
- // unsupported
546
- rb_raise(eQuickTime, "Unsupported ChannelLayoutTag in track_get_audio_channel_map: %d", layoutTag);
563
+ // unsupported channels
564
+ highLayoutTag = (layoutTag & 0xff0000) >> 16;
565
+ sprintf(message, "layoutTag unsupported by rmov: (%dL << 16) | %d", highLayoutTag, numChannels);
566
+ for (x=0; x < numChannels; x++) {
567
+ ADD_CHANNEL(channels, channel, "UnsupportedByRMov");
568
+ rb_hash_aset(channel, ID2SYM(rb_intern("message")), rb_str_new2(message));
569
+ }
570
+ //rb_raise(eQuickTime, "Unsupported ChannelLayoutTag in track_get_audio_channel_map: %d", layoutTag);
547
571
  break;
548
572
  }
549
573
 
@@ -556,6 +580,64 @@ static VALUE track_get_audio_channel_map(VALUE obj)
556
580
  return channels;
557
581
  }
558
582
 
583
+ /*
584
+ call-seq: track_encoded_pixel_dimensions() -> {:width => width, :height => height}
585
+
586
+ returns hash of dimensions {:width => width, :height => height} of the encoded pixel
587
+ dimensions
588
+ */
589
+ static VALUE track_encoded_pixel_dimensions(VALUE obj)
590
+ {
591
+ OSErr osErr = noErr;
592
+ ImageDescriptionHandle image_description = track_image_description(obj);
593
+ if (image_description == NULL) goto bail;
594
+
595
+ SInt32 width, height;
596
+ osErr = ICMImageDescriptionGetProperty(image_description, kQTPropertyClass_ImageDescription, kICMImageDescriptionPropertyID_EncodedWidth, sizeof(width), &width, NULL);
597
+ if (osErr != noErr) goto bail;
598
+
599
+ osErr = ICMImageDescriptionGetProperty(image_description, kQTPropertyClass_ImageDescription, kICMImageDescriptionPropertyID_EncodedHeight, sizeof(height), &height, NULL);
600
+ if (osErr != noErr) goto bail;
601
+
602
+ VALUE size_hash = rb_hash_new();
603
+
604
+ rb_hash_aset(size_hash, ID2SYM(rb_intern("width")), INT2NUM(width));
605
+ rb_hash_aset(size_hash, ID2SYM(rb_intern("height")), INT2NUM(height));
606
+
607
+ DisposeHandle((Handle)image_description);
608
+ return size_hash;
609
+
610
+ bail:
611
+ DisposeHandle((Handle)image_description);
612
+ rb_raise(eQuickTime, "Error %d when getting track_encoded_pixel_dimensions", osErr);
613
+ return Qnil;
614
+ }
615
+
616
+ /*
617
+ call-seq: track_pixel_aspect_ratio() -> aspect_ratio array [1, 1]
618
+ */
619
+ static VALUE track_pixel_aspect_ratio(VALUE obj)
620
+ {
621
+ OSErr osErr = noErr;
622
+ ImageDescriptionHandle image_description = track_image_description(obj);
623
+ if (image_description == NULL) goto bail;
624
+
625
+ PixelAspectRatioImageDescriptionExtension dimension;
626
+ osErr = ICMImageDescriptionGetProperty(image_description, kQTPropertyClass_ImageDescription, kICMImageDescriptionPropertyID_PixelAspectRatio, sizeof(dimension), &dimension, NULL);
627
+ if (osErr != noErr) goto bail;
628
+
629
+ // printf("\naspect ratio: %d:%d\n", dimension.hSpacing, dimension.vSpacing);
630
+ VALUE aspect_ratio = rb_ary_new3(2, INT2NUM(dimension.hSpacing), INT2NUM(dimension.vSpacing));
631
+
632
+ DisposeHandle((Handle)image_description);
633
+ return aspect_ratio;
634
+
635
+ bail:
636
+ DisposeHandle((Handle)image_description);
637
+ rb_raise(eQuickTime, "Error %d when getting track_encoded_pixel_dimensions", osErr);
638
+ return Qnil;
639
+ }
640
+
559
641
  void Init_quicktime_track()
560
642
  {
561
643
  VALUE mQuickTime;
@@ -571,9 +653,12 @@ void Init_quicktime_track()
571
653
  rb_define_method(cTrack, "codec", track_codec, 0);
572
654
  rb_define_method(cTrack, "width", track_width, 0);
573
655
  rb_define_method(cTrack, "height", track_height, 0);
656
+ rb_define_method(cTrack, "encoded_pixel_dimensions", track_encoded_pixel_dimensions, 0);
657
+ rb_define_method(cTrack, "pixel_aspect_ratio", track_pixel_aspect_ratio, 0);
658
+
574
659
  rb_define_method(cTrack, "channel_count", track_get_audio_channel_count, 0);
575
660
  rb_define_method(cTrack, "channel_map", track_get_audio_channel_map, 0);
576
-
661
+
577
662
  rb_define_method(cTrack, "id", track_id, 0);
578
663
  rb_define_method(cTrack, "delete", track_delete, 0);
579
664
  rb_define_method(cTrack, "enabled?", track_enabled, 0);
data/rmov.gemspec CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rmov}
5
- s.version = "0.2.4"
5
+ s.version = "0.2.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ryan Bates, with updates by 1K Studios, LLC"]
9
- s.date = %q{2009-03-01}
9
+ s.date = %q{2009-03-04}
10
10
  s.description = %q{Ruby wrapper for the QuickTime C API. Updates by 1K include exposing some movie properties such as codec and audio channel descriptions}
11
11
  s.email = %q{ryan (at) railscasts (dot) com}
12
12
  s.extensions = ["ext/extconf.rb"]
13
13
  s.extra_rdoc_files = ["CHANGELOG", "ext/exporter.c", "ext/extconf.rb", "ext/movie.c", "ext/rmov_ext.c", "ext/rmov_ext.h", "ext/track.c", "lib/quicktime/exporter.rb", "lib/quicktime/movie.rb", "lib/quicktime/track.rb", "lib/rmov.rb", "LICENSE", "README.rdoc", "tasks/setup.rake", "tasks/spec.rake", "TODO"]
14
14
  s.files = ["CHANGELOG", "ext/exporter.c", "ext/extconf.rb", "ext/movie.c", "ext/rmov_ext.c", "ext/rmov_ext.h", "ext/track.c", "lib/quicktime/exporter.rb", "lib/quicktime/movie.rb", "lib/quicktime/track.rb", "lib/rmov.rb", "LICENSE", "Manifest", "Rakefile", "README.rdoc", "spec/fixtures/settings.st", "spec/quicktime/exporter_spec.rb", "spec/quicktime/movie_spec.rb", "spec/quicktime/track_spec.rb", "spec/quicktime/hd_track_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/setup.rake", "tasks/spec.rake", "TODO", "rmov.gemspec"]
15
15
  s.has_rdoc = true
16
- s.homepage = %q{http://github.com/ryanb/rmov}
16
+ s.homepage = %q{http://github.com/one-k/rmov}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rmov", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib", "ext"]
19
19
  s.rubyforge_project = %q{rmov}
@@ -10,11 +10,15 @@ describe QuickTime::Track do
10
10
  before(:each) do
11
11
  @track = @movie.video_tracks.first
12
12
  end
13
-
13
+
14
14
  it "should have a codec of Apple ProRes 422 (HQ)" do
15
15
  @track.codec.should == "Apple ProRes 422 (HQ)"
16
16
  end
17
-
17
+
18
+ it "has video track aspect ratio of 1:1" do
19
+ @track.pixel_aspect_ratio.should == [1, 1]
20
+ end
21
+
18
22
  end
19
23
 
20
24
  describe "HD2.mov audio track" do
@@ -49,37 +53,57 @@ describe QuickTime::Track do
49
53
 
50
54
  end
51
55
 
52
- describe "SD3v2.mov audio tracks" do
56
+ describe "SD3v2.mov" do
53
57
  before(:each) do
54
58
  @movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/SD3v2.mov')
55
59
  end
56
60
 
57
- it "has audio track 0 with left/right" do
58
- track = @movie.audio_tracks[0]
59
- track.channel_map.should_not == nil
60
- track.channel_map[0][:assignment].should == :Left
61
- track.channel_map[1][:assignment].should == :Right
62
- end
61
+ describe "video track" do
62
+ before(:each) do
63
+ @track = @movie.video_tracks.first
64
+ end
63
65
 
64
- it "has audio track 1 with left/right" do
65
- track = @movie.audio_tracks[1]
66
- track.channel_map.should_not == nil
67
- track.channel_map[0][:assignment].should == :Left
68
- end
66
+ it "has size of 720x480" do
67
+ @track.width.should == 720
68
+ @track.height.should == 480
69
+ end
69
70
 
70
- it "has audio tracks with proper assignments" do
71
- channel_maps = @movie.audio_tracks.collect {|tr| tr.channel_map}
72
- channel_maps.should == [
73
- [{:assignment => :Left}, {:assignment => :Right}],
74
- [{:assignment => :Left}],
75
- [{:assignment => :Right}],
76
- [{:assignment => :Center}],
77
- [{:assignment => :LFEScreen}],
78
- [{:assignment => :LeftSurround}],
79
- [{:assignment => :RightSurround}],
80
- ]
71
+ it "has encoded pixel size of 720x480" do
72
+ @track.encoded_pixel_dimensions.should == {:width => 720, :height => 480}
73
+ end
74
+
75
+ it "has aspect ratio of 1:0.84375" do
76
+ @track.pixel_aspect_ratio.should == [100000, 84375]
77
+ end
81
78
  end
82
79
 
80
+ describe "audio tracks" do
81
+ it "has audio track 0 with left/right" do
82
+ track = @movie.audio_tracks[0]
83
+ track.channel_map.should_not == nil
84
+ track.channel_map[0][:assignment].should == :Left
85
+ track.channel_map[1][:assignment].should == :Right
86
+ end
87
+
88
+ it "has audio track 1 with left/right" do
89
+ track = @movie.audio_tracks[1]
90
+ track.channel_map.should_not == nil
91
+ track.channel_map[0][:assignment].should == :Left
92
+ end
93
+
94
+ it "has audio tracks with proper assignments" do
95
+ channel_maps = @movie.audio_tracks.collect {|tr| tr.channel_map}
96
+ channel_maps.should == [
97
+ [{:assignment => :Left}, {:assignment => :Right}],
98
+ [{:assignment => :Left}],
99
+ [{:assignment => :Right}],
100
+ [{:assignment => :Center}],
101
+ [{:assignment => :LFEScreen}],
102
+ [{:assignment => :LeftSurround}],
103
+ [{:assignment => :RightSurround}],
104
+ ]
105
+ end
106
+ end
83
107
  end
84
108
 
85
109
 
@@ -99,7 +123,39 @@ describe QuickTime::Track do
99
123
  [{:assignment => :Mono}],
100
124
  [{:assignment => :Mono}],
101
125
  ]
102
- end
126
+ end
127
+
128
+ it "has video track aspect ratio of 1:1" do
129
+ track = @movie.video_tracks.first
130
+ track.pixel_aspect_ratio.should == [1, 1]
131
+ end
132
+ end
133
+
134
+
135
+ describe "SD2v2.mov audio tracks" do
136
+ before(:each) do
137
+ @movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/SD2v2.mov')
138
+ end
139
+
140
+ it "has video track aspect ratio of 100000:112500" do
141
+ track = @movie.video_tracks.first
142
+ track.pixel_aspect_ratio.should == [100000, 112500]
143
+ end
144
+
103
145
  end
104
146
 
147
+ describe "exampleUnsupportAudio.mov audio tracks" do
148
+ before(:each) do
149
+ @movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/exampleUnsupportAudio.mov')
150
+ end
151
+
152
+ it "has audio tracks with proper assignments" do
153
+ channel_maps = @movie.audio_tracks.collect {|tr| tr.channel_map}
154
+ channel_maps.should == [
155
+ [{:assignment => :UnsupportedByRMov, :message => "ChannelLabel unsupported by rmov: 65537"}]
156
+ ]
157
+ end
158
+ end
159
+
160
+
105
161
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one-k-rmov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bates, with updates by 1K Studios, LLC
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-01 00:00:00 -08:00
12
+ date: 2009-03-04 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -64,7 +64,7 @@ files:
64
64
  - TODO
65
65
  - rmov.gemspec
66
66
  has_rdoc: true
67
- homepage: http://github.com/ryanb/rmov
67
+ homepage: http://github.com/one-k/rmov
68
68
  post_install_message:
69
69
  rdoc_options:
70
70
  - --line-numbers