Create a QuickTime Image Sequence/Slideshow Movie with Custom Timing

QuickTime makes it easy to import an image sequence. However, there’s no way to modify the timing of the slides. So, I’ve been working on a script that turns an image sequence (PowerPoint slide export) into a custom timed slideshow.

The main idea behind this is to create an image sequence movie that will be timed to an audio narration; allowing someone to easily create a narrated slideshow that will retain the custom timing for each slide in the presentation - and as a bonus get synchronized chapter markers!

It works by creating a standard image sequence movie, then importing chapter markers into another movie. From there, it iterates through the image sequence, copying each image and adding them to the chapter marker movie according to the duration of each chapter (text frame).

The script works great on small test sequences (10 slides), but as soon as I tried it on a real presentation (77 slides) I encountered what seems to be random memory corruption during “add with scaled”, usually occurring 20-40 slides into the process. From what I’ve read online so far, there doesn’t seem to be much I can do about this.

Anyone have any thoughts or suggestions about what I can do at this point?

Thanks!

global slideMovie
global textMovie

global duration1

tell application "Finder"
	my openImageSequence(choose file with prompt "Select the first image in your image sequence.")
	my openTextSequence(choose file with prompt "Select the QuickTime Text file with your chapters.")
	my makeSlideShow()
	tell application id "com.apple.quicktimeplayer"
		close slideMovie saving no
		tell textMovie
			select none
			--set chapterlist of track "Audio Track" to track "Text Track"
			--set enabled of track "Text Track" to false
			save self contained in (path to desktop as string) & "SlideShow.mov"
		end tell
	end tell
end tell

on makeSlideShow()
	tell application id "com.apple.quicktimeplayer"
		activate
		tell slideMovie
			activate
			repeat with i from 1 to (number of frames in track 1)
				tell slideMovie
					activate
					set inPoint to time of (frame i) in (track 1)
					if (i + 1) is not greater than (number of frames in track 1) then
						set outPoint to time of (frame (i + 1)) in (track 1)
					else
						set outPoint to duration of track 1
					end if
					select at inPoint to outPoint
					copy
					--delay 1
				end tell
				my setSlidesInChapters(i as number)
			end repeat
		end tell
	end tell
end makeSlideShow

on setSlidesInChapters(chpt)
	tell application id "com.apple.quicktimeplayer"
		tell textMovie
			activate
			set inPoint to time of (text frame chpt) in (track 1)
			if (chpt + 1) is not greater than (number of frames in track 1) then
				set outPoint to time of (frame (chpt + 1)) in (track 1)
			else
				set outPoint to duration of track 1
			end if
			select at inPoint to outPoint
			add with scaled
			--Debug.  This tests to see if add with scaled changes the movie duration (this shouldn't happen)
			if duration of textMovie is greater than duration1 then
				display dialog (("While adding --> slide " & (chpt as string) & "<-- the movie duration changed.  New durration is " & duration of textMovie as string) & ".  Used startPoint " & inPoint as string) & " and endpoint " & outPoint as string
				set duration1 to duration of textMovie
			end if
			--end Debug
		end tell
	end tell
end setSlidesInChapters

on openTextSequence(textFile)
	tell application id "com.apple.quicktimeplayer"
		open textFile
		set textMovie to a reference to document (name of document 1)
		set duration1 to duration of textMovie
	end tell
end openTextSequence

on openImageSequence(firstSlide)
	tell application id "com.apple.quicktimeplayer"
		close every window
		open image sequence firstSlide seconds per frame 1
		set slideMovie to a reference to document (name of document 1)
		tell slideMovie
			set numberOfSlides to number of frames in track 1 as string
		end tell
	end tell
end openImageSequence

Here’s the 20 second, 10 slide chapter marker list that I used when I was building the script. For the slides, I just exported 10 slides from PPT as 1024x768 .jpg

{QTText}
[00:00:00.00] Slide 1
[00:00:02.00] Slide 2
[00:00:05.00] Slide 3
[00:00:06.00] Slide 4
[00:00:07.00] Slide 5
[00:00:08.00] Slide 6
[00:00:10.00] Slide 7
[00:00:13.00] Slide 8
[00:00:15.00] Slide 9
[00:00:16.00] Slide 10
[00:00:20.00]