p2d
Home

Documentation

Tutorial

Tips

Sourceforge: Summary  |  Bugs |  Support |  RFE |  News |  CVS |  Files | 

Tutorial

Install p2d and follow along with this tutorial using your own pictures. The transitions take a while to generate, so I have kept things simple with only 3 transitions. On my 3Ghz machine it takes about one and a half minutes to generate the video. If you follow along, you can use xine to view the results.

Here is a simple script, I called gen, that will generate a basic configuration file using all the jpeg photos in the current directory. It shows each photo for 5 seconds and does a simple 1 second dissolve between photos.

#!/bin/sh
last=\"-black\"
for i in `ls *jpg`
do
    echo "1s    $last dissolve $i"
    echo "5s    $i"
    last=$i
done 
echo "1s    $last dissolve \"-black\""
Given a directory with the following 2 files in it (if your following along, create a new directory and put two images in it.)
20050621_1500.jpg
20050622_2053a.jpg
Running the above script
gen > show.cfg
will generate
1s    "-black" dissolve 20050621_1500.jpg
5s    20050621_1500.jpg
1s    20050621_1500.jpg dissolve 20050622_2053a.jpg
5s    20050622_2053a.jpg
1s    20050622_2053a.jpg dissolve "-black"
This is the setup for your typical, run of the mill, slide show. You can then generate a video with the command This will create a subdirectory named out, and after running it will the file video.mpg in it.. This is the composite video file. You can view the results with the command:
p2d show.cfg out
You can click here to view a small version of this video.

p2d supports many different transitions. Given all the choices, it's almost as easy to take a list of photo names, pick some transitions that fit and generate the configuration file by manually editing it. Here is another configuration file, built that way. I called this file show1.cfg.

