Thursday, May 28, 2020

#1 2020-03-23 02:08:51 am

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Catalina killed my QuickTime Player script

Hello all,

I had a couple of scripts running, ever since macOS Yosimite I think, that now seem to fail after migrating to Catalina.

Here is what happens:
I have a TV-recording-file of about 2 hour long that contains Flower Power clips.
I have defined start- and stop-positions of each clip and have an applescript that takes care of the trimming.
As I said, the script has been running fine for years, but now I cannot get it to work any longer.

The script:
set savePath to (the path to the desktop folder as text) & "__716.m4v"

set unixFile to "/Volumes/4TP1/BackUp/Top40/1111-11-11.m4v"
set macFile to POSIX file unixFile

tell application "QuickTime Player"
   activate
   try
      stop the front document
      close saving no
      close the front document
   end try

   open macFile
   
   set theDuration to the duration of the front document

   delay 4

   set tDoc to open file macFile
   tell tDoc
      set current time to theDuration
   delay 4
      -- position at the title, just for a nice preview
      set current time to 731
   delay 4
do shell script "echo " & "'==== theDuration = " & theDuration & " ====' > /tmp/debug_out"
do shell script "echo " & "'trim from 716 to 1082' >> /tmp/debug_out"
      trim from 716 to 1082
   end tell

   delay 4

   export the front document in file savePath using settings preset "1080p"

   delay 4

   try
      stop the front document
      close the front document without saving
   end try
end tell


The delays and shell-script lines are there just for myself, just to be able to find out what is going on.
The lines:
      set current time to theDuration     and
      set current time to 731
are there, just to make sure the start- and endpositions are OK, and they are! QuickTime Player flawlessly positions on both frames.

When running the script however I get:
% osascript < _Applescript_8134_trim
767:788: execution error: QuickTime Player got an error: End time must be less than or equal to duration (6)

/tmp/debug_out contains:
==== theDuration = 7187.04 ====
trim from 716 to 1082

I have tried integer as well as float representations of the start- and stop-numbers but nothing seems to work anymore.

Anybody any clues on to how to get it going again? Thanks!

Model: MacBook Pro (late 2013), macOS 10.15.4
Browser: Safari 605.1.15
Operating System: macOS 10.14

Offline

 

#2 2020-03-23 04:38:44 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina killed my QuickTime Player script

I don't know. On Mojave the following script works fine:

Applescript:


set savePath to (path to the desktop folder as text) & "__716.m4v"
set macFile to choose file of type "m4v"

tell application "QuickTime Player"
   activate
   close documents saving no
   close windows
   
   tell (open macFile)
       set theDuration to duration -- set TO time
       set current time to theDuration / 2 -- set FROM time
       trim from (current time) to theDuration
   end tell
   
   export front document in file savePath using settings preset "1080p"
   close documents saving no
   close windows
   quit
end tell

