[Pythonmac-SIG] appscript and quicktime

Nicholas Riley njriley at uiuc.edu
Mon Oct 3 16:44:42 CEST 2005


On Mon, Oct 03, 2005 at 09:21:41AM +0200, captnswing wrote:
> if (can export movie 1 as DV stream) is true then
>      try
>          with timeout of 360 seconds
>              export movie 1 to POSIX file the_newname as DV stream  
> using settings the_settings with replacing
>          end timeout
>      on error errorMsg number errNo
>          ...
>      end try
> end if
> =================================================
> 
> can export? with timeout? not sure how to do this in appscript...

Generally you replace multi-word commands in AppleScript with
"word1_word2_..." in appscript.

In [6]: qt.help('-o')
[...]
Commands: 
    can_export 
[...]

In [7]: qt.can_export.help()
================================================================================
Appscript Help (-t)

Reference: app(u'/Applications/QuickTime Player.app').can_export 

-------------------------------------------------------------------------------- 
Description of reference

Terminology for can_export command

Command: can_export(...) -- Determine if a movie or track can be exported to the desired type 
    Reference -- the movie or track to export 
    as=k.AIFF | k.AVI | k.BMP | k.DV_stream | k.Fast_Start_QTVR_Movie | k.FLC | k.hinted_movie | k.image_sequence | k.interframe_compressed_VR_object_movie | k.MuLaw | k.MPEG2 | k.MPEG4 | k.picture | k.QuickTime_media_link | k.QuickTime_movie | k.QuickTime_TeXML | k.standard_MIDI | k.System_7_sound | k.text_file | k.ThreeGPP | k.wave -- the desired file type 
    Result: Boolean -- is the export supported 

================================================================================ 

In [8]: qt.can_export(qt.movies[1], as=k.DV_stream)
Out[8]: True

Timeout is a keyword argument to all commands, so you'd do something
like:

In [40]: qt.export(qt.movies[1], to='i:Users:nicholas:Desktop:foo.dv', as=k.DV_stream, replacing=True, timeout=360)

and you'd get back a CommandError exception if the event timed out.

> also the following:
> 
> 
> =================================================
> --get number of tracks and kind of movie
> tell application "QuickTime Player"
>      activate
>      open the_file
>      tell movie file_name
>          set track_count to the count of tracks
>          set track_kind to the kind of track 1
>      end tell
> end tell
> 
> --if movie is muxed mpeg
> if (track_count is equal to 1) and (track_kind contains "Muxed") then
> .....
> =================================================
> 
> 
> it is unclear to me how to get to the track_kind property of a movie
> are not all properties and functions mapped over to appscript?

In [14]: len(qt.movies[1].tracks())
Out[14]: 2

In [15]: qt.movies[1].tracks[1].kind()
Out[15]: u'Sound'

I think there are some things that appscript still doesn't do, but I
haven't ever run into them.

> also I wonder how you can tell which appscript command takes what  
> parameters.
> I remember the Quark Express discussion a while ago where there was a  
> astype parameter to the get command: pw.get(astype=k.Char)

You can either generate HTML documentation or interactively probe the
terminology with appscript; see:

<http://freespace.virgin.net/hamish.sanderson/appscripthelpsystem.html>

> and finally, what does the k. in the documentation  (and the above get 
> () call) stand for?

"keyword", I think.

-- 
Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>


More information about the Pythonmac-SIG mailing list