# RubyOSA for QuickTime

**URL:** <https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480>\
**Category:** Ruby\
**Created:** [July 3, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480 "2007-07-03T23:35:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 3, 2007, 11:35pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/1 "2007-07-03T23:35:36Z")

</div>

How do I access the properties of a QuickTime movie? I’m trying RubyOSA,  
but am open to other ideas.

I ultimately want to save the middle frame of movies I download from my  
digital camera. That jpg will be a placeholder in Aperture. Here’s what  
I think are the essentials at this point

require ‘rbosa’  
require ‘fileutils’  
include FileUtils  
appQT = OSA.app(‘QuickTime Player’)  
src = “/Volumes/photos/”

filesCount = 0  
frameFilesCount = 0  
Find.find(src) do |fn|  
if File.file?(fn)  
if [’.mov’,’.avi’].include?(File.extname(fn).downcase)  
appQT.open(fn) # works  
frameCount = appQT.duration(“movie 1”) \>\> undefined method  
â€˜durationâ€™ for #OSA::QuickTimePlayer::Application:0x1065c24  
puts “frameCount: #{frameCount}”  
appQT.close(fn) # doesn’t work  
end  
end  
end  
puts

I looked at the output of appQT.methods and none of the items listed  
that made sense to me worked.

This newbie needs some help groking RubyOSA, Ruby, and QuickTime.

Thanks

---

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 3, 2007, 11:58pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/2 "2007-07-03T23:58:45Z")

</div>

Hi,

On 7/3/07, 12 34 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How do I access the properties of a QuickTime movie? I’m trying RubyOSA,  
> but am open to other ideas.

Why not trying to access the QTKit framework from Ruby via RubyCocoa?

Here is an example that prints all the metadata properties of a given  
movie.

$ cat a.rb  
require ‘osx/foundation’  
OSX.require\_framework ‘QTKit’  
puts OSX::QTMovie.movieWithFile\_error(ARGV[0], nil).movieAttributes

HTH,  
Laurent

---

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 4, 2007, 2:19am UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/3 "2007-07-04T02:19:44Z")

</div>

Laurent S. wrote:

> Hi,
> 
> On 7/3/07, 12 34 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > How do I access the properties of a QuickTime movie? I’m trying RubyOSA,  
> > but am open to other ideas.
> 
> Why not trying to access the QTKit framework from Ruby via RubyCocoa?

Didn’t know I could, and even if I had I didn’t know what do to with it.  
I thought RubyCocoa went to the other way. That is, to use Ruby in  
XCode. But obviously it’s more than that.

> Here is an example that prints all the metadata properties of a given  
> movie.
> 
> $ cat a.rb  
> require ‘osx/foundation’  
> OSX.require\_framework ‘QTKit’  
> puts OSX::QTMovie.movieWithFile\_error(ARGV[0], nil).movieAttributes
> 
> HTH,  
> Laurent

Either I’ve already installed RubyCocoa or I can’t. Neither machine will  
allow the pkg installer to work. And I tried by hand recently on my iMac  
desktop, and I got an error at some point.

So unless I figure out how to get around that I’m up a creek.

Also what is cat a.rb. I don’t find cat in Ruby, and man cat, tell me  
it’s concatenate and pring; but that doesn’t make sense to me in this  
context. Much to learn.

Thanks for any other further suggestions.

---

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 4, 2007, 12:17pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/4 "2007-07-04T12:17:46Z")

</div>

On 7/4/07, 12 34 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I thought RubyCocoa went to the other way. That is, to use Ruby in  
> XCode. But obviously it’s more than that.

Yes, it’s a real bridge between the Objective-C and the Ruby runtimes.

> Either I’ve already installed RubyCocoa or I can’t. Neither machine will  
> allow the pkg installer to work. And I tried by hand recently on my iMac  
> desktop, and I got an error at some point.

Ah, maybe you are running 10.4.10. The latest release won’t install on  
it because of an installer bug, but we released a minor version,  
called RubyCocoa-0.11.1p1, that you can get from the usual location:

> **[RubyCocoa - Browse Files at SourceForge.net](https://sourceforge.net/projects/rubycocoa/files/)**
>
> RubyCocoa is a Mac OS X framework that allows Cocoa programming in the object-oriented scripting language Ruby.

> So unless I figure out how to get around that I’m up a creek.
> 
> Also what is cat a.rb. I don’t find cat in Ruby, and man cat, tell me  
> it’s concatenate and pring; but that doesn’t make sense to me in this  
> context. Much to learn.

cat is an UNIX command-line tool that has nothing to do with Ruby  
here. Just look at the 3 lines of Ruby code 🙂

Laurent

---

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 4, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/5 "2007-07-04T17:16:25Z")

</div>

There is also an AppleScript gem.  
So you could use that to control any GUI app on OS X that has  
AppleScript events enabled. Most apps from Apple do have it enabled,  
and most apps for OS X have it, since it is one of the many things  
that the OS and the Cocoa framework provide to app programmers with  
very little effort at all.

---

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 4, 2007, 7:51pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/6 "2007-07-04T19:51:56Z")

</div>

Laurent S. wrote:

> On 7/4/07, 12 34 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Either I’ve already installed RubyCocoa or I can’t. Neither machine will  
> > allow the pkg installer to work. And I tried by hand recently on my iMac  
> > desktop, and I got an error at some point.
> 
> Ah, maybe you are running 10.4.10. The latest release won’t install on  
> it because of an installer bug, but we released a minor version,  
> called RubyCocoa-0.11.1p1, that you can get from the usual location:
> 
> [RubyCocoa - Browse Files at SourceForge.net](http://sourceforge.net/project/showfiles.php?group_id=44114)
> 
> Laurent

LoadError: no such file to load â€” osx/foundation

I’ll be back later.

---

<div class="post-metadata">

**Author:** ![mtnbiker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@mtnbiker](https://www.ruby-forum.com/u/mtnbiker)\
**Post date:** [July 5, 2007, 11:59pm UTC](https://www.ruby-forum.com/t/rubyosa-for-quicktime/108480/7 "2007-07-05T23:59:23Z")

</div>

12 34 wrote:

> LoadError: no such file to load â€” osx/foundation

Still have problem with RubyOSA

With solution using rb-appscript from HAS, I’ve got what I need for now.