Last edited by KniazidisR (2020-03-23 04:42:06 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#3 2020-03-23 05:54:08 am

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

I know... Mine worked fine under Mojave too...

Still, no luck under Catalina.

Offline

 

#4 2020-03-23 09:46:03 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina killed my QuickTime Player script

MacAdam,

I didn’t tell you: most likely it’s not bug of Catalina. I ran your script on  Mojave and got the same error as you. Then I ran my script, and the clip was safely saved to the desktop.

I think the whole point is that you open the same clip twice, and the second time you open the clip incorrectly. The fact is that the reference you specified at the beginning:

Applescript:


set macFile to POSIX file unixFile

is already a file reference, not a Posix path. Therefore, coercion file MacFile should not be performed.

So, you definitely ran my script as is? Changing nothing in it? I use alias (instead of file reference), with which QuickTime Player works fine.

Last edited by KniazidisR (2020-03-23 09:55:16 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#5 2020-03-23 06:33:22 pm

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

Well, I agree that I should not have opened the macfile twice but removing the 'open macFile'-line did not produce different results.


What DID make things going was, instead of just 'trim from 716 to 1082':

try
      trim from 716 to 1082
end try

heaven knows why, but my script again started to do what it has been doing for years!

Offline

 

#6 2020-03-24 02:43:45 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina killed my QuickTime Player script

MacAdam wrote:

Well, I agree that I should not have opened the macfile twice but removing the 'open macFile'-line did not produce different results.


Well, you just hid the error, not corrected it. In addition, you do not understand. I already told you that you need to remove the second opening of the file, which is incorrect. And you removed the correct opening of the file - the first. If you really do not want to just run someone else's script... it is really difficult to learn something.

Last edited by KniazidisR (2020-03-24 03:21:23 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#7 2020-03-24 05:44:15 am

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

I have modified my script so that it looks exactly like yours...
It works well, but it DOES need the try/end try around the trim, otherwise it keeps complaining about the end time (End time must be less than or equal to duration (6)).

set savePath to (the path to the desktop folder as text) & "__716.m4v"

set unixFile to "/Volumes/4TP1/BackUp/Top40/1111-11-11.m4v"
set macFile to POSIX file unixFile

tell application "QuickTime Player"
   activate
   close documents saving no
   close windows

   tell (open macFile)
      set theDuration to duration
      -- position at the title, just for a nice preview
      set current time to 731
      delay 4
      try
         trim from 716 to 1082
      end try
   end tell
   delay 4

   export the front document in file savePath using settings preset "1080p"
   delay 4

   close documents without saving
   close windows
end tell

Offline

 

#8 2020-03-24 05:57:54 am

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

Now guess what... This works too:

   tell (open macFile)
      set theDuration to duration
      -- position at the title, just for a nice preview
--      set current time to 731
--      delay 4
--      try
         trim from 716 to 1082
--      end try
   end tell

I wonder if the 'set current time' is the one that confuses QuickTime Player...???

Offline

 

#9 2020-03-24 06:10:38 am

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

Now I AM confused...

It runs in about 8 of 10 times, it complains about the end time on the other 2 occasions...


After changing the code to:

   tell (open macFile)
      set theDuration to duration
      -- position at the title, just for a nice preview
      set current time to 731
      delay 4
      try
         trim from 716 to 1082
      end try
   end tell


it runs just fine 10 out of 10 times...

Offline

 

#10 2020-03-24 01:45:41 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina killed my QuickTime Player script

Your settings 731, 716 and 1082 should not be longer than the total duration of your clip. The way you use try block, without catching the error, just hides this error, does not fix it.

Add at end of last script:

Applescript:

return theDuration

to see what is the duration of your clip


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#11 2020-03-24 01:48:45 pm

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

See my original posting...

/tmp/debug_out contains:
==== theDuration = 7187.04 ====
trim from 716 to 1082


The movie is about 2 hours long...

Offline

 

#12 2020-03-27 08:01:02 am

MacAdam
Member
Registered: 2020-03-22
Posts: 8

Re: Catalina killed my QuickTime Player script

Dear KniazidisR,

Can you please indicate what version of Catalina you are running?
I run 10.15.4 (19E264b)

And starting today (mar 28) that is: macOS 10.15.4 (19E266)

Kind regards,
Adam

Last edited by MacAdam (2020-03-28 05:17:52 am)

Offline

 

#13 2020-03-29 02:33:08 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina killed my QuickTime Player script

Hi, MacAdam.

I just switched to Catalina, and now I can answer your question definitely: the trim command of the QuickTime Player application has an insignificant but unpleasant bug: it cuts the movie correctly, but for some reason it gives an error message for the error that does not exist.

To get rid of this stupid message, you can:

1) Put the trim command in a try block, as you did.
2) Ask Apple to fix the stupid bug.
3) Put the trim command in the ignoring application responses block to gag the QuickTime Player application:

Applescript:


set savePath to (path to the desktop folder as text) & "__716.m4v"
set macFile to choose file of type "m4v"

tell application "QuickTime Player"
   activate
   close documents saving no
   close windows
   
   tell (open macFile)
       set aDuration to get duration
       set curTime to aDuration / 2
       ignoring application responses
           trim from curTime to aDuration
       end ignoring
   end tell
   
   export front document in file savePath using settings preset "1080p"
   close documents saving no
   close windows
end tell

Last edited by KniazidisR (2020-03-29 02:38:27 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)