Saturday, March 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: 1014

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
macOS Mojave -- version 10.14.4, Ram 4 GB
Safari -- version 12.1
Firefox -- version 70.0

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: 1014

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
macOS Mojave -- version 10.14.4, Ram 4 GB
Safari -- version 12.1
Firefox -- version 70.0

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: 1014

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
macOS Mojave -- version 10.14.4, Ram 4 GB
Safari -- version 12.1
Firefox -- version 70.0

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: 1014

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
macOS Mojave -- version 10.14.4, Ram 4 GB
Safari -- version 12.1
Firefox -- version 70.0

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-24 02:27:46 pm

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

Re: Catalina killed my QuickTime Player script

Add at end of last script:

Applescript:

return theDuration

to see what is the duration of your clip

You should do the first log immediately after receiving the duration of the clip. To avoid similar confusion in the future. If the script is interrupted before an attempt to write due to some kind of error (in your original script is set current time to 731 code line), then you have some kind of old log.

If this is not the case, then try a script with a different clip. Sometimes a clip may have a defect.

Last edited by KniazidisR (2020-03-24 03:01:29 pm)


Model: MacBook Pro
macOS Mojave -- version 10.14.4, Ram 4 GB
Safari -- version 12.1
Firefox -- version 70.0

Offline

 

#13 Yesterday 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 (Today 05:17:52 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)