Applescript- please try 2 compile this 3 line test script. It won't work for me!?!

Discussion in 'Mac Programming' started by physaux, Feb 11, 2010.

  1. physaux macrumors newbie

    Joined:
    Feb 11, 2010
    #1
    Hey guys, this is in reference to my other thread. I think I have narrowed down the problem. Anyways, here is the code:

    Code:
    tell application "QuickTime Player"
    trim document 1 from 0 to 2
    end tell
    
    Could somebody please try that and tell me if you can compile it?
    When I try I get the following error:
    Code:
    Expected end of line, etc. but found "from"
    I am using 'Script Editor'- Here is the version Data:
    http://img692.imageshack.us/img692/8130/picture3qf.png
    And I have Mac OS X 10.5.8

    What is wrong here??:confused::confused:
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #2
    try setting the movie document properties selection start and selection end first, then issue the trim command, by itself. Something like this (dunno if this would work exactly):

    Code:
    tell application "QuickTime Player"
    	tell document 1
    		set selection start to 0
    		set selection end to 2
    		trim
    	end tell
    end tell
     
  3. physaux thread starter macrumors newbie

    Joined:
    Feb 11, 2010
    #3
    I tried that, and it compiled properly. But it did not run properly.. I think I just need to upgrade to snow leopard.. :(
     
  4. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #4
    Weird, I just tried it and it seems to work, and I am on Leopard 10.5.8 as well. What I did find out, though, is that the values you use for the time depend on the "time scale" the movie uses. In my case the movie was 29.97 frames per second, and in this case QuickTime uses a time scale of 2997 units per second. For your example using the values 0 and 2, that would not work out well, since it'd be much less than one frame of any common video format. You need to get the time scale from the movie first. So if I want to trim off the first two seconds and the last three seconds of the movie, this works:

    Code:
    tell application "QuickTime Player"
    	tell document 1
    		set timeScale to time scale
    		set selection start to (timeScale * 2)
    		set selection end to (duration - (timeScale * 3))
    		trim
    	end tell
    end tell
     
  5. physaux thread starter macrumors newbie

    Joined:
    Feb 11, 2010
    #5
    omg amazing I am so happy thank you :)
    It is working now, yesssssssss :):):)

    I restarted my laptop and now it works fine :)
     

Share This Page