xine out/video.mpg
0.5s  "-black"
1s    20050621_1500.jpg fill 1000% pan 100%
5s    20050621_1500.jpg
1s    20050621_1500.jpg box in 20050622_2053a.jpg
5s    20050622_2053a.jpg
1s    20050622_2053a.jpg wipe fromleft "-black" slide
0.5s "-black"
I'll explain what's happening (or just view the video and you may see what's happening. Better yet, if your following along and doing this with your own pictures, you can look at the video p2d generated from that.

The pan is an interesting transition. I wanted to start with a black screen, show the first picture as a small dot in the center and slowly expand it to full screen. I figure that a small dot means about 10% of the image in the center. This is a magnification of 10x or 1000%. The second line will start with that small image and then expand the image over 1 second to fill screen. The box transition, seemed appropriate next since it starts with the first photo on the line and slowly maps in the second image from the outer edges in to the center. (Imagine a box shrinking from full screen to the center, and as it procedes in, the second photo is revealed as the box passes thru the image.) Finally this uses a slide transition. I read the wipe transition as 20050622_2053a.jpg wipe in fromleft "-black" slide out. The black screen appears to push the last image off the screen.

Let's talk a little about transitions. First the wipe/slide transitions. As you saw in the previous example, a "wipe in fromleft .. slide out" transition can be described as follows. Imagine a vertical line moving from the left to the right of the screen, the "wipe in" means that the new image is revealed as the line passes that portion of the screen. The slide out, makes the old image appear to be pushed off the screen. You can use wipe or slide for either image, and from any side, fromleft, fromright, fromtop, or frombottom. You can also do wipes from the corners. So you could say

1s    20050622_2053a.jpg wipe fromtopleft "-black" wipe
0.5s "-black"
The corner wipes can only be a wipe. It doesn't really make sence to slide the image in or out diagonally.

The box transition can either start at the center and grow out, or at the edges and shrink in. Thus 'box in' and 'box out' transitions. There is also a 'diamond in' and 'diamond out' which behaves similarly, but uses a diamond shape.

We now have a video, although its only about 14 seconds long. What about audio? If you have been trying this yourself as you read along, you will notice that p2d generates a storyboard when it finishes. For my second example it looks like this: this

       Time    Duration Event
 0:00:00.00  0:00:14.00 audio  : -silence ( 0:07:00.00) 
 0:00:00.00  0:00:00.50 video  : -black crop 720x480+0+0 resize 720x480
 0:00:00.50  0:00:01.00 video  : 20050621_1500.jpg(2608x1952) center=1304,976
                                 mag=0.027 (10%,11%) pan to center=1304,976
                                 mag=0.276074 (100%,112%)
 0:00:01.50  0:00:05.00 video  : 20050621_1500.jpg crop 2607x1738+0+107 resize
                                 720x480
 0:00:06.50  0:00:01.00 video  : 20050621_1500.jpg box in 20050622_2053a.jpg
 0:00:07.50  0:00:05.00 video  : 20050622_2053a.jpg crop 2607x1738+0+107 resize
                                 720x480
 0:00:12.50  0:00:01.00 video  : 20050622_2053a.jpg wipe in FROMLEFT slide out
                                 -black
 0:00:13.50  0:00:00.50 video  : -black crop 720x480+0+0 resize 720x480
Run Time  0:00:14.00
Notice it supplied an audio track for us. But it's not very exciting. 14 seconds of silence. The config file below, adds a mp3 audio clip.
-     clip.mp3 audio
0.5s  "-black"
1s    20050621_1500.jpg fill 1000% pan 100%
5s    20050621_1500.jpg
1s    20050621_1500.jpg box in 20050622_2053a.jpg
5s    20050622_2053a.jpg
1s    20050622_2053a.jpg wipe fromleft "-black" slide
0.5s "-black"
This will use the audio clip "clip.mp3". When the last slide is finished the audio will stop. Notice that instead of a number the line starts with a minus sign. This means, use the length of the audio clip as the duration, well at least as much of it is needed. Another special case is using a minus sign for the duration of a photo. This means to display the photo until the current audio clip is finished.

You can also specify a fadein or fadeout on an audio clip. In our example, our 14 second video, the audio will end abruptly at 14 seconds. If we want to fade the sound out over the last second as the image wipes to black then stays on black for a while we could have used either of the following for the audio line.

14s     clip.mp3 audio fadeout 1
-       clip.mp3 audio fadeout 1
Finally, if you want to skip the beginning of the audio clip, you can use the trim modifier.
-     clip.mp3 audio trim 2 fadeout 1
This will start the audio clip 2 seconds into it.

Zoom

Each image allows a number of options to be set. You can specify a location on the image that you want to be at the center of the screen, and you can specify a zoom or magnification factor.
5s    20050621_1500.jpg 200% 800,600
5s    20050621_1500.jpg 200% bottomleft fill
5s    20050621_1500.jpg 200% bottomleft
The first line will magnify the picture to 200% and use 800x600 as the center. This of course means you need to know the size of the photo to figure out where you want the center to be. p2d provides 9 predefined points for you. The 4 corners (topleft, topright, bottomleft, bottomright), the mid-points of each side (top, bottom, left, right), and the center of the image. For everything else, I find it easier to bring up the photo in gimp and have it tell me the coordinates desired.

The second line above, specifies the bottomleft corner, which in this case happens to be 0,1952. Adding the word fill causes p2d to actually place the specified point at the center of the final image. It says to allow all the space where the image doesn't appear to be filled with the background image. This is the image on the left below. Since we haven't done anything with the background, the default is just a black screen.

fill image nofill image

The third line, doesn't use fill. p2d will move the center and adjust the zoom if necessary so that there are pixels to be seen everywhere. This is the picture on the right. In this case, p2d will increase the x, and decrease the y coordinates for the center so that the bottom left corner of the image is at the bottom left of the screen.

While the image on the left doesn't look very attractive, there are situations where it creates an interesting effect.

Titles

Other tools are much more capable of adding text to images. p2d does provide some very limited capabilities. Hopefully, just enough. Here is one more iteration of our example with some title information
-     clip.mp3 audio fadeout 1
0.5s  "-black" title "The Oregon Coast" color blue
1s    "-black" title "The Oregon Coast" color blue dissolve 20050621_1500.jpg 
5s    20050621_1500.jpg
1s    20050621_1500.jpg wipe fromtopleft 20050622_2053a.jpg
5s    20050622_2053a.jpg
title color yellow
subtitle 12 color yellow
1s    20050622_2053a.jpg diamond out  "-black" title "That's All Folks" subtitle "Copyright 2005 Stephen Dum" 
0.5s "-black" title "That's All Folks" subtitle "Copyright 2005 Stephen Dum" 
2.0s "-black" title "That's All Folks" subtitle "Copyright 2005 Stephen Dum" wipe frombottom "-black" slide
title and subtitle are modifiers that can be applied to images. There is some control over placement, but title is placed left justified, and a sub title is centered. The second and third line show a simple use of adding a title to an image. title and subtitle are also separate commands that can be used to change the default values. These are used in the 7th and 8th lines, so I didn't have to retype the data as many times. Putting everything needed on a single configuration line for a complex line like line 9 can make for very long lines. You can put a backslash at the end of a line and continue on the next line.

You can try the final video clip.

If you have been following along, you may have noticed that the videos linked to in this tutorial are not the same as the ones you have been generating. p2d has a special option, -w, which causes it to halve the dimentions of the images, making for a much faster download, and of course smaller images. This was used to generate the videos in the tutorial. Because the default settings for title and subtitle are really for 720x480 sized images, (they should be close enough for PAL users who use 720x576) when the image is reduced to 360x240, they don't work very well. Here is the config file that was actually used to generate the smaller video

-     clip.mp3 audio fadeout 1
0.5s  "-black" title "The Oregon Coast" color blue 24
1s    "-black" title "The Oregon Coast" color blue 24 dissolve 20050621_1500.jpg 
5s    20050621_1500.jpg
1s    20050621_1500.jpg wipe fromtopleft 20050622_2053a.jpg
5s    20050622_2053a.jpg
title 24 color yellow
subtitle 10 0,170 color yellow
1s    20050622_2053a.jpg diamond out  "-black" title "That's All Folks" subtitle "Copyright 2005 Stephen Dum" 
0.5s "-black" title "That's All Folks" subtitle "Copyright 2005 Stephen Dum" 
2.0s "-black" title "That's All Folks" subtitle "Copyright 2005 Stephen Dum" wipe frombottom "-black" slide

One final item. If you want a background other than the simple black you get by default, you can use the background command to change the default.

background "-blue"
background myimage.jpg 110%
The first line, would set a blue background. The second uses myimage.jpg with a slight zoom.

If you haven't downloaded and tried p2d yet, I hope this persuaded you to give it a try.

And now what do I do with this video

There are two obvious answers to this:
  • The video is playable with xine and windows media player, share it with friends.
  • Share it on the web. The -w option, generates a 360x240 lower resolution image video more suited for web viewing.
  • Create a dvd from it with a authoring tool like dvdstyler. One caution, I found that dvdstyler version 1.4 has a problem on Fedora Core 4 that prevents it from generating menus correctly. Until it's fixed, a hack to work around it, is to bring up the configuration settings menu and add the option '-S 420mp3g2' as an option for ppmtoy4m in the Jpeg2Mpeg command.

SourceForge.net logo

Copyright 2005 Stephen A. Dum