Quicktime and Ruby

Hey all

I read a previous post from early April about working applescript into Ruby. BUT....

I need to be able to convert mp3s into hinted movie format (which isn't covered ANYWHERE). Whats the best way to do this in any applescript wrapper?

Thanks,
Ari
-------------------------------------------|
Nietzsche is my copilot

Ari Brown wrote:

Hey all

I read a previous post from early April about working applescript
into Ruby. BUT....

I need to be able to convert mp3s into hinted movie format (which
isn't covered ANYWHERE). Whats the best way to do this in any
applescript wrapper?

Thanks,
Ari
-------------------------------------------|

I'm not sure I understand the question. But does this help

rb-appscript.rubyforge.org

This isn't what you're looking for, but gives an example of working with
a movie. I got the following in response to a question I asked from HAS:

require 'appscript'
include Appscript
QTP = app('QuickTime Player.app')

# 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

Hope this helps.

···

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

You can tell QuickTime Player to open each file and export it as a
hinted movie. This is not really a Ruby matter, though certainly you
might use Ruby as a basis for sending the necessary Apple events. m.

···

Ari Brown <ari@aribrown.com> wrote:

Hey all

I read a previous post from early April about working applescript
into Ruby. BUT....

I need to be able to convert mp3s into hinted movie format (which
isn't covered ANYWHERE). Whats the best way to do this in any
applescript wrapper?

--
matt neuburg, phd = matt@tidbits.com, Matt Neuburg’s Home Page
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

12 34 wrote:

This isn't what you're looking for, but gives an example of working with
a movie.

[...]
You're very close. Just needs some minor changes:

#!/usr/local/bin/ruby

require 'appscript'
include Appscript

QTP = app('QuickTime Player.app')

infile = '/path/to/your file.mp3'
outfile = '/path/to/your file.mov'

movie = QTP.open(MacTypes::Alias.path(infile))[0]
movie.export(:to=>MacTypes::FileURL.path(outfile), :as=>:hinted_movie)
movie.close

HTH

has

···

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

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

<snip>

require 'appscript'
include Appscript
QTP = app('QuickTime Player.app')

# 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

I saw that, and in fact that's what I'm using as my library. But I need to convert the file into Hinted Movie format. In quicktime, it's under File -> Export -> Hinted Movie

What would I write in ':as' if I wanted to do that? Or where could I get a list of possible file conversions for this?

aRi
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.

···

On Jul 9, 2007, at 11:33 PM, 12 34 wrote:

THANK YOU SO MUCH!

I'm SO glad that all I needed to do was alter the ':as' statement. You have made my life so much easier.

You see, there are 9000 songs which I am getting paid to convert.

has rules,
aRi
-------------------------------------------------------|
~ Ari
crap my sig won't fit

Hey, thanks for your help. I just have a quick question.

#!/usr/local/bin/ruby

require 'appscript'
include Appscript

QTP = app('QuickTime Player.app')

infile = '/path/to/your file.mp3'
outfile = '/path/to/your file.mov'

What does the 'MacTypes::Alias.path(infile))[0]' do?

movie = QTP.open(MacTypes::Alias.path(infile))[0]

                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't understand what the Alias and the [0] are doing. I guess it makes an alias of the file?

movie.export(:to=>MacTypes::FileURL.path(outfile), :as=>:hinted_movie)
movie.close

-------------------------------------------|
Nietzsche is my copilot

···

On Jul 10, 2007, at 4:42 AM, hengist podd wrote:

As I said, this is not a Ruby matter. You have to read the dictionary
(the AppleScript dictionary). m.

···

Ari Brown <ari@aribrown.com> wrote:

On Jul 9, 2007, at 11:33 PM, 12 34 wrote:
<snip>
> require 'appscript'
> include Appscript
> QTP = app('QuickTime Player.app')
>
> # 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

I saw that, and in fact that's what I'm using as my library. But I
need to convert the file into Hinted Movie format. In quicktime, it's
under File -> Export -> Hinted Movie

What would I write in ':as' if I wanted to do that? Or where could I
get a list of possible file conversions for this?

--
matt neuburg, phd = matt@tidbits.com, Matt Neuburg’s Home Page
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

Ari Brown wrote:

Hey, thanks for your help. I just have a quick question.

What does the 'MacTypes::Alias.path(infile))[0]' do?

movie = QTP.open(MacTypes::Alias.path(infile))[0]

                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I don't understand what the Alias

MacTypes::Alias.path(...) creates a new Alias object. The MacTypes
module is discussed in more detail in the appscript documentation.

and the [0] are doing.

QTP's 'open' command returns an array of references to the newly opened
movies, in this case [app('QuickTime Player').movies['some file']].
However, we just want the first item in that array so we call its #
method.

HTH

has

p.s. The equivalent line in AppleScript would read:

    set theMovie to item 1 of (open alias "HD:path:to:your file.mp3")

except that AppleScript uses an HFS path string rather than a POSIX one
for legacy reasons.

···

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

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