[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Quicktime and Ruby

Ari Brown

7/10/2007 1:39:00 AM

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



8 Answers

matt

7/10/2007 2:59:00 AM

0

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?

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.

--
matt neuburg, phd = matt@tidbits.com, http://www.tidbits...
Tiger - http://www.takecontrolbooks.com/tiger-custom...
AppleScript - http://www.amazon.com/gp/product/...
Read TidBITS! It's free and smart. http://www.t...

12 34

7/10/2007 3:33:00 AM

0

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

hengist podd

7/10/2007 8:42:00 AM

0

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.sourc...
http://rb-appscript.rub...


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

Ari Brown

7/10/2007 12:05:00 PM

0


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?

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



Ari Brown

7/10/2007 12:12:00 PM

0

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


Ari Brown

7/10/2007 12:23:00 PM

0

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


On Jul 10, 2007, at 4:42 AM, hengist podd wrote:
> #!/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



matt

7/10/2007 2:03:00 PM

0

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?

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


--
matt neuburg, phd = matt@tidbits.com, http://www.tidbits...
Tiger - http://www.takecontrolbooks.com/tiger-custom...
AppleScript - http://www.amazon.com/gp/product/...
Read TidBITS! It's free and smart. http://www.t...

hengist podd

7/10/2007 2:23:00 PM

0

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.sourc...
http://rb-appscript.rub...

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