Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RubyOSA for QuickTime

0 views
Skip to first unread message

12 34

unread,
Jul 3, 2007, 5:35:51 PM7/3/07
to
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

--
Posted via http://www.ruby-forum.com/.

Laurent Sansonetti

unread,
Jul 3, 2007, 5:57:10 PM7/3/07
to
Hi,

On 7/3/07, 12 34 <ruby...@web.knobby.ws> 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

12 34

unread,
Jul 3, 2007, 8:19:49 PM7/3/07
to
Laurent Sansonetti wrote:
> Hi,
>
> On 7/3/07, 12 34 <ruby...@web.knobby.ws> 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.

has

unread,
Jul 4, 2007, 3:39:41 AM7/4/07
to
On 3 Jul, 22:35, 12 34 <rubyfo...@web.knobby.ws> wrote:
> How do I access the properties of a QuickTime movie? I'm trying RubyOSA,
> but am open to other ideas.

Using rb-appscript (http://rb-appscript.rubyforge.org) to get
properties of the frontmost movie in QuickTime Player:


require 'appscript'
include Appscript

QTP = app('QuickTime Player.app')


movie = QTP.movies[1] # a reference to the frontmost movie
p movie.name.get # get movie name
p movie.duration.get # get movie duration
p movie.properties_.get # get all properties at once
# etc...

> I ultimately want to save the middle frame of movies I download from my
> digital camera.

To export the middle frame of a movie file to a PICT file:

movie = QTP.open(MacTypes::Alias.path('/path/to/your movie.mov'))[0]
movie.current_time.set(movie.duration.get / 2)
movie.export(:to=>MacTypes::FileURL.path('/path/to/middle
frame.pict'), :as=>:picture)
movie.close


To convert a PICT file to a JPEG file:

IA = app('Image Events')

img = IA.open(MacTypes::Alias.path('/path/to/middle frame.pict'))
img.save(:in=>'/path/to/middle frame.jpg', :as=>:JPEG)
img.close


HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

Laurent Sansonetti

unread,
Jul 4, 2007, 6:15:45 AM7/4/07
to
On 7/4/07, 12 34 <ruby...@web.knobby.ws> wrote:
> Laurent Sansonetti wrote:
> > Hi,
> >
> > On 7/3/07, 12 34 <ruby...@web.knobby.ws> 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.

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

> > 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.

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:

http://sourceforge.net/project/showfiles.php?group_id=44114

> 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

John Joyce

unread,
Jul 4, 2007, 11:15:09 AM7/4/07
to
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.

12 34

unread,
Jul 4, 2007, 1:52:22 PM7/4/07
to
Laurent Sansonetti wrote:
> On 7/4/07, 12 34 <ruby...@web.knobby.ws> 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:
>
> http://sourceforge.net/project/showfiles.php?group_id=44114
>
> Laurent

LoadError: no such file to load — osx/foundation

I'll be back later.

Jan Friedrich

unread,
Jul 5, 2007, 12:25:50 PM7/5/07
to
Why not use MiniExiftool? ;)

If Exiftool support your needs
http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/QuickTime.html
it should work.

Greets
Jan

12 34

unread,
Jul 5, 2007, 5:59:34 PM7/5/07
to
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.

0 new messages