As in years past, I continue to work on my annual family video as a year-end project. As is my tradition, I always end my videos with a sort-of “outro” segment where I play a slideshow of family photos from the past year over some upbeat song.
The software I use, Cyberlink PowerDirector, has a nifty Slideshow Creator tool that makes it easy for you to drop your photos and music into one of several slick, pre-created templates for a cool slideshow. While this tool produces a neat product in a short amount of time, I’ve encountered a few problems with it:
- Slide order is not guaranteed. I often want particular photos to start the slideshow and particular ones to end it but no matter how I name my images alphabetically, the Slideshow Creator never seems to order my slides how I want them.
- I always have a challenge matching the number of images I want in my project to the length of the background music I want playing in the montage. Often, I have too many images for the length of song I’ve chosen and Slideshow Creator will repeat my song until it’s cycled through all my photos. I usually play a game of building my project with a certain amount of images and then trying to guess how many I need to delete to avoid Slideshow Creator repeating my song.
This year, I finally explored a second option: Theme Designer. It seems like Slideshow Creator is a layer of abstraction over Theme Designer, but PowerDirector allows you to bypass the Creator tool and work directly with the Designer. There’s less automation, but more control; however, my problems still remain: can I order my slides as I see fit and just how many photos can I use to cover the length of my chosen music?
The tutorial video is helpful and shows you that you have full control over the order of your images, but I still have the question about how many images I can include to fill the length of my chosen music. Here’s how I solved that problem.
Step 1: Measure the length of each template you want to use
In this example, I’ll focus on the Picture Frames theme. This theme has five templates:
- An Opening template that holds two images
- A Middle 1 template that holds three images
- A Middle 2 template that holds four images
- A Middle 3 template that holds five images
- and a Closing template that holds four images
What is the runtime for these templates? You can check the runtime in the preview on the right by dragging the timer all the way to the end of the segment–for the Opening template, the preview says it runs for seven seconds–but I’ve not found this preview to be completely honest.
I’ve found I’ve had to add each template to a new project, add images to all the templates, then drag the timer to the end of each template before I was confident in the true length of each sequence. In the case of the Picture Frames theme, I’ve found the runtimes of each template to be (rounding down to the nearest second):
- The Opening template runs for seven seconds
- The Middle 1 template runs for six seconds
- The Middle 2 template runs for ten seconds
- The Middle 3 template runs for 16 seconds
- and the Closing template runs for eight seconds
Step 2: Figure out your song length
You can easily figure out the length of the song for your slideshow by right-clicking on the file, clicking the Details tab, and finding the Length property.
Step 3: Let Python tell you the templates you need and the number of images to use
So, I know that my slideshow should run for 255 seconds. I know I want to use the Opening template only once at the beginning of the slideshow and the Closing template only once at the end. That’s 15 seconds out of 255: so I have 240 seconds to fill with some amount of the Middle templates. How many? Here’s some simple code I wrote to figure that out:
song_len_seconds = 255 # free fallin
opening_template = (7, 2) # nbr of seconds long, nbr of pictures in template (Picture Frames)
middle_template1 = (6, 3)
middle_template2 = (10, 4)
middle_template3 = (16, 5)
closing_template = (8, 4)
remaining_time = song_len_seconds - opening_template[0] - closing_template[0]
print('After subtracting the runtime of the opening and closing templates, remaining secs to fill with middle templates: {0}'. \
format(remaining_time))
print('Number of middle template combos to add to project: {0}'. \
format(remaining_time / (middle_template1[0] + middle_template2[0] + middle_template3[0])))
middle_factor = int(remaining_time / (middle_template1[0] + middle_template2[0] + middle_template3[0]))
print('Total seconds consumed by adding {0} middle template combos: {1}'. \
format(middle_factor, middle_factor*middle_template1[0] + middle_factor*middle_template2[0] + middle_factor*middle_template3[0]))
print('Remaining seconds to fill: {0}'. \
format(remaining_time - (middle_factor*middle_template1[0] + middle_factor*middle_template2[0] + middle_factor*middle_template3[0])))
total_pics = opening_template[1] + closing_template[1] + \
middle_factor*(middle_template1[1] + middle_template2[1] + middle_template3[1])
print('Number of pictures I\'ll need: {0}'.format(total_pics))
For simplicity, I just opted to use all three Middle templates in the same order: Middle 1, Middle 2, then Middle 3. By my calculations, after subtracting the Opening and Closing template runtimes, I will need to include seven Middle 1/Middle 2/Middle 3 combinations. Even after including seven of those combinations, I still have 16 additional seconds to fill–I didn’t write any code to recommend how to fill that time. I could fill it with one more Middle 3 template; of course, I’d want to make sure to place it in my project so that I don’t have two Middle 3 templates back-to-back.
My code also lets me know that an Opening, Closing, and seven Middle 1/Middle 2/Middle 3 combinations requires 90 images–which is nice for planning purposes.
Anyway, using some simple code like this will help me develop future slideshows more quickly and consistently.
Recent Comments