QuickTime Player refuses to export a trimmed movie

… when the target format is iPhone or Apple TV. I think the addressees of my topic are venerate users who know what QuickTime Player 7 is. It’s the app I still use but have stumbled upon this misbehaviour only now. Have you too?

The script’s backbone is the following code:

with timeout of (1000 * hours) seconds
	
		tell application "QuickTime Player 7"
			tell document 1
				set theDoc to a reference to it
 -- set trimming points and trim: the movie is trimmed successfully.

export theDoc to POSIX file "/Movies/MyMovie.m4v" as iPhone without replacing

-- export theDoc to POSIX file "/Movies/MyMovie.m4v" as Apple TV without replacing

end tell
		end tell
end timeout

At first, I suspected a malformed reference to the front document. However, the premise of a reference to is just that - to create a dynamic link that points to any front document. Since the trimmed document is the only one that’s at the front then there shouldn’t be any hindrance for AppleScript to identify it (which proves it’s the case with the export runs that produce a trimmed movie as I expect it to).

I double-checked and verified thoroughly that the problem is as much real as it’s odd: I used every other export format and extension - QuickTime Movie, images, a referenced movie, hinted movie etc - in each of these cases QTP accepts the trimmed version. As soon as I set the destination format to one of iPhone and Apple TV (with .m4v) it proceeds with the original untrimmed movie which isn’t what I want at all.

What’s with it?

I don’t have that version here, but I suspect the answer is that you need to pass a file reference, not a path.

I made a typo while composing the original message. I now updated it to reflect my actual code. I passed the POSIX file reference to export in my script. No dice.

To be clear: the problem isn’t that export doesn’t work. It works. It just goes AWOL when the export targets are either iPhone or Apple TV (both are enumerations in the DOM of QuickTime Player 7).

Update.

The script does not manifest this flaw in MacOS X 10.7. An old system but this part just flies there (I still do a lot of tasks that the newer generations struggle to deliver). It correctly identified the reference and took the trimmed movie not its untrimmed version. The export was a breeze.
The macOS where the issue showed up was 10.9. Looks like a ridiculous nasty bug.

I think, it isn’t application bug. Your script remembers the untrimmed document reference in the variable theDoc, then it exports it of course, and not trimmed document. You should get again document 1 after trimming, then export it instead. Not inside the tell block of “untrimmed” document.

I don’t have “QuickTime Player 7” to test my suggestion.


with timeout of (1000 * hours) seconds
   
       tell application "QuickTime Player 7"
          
           tell document 1
               set theDoc to a reference to it
-- set trimming points and trim: the movie is trimmed successfully.
end tell

set trimmedDoc to document 1
export trimmedDoc to POSIX file "/Movies/MyMovie.m4v" as iPhone without replacing

       end tell
end timeout

I tried your suggestion as the first aid solution relying on exactly same logic. It didn’t make a difference. Also, I specifically noted that the reference class returns the object implied by its name, that is, a reference to the object not the object it encapsulates. Read:

https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_operators.html#//apple_ref/doc/uid/TP40000983-CH5g-SW1

Also, my script operates in other macOS systems as expected. The message was not that it’s an application bug but that most certainly it’s a manifestation of underlining frameworks (such as a decoder/encoder) inconsistency.

Yes you are right. I understand now that you are keeping a reference to document 1 (i.e. object) and this should work correctly.

I would still send the export command to the application, not document 1. This is an unnecessary confusion that can lead to a number of hidden errors - in addition to the problem that already exists.

Try also adding some time delay after trimming. It’s hard to understand what’s going on without an application, so I’m leaving the topic.