I've been interested in this for some time now, and recently have figured out some neat (to me at least) things I can create for my own home movie dvds. I thought I'd create a thread where I can share this with the forum and also see what ideas others might have on the same topic. I'll start off with more basic options in this first post (banners/titles/credits), and will follow up with more advanced ideas like creating your own transitions from scratch, screen in screen, and others.
Note: My camera takes videos that are 640x480 in frame size, and the dvds I make are in NTSC format 720x480. All examples I provide assume these specifications, but it shouldn't be too hard to translate this to your specific situation.
Banners/Titles: I like to include a short title segment before each of my home movies. Of course, there are a number of editing suites in Linux which will do this for you, but this is about making your own. The easiest way I know to do this is to use dvd-slideshow. I create an all black png image and type the title information in large white font on the image using gimp (I store the original in xcf format as well just in case I want to make edits). Then I use dvd-slideshow to turn the png image into dvd video. To make things work best, you should make sure the format of your dvd encoded movie file and the title segment you are creating will match up (same frame rate, size, audio codec, audio bitrate, etc). You can either change how you encode your movies, or the settings in dvd-slideshow, or both to make these match. In my case, I ended up editing the dvd-slideshow bash file and changing the applicable switch on the ffmpeg line from “-ac 6” to “-ac 2” so it would create stereo ac3 audio instead of 6 channel ac3. There is no one right way to do this, so long as both dvd ready files will match up so you can append them in avidemux later. Here is an example of a dvd-slideshow input file to create a title segment:This will start with a black frame, fade the credits in, and then fade back to pure black. Since the background of the credits page is also black, only the credits themselves will fade in and out. The only problem now is that if you append this in front of your home movie file you will have a rather abrupt transition from a black screen to the first frame of your video. There are many ways to handle this (more below), but one quick and easy way is to use the fade in filter in avidemux to have the first 15 or so frames fade from black when you encode your home movie to dvd format. Once you have both your title segment and your movie segment coded, you can then join them together with avidemux. First open the title segment, and then select File/Append and have avidemux append the dvd-movie file. From here all you have to do is make sure the video & audio settings are set to “ copy”, and set the format to “mpeg-ps” and save the combined video using a new name.Code:background:0::black fadein:0.5 title.png:2 fadeout:0.5
Two quick notes on opening dvd-slideshow generated files with avidemux: if you create a dvd encoded file that is less than 35 frames, avidemux will give you an error when you try to open it. The segment created above is 2 seconds long so it won't present a problem. However, if you start working with very short transitions (right around 1 sec or less) you could run into this issue. Also, when avidemux first opens an mpeg file it creates an index for that file. If you create a new vob with with the same name as one you have already opened with avidemux, you need to delete the old .idx file before opening it with avidemux or the video will appear as if it was corrupt because it opened the file using the old .idx file. If you have problems opening a dvd-slideshow file with avidemux, first check for these two issues.
The title segment above is pretty snappy, but after I started doing this of course I wanted more. Why not crossfade from the title.png to the first frame of the video? Avidemux will let you export any frame of a video as either a jpeg or bmp file, so I tried this out with a bmp of the first frame of a video which had already been encoded in dvd format. First I had to open the bmp file in gimp and then save it as a .png file so dvd-slideshow could handle it. Then I ran dvd-slideshow, crossfading from my title image to the first frame in the video:
Unfortunately, once I mated the two files up in avidemux I found out that dvd-slideshow changed the shape of the first frame so it didn't match up (try this to see what I mean). This gave a nice smooth fade, followed by an abrupt wobbly transition to the moving video. After playing with this for a while, it turns out there is a simple fix for this; stretch the firstframe.png file so it is 112% of its original height, leaving the width alone. After using gimp to stretch the png image to 720x538 pixels, it works perfectly! You can also use the other transition option in dvd-slideshow (wipe) the same way if you want, and have the movie push aside the title screen.Code:background:0::black fadein:.5 title.png:2 crossfade:1 firstframe.png:0.534 #(0.034 seconds creates a single frame at 29.97 fps. See note on timing below.)
Introductory & Final Credits: These are very much like the title segments, but I like to do something a little different here. One thing that looks nice is to create one image with just a title like “Credits” at the top, and another copy of the same image with the credits included below. Then you can crossfade from the bare “credits” page to the one with the credit information included. If you have multiple credits pages you can use this to fade the credits themselves in and out while having the title “credits” remain on the screen the entire time.
Having text fly in from the distance (or fly out if you wish): Start with a 720x480 (or 720x538 if you wish) black image, and center “Created with Linux” on the page with large white font, naming the file “linux.png”. Next, resize the canvas to 10x the original size, (7200x4800) and create a new black layer background to fill in the new canvas space and name this “big_linux.png”. This will cause your original text to look tiny when you view the entire image. Then use the dvd-slideshow kenburns feature to make the phrase fly in:
You can do the same fly in/out effect with a frame from a movie as well. Lets say this time you want to start with the first frame of your unprocessed video file named “firstframe.bmp”. Since my unprocessed movies are 640x480, I need to either stretch the image or add black bars to bring the width to 720. Then I need to stretch the height by 12% to account for the fact that dvd-slideshow resizes the height back down. You could do this with gimp, but here is how I do this with imagemagick (more on this great tool later). Run the following into the command lines in a folder where you placed the first frame of your unprocessed movie (titled firstframe.bmp):Code:background:0::black fadein:.5 big_linux.png:.534 big_linux.png:.5::kenburns:100%;middle;10%;middle linux.png:4 #you could also use the big version with “::crop:10%;middle” to hold the zoom. fadeout:.5
Now that we have the base image ready to go, we need to center it in a black background 10 times it's size:Code:convert -size 720x480 xc:black black_im.png # create an all black image composite -gravity center firstframe.bmp black_im.png firstframe.png # Combine the first frame over the black image creating a new png file with bars. convert firstframe.png -resize 100%x112% firstframe.png #Stretch the image height to 12% taller.Now you can use the following as the input file for dvd-slideshow to create a title segment using a zoom transition to the first frame of the video:Code:convert -size 7200x5380 xc:black big_black_im.png # create a really big all black image composite -gravity center firstframe.png big_black_im.png big_firstframe.png #center the frame in the big black image.
Note on dvd-slideshow timing: Older versions of dvd-slideshow had a very straightforward way of parsing timing. All you had to do was enter the amount of time each line should generate in the slideshow. Starting with version 0.8, they changed this for reasons entirely unclear to me. Now the time for any transition line is subtracted equally from the time of the lines above and below it. This is pretty straightforward (but still unnecessarily complex) if you have a picture showing for 4 seconds with transition lines before and after it each lasting 1 second. What this means is the picture will only be shown for a total of 3 seconds, with .5 seconds devoted to each of the transition effects before and after it (for a total subtraction of 1 sec). In cases of an initial fade in or a final fadeout, the image line closest to the transition has the entire transition time deducted from it's playing time. So if you have an image at the end of the show with a 1 second crossfade before it and a 1 second fadeout after it, you would need to set the time for that image to 4.5 seconds to have it display for a total of 3 seconds.Code:background:0::black fadein:.5 title.png:3 fadeout:.5 background:0.409 crossfade:0.25 big_firstframe.png:.159 big_firstframe.png:1::kenburns:100%;middle;10%;middle
+ Reply to Thread
Results 1 to 5 of 5
More advanced transitions and effects:All of the examples above relied on the transition or kenburns capability built into dvd-slideshow. But what if you want to make your own custom transitions or effects? This is very simple when you put the following three facts together:
1)You can export every frame in a movie file to a series of images using either avidemux or ffmpeg.
2)Imagemagick allows you to manipulate images in truly amazing ways from the command line.
3)You can convert a series of image files into video using dvd-slideshow, avidemux, ffmpeg, or mencoder.
Put another way; using a bash script, you can do anything with moving video that you can do to a single image file using imagemagick! For more information on imagemagick, check out this page on the command line options, as well as this page on use examples. This tool is really amazing, and what I'll show below will only scratch the surface!
Creating a barn door wipe transition: I like the barn door wipe transition in Kino, but for reasons I won't go into now I would prefer to process my videos in avidemux. So I decided to “roll my own” barndoor wipe transition. We'll start with two images, title.png (black with white writing), and firstframe.png (the first frame of an unprocessed video). Both images are 640x480 in size (different than the examples above). To make the first frame of the video push in from the the sides over the title image, all you have to do is paste progressively skinnier crops of the title page centered over the first frame. The following script will generate the frames for this effect:Code:
#!/bin/bash tmpname=tmpcrop.png ext=.png startimage=title.png endimage=firstframe.png qual="100%" echo "Creating the animation frames and the dvdslideshow text file." percent=100 counter=0 while (( percent > 0 )) do counter=$(($counter+1)) convert $startimage -gravity center -crop $percent%x100% -quality $qual $tmpname composite -gravity center $tmpname $endimage -quality $qual frame$counter$ext percent=$(($percent-2)) done
convert -gravity center $endimage \( $startimage -gravity center -crop $percent%x100% +repage \) -composite -quality $qual frame$counter$ext
After you run the script, you should have a series of images named frame1.png, frame2.png, etc. If you want to view them as a video, open the first frame in avidemux, and it will pull the rest in. From here you can add an audio track (even if it is just silence), and convert the video to whatever format you want (more on this later). One thing you will notice is the title page is only shown in full for one frame. To make this useful as a title frame you need to create additional video making the title page fade in and then hold for a few seconds before transitioning to the first frame of the video. Since dvd-slideshow can handle creating the initial fade in and display of the title frame, and also can convert the clip into dvd ready video and audio (silence), I use the following script to turn the whole thing into a title segment ready to be appended in front of the movie file. All you have to do is place this script in a folder containing the first frame of the video the title is for (named “ff.bmp”), the title.png image, and a text file named "slideshowstart.txt" (which contains the dvd-slideshow commands you want to fade in and display the title page) and run the script.Code:
#!/bin/bash ext=.png startimage=title.png endimage=ff.bmp qual="100%" #check to see if title image and first frame exist. if [ ! -e $startimage ]; then read -p "$startimage not found. Exiting script." exit 0 fi #end if [ ! -e $startimage ] if [ ! -e $endimage ]; then read -p "$endimage not found. Exiting script." exit 0 fi #end if [ ! -e $endimage ] #Make sure both input files are 720 x 538 pixels. Add black bars on sides of the endimage if needed (in case image came from unprocessed avi file). convert $endimage -resize 100%x112% tmpimage1.png #stretch the bmp to make it taller convert -size 720x538 xc:black tmp_black.png #create an all black image composite -gravity center tmpimage1.png tmp_black.png tmpimage2.png #overlay the stretched image on the black image. If it was less than 720, black bars will be appear. endimage=tmpimage2.png convert $startimage -resize 720x538! $startimage echo "Creating the animation frames and the dvdslideshow text file." vobname=title_barndoortrans percent=100 counter=0 while (( percent > 0 )) do counter=$(($counter+1)) convert -gravity center $endimage \( $startimage -gravity center -crop $percent%x100% +repage \) -composite -quality $qual frame$counter$ext echo "frame$counter$ext:0.034" >> tmp_dvdslideshow.txt echo "Created frame$counter$ext" percent=$(($percent-3)) done #check to see if there are files with dvd-slideshow commands to be inserted first or last if [ -e slideshowstart.txt ]; then echo "found dvd-slideshow commands for the front of the file" cat slideshowstart.txt tmp_dvdslideshow.txt > tmp.txt cat tmp.txt > tmp_dvdslideshow.txt rm tmp.txt fi if [ -e slideshowend.txt ]; then echo "found dvd-slideshow commands for the end of the file" cat slideshowend.txt >> tmp_dvdslideshow.txt fi #Render the slideshow dvd-slideshow -n $vobname -f 'tmp_dvdslideshow.txt' # remove the old vob.idx file (if present), plus the dvd-slideshow log file, and the dvd-slideshow xml file and script temp files. echo "Cleaning up temporary files." rm $vobname.vob.idx rm $vobname.log rm $vobname.xml rm tmpimage1.png rm tmpimage2.png rm tmp_dvdslideshow.txt rm tmp_black.png #clean up the animation frames while (( counter > 0 )) do rm frame$counter$ext counter=$(($counter-1)) done
Creating your own fade transition: If you aren't using dvd-slideshow, you may want to create your own crossfade script. Here is the key line to place within the script loop:Code:
composite -blend $percent -gravity center $endimage $startimage -matte -quality $Qual frame$counter$extCode:
ffmpeg -i movie.avi images%05d.png
Mountain Man, you and I are doing much the same thing. I have found some ways to add some extra effects to my video titles by using Fred Weinhaus scripts. Here is a link to Fred's scripts http://www.fmwconcepts.com/imagemagick/index.php. I use Gimp and Fred's Glow script to make one of the title images. I will then use DVD-SLIDESHOW to convert it to a video. I will then use FFMPEG or AVIDEMUX to extract the images into folder. I will then use some more scripts to modify those images.
Good link optrader, and also good to see I'm not the only one playing around with this! I suggest looking at those scripts even for those who plan on writing their own scripts (like me), because it gives a good idea of the breadth of what ImageMagick is capable of. I've been playing around with masks/transparency, and should have a script to do with moving video what he calls "Radial Gradient" on the Transitions page.
In my posts above all of the transitions involved moving from one still frame to another, and a gui editor was needed for at least part of the processing. I've been working on this further, and this post will describe how to:
- 1) Join two movie files together.
2) With a transition involving moving video (not still images).
3) All from the command line.
We'll start assuming you have two video files you want to join together using one of the transitions described in my second post above. Ideally you have avoided any lossy conversions when editing these two files to this point. You should also be in a new directory since this process will create a number of files you will want to clean up later.
Assuming you want to have the two files joined together with 1 second of transition, the first thing we need to do is break each file up into two parts; the main body of each file, and the 1 second clips which will be used for the transition. For file1 the body will be all of the file except the last second, and for file2 the body will be the entire file following the first second. Using ffmpeg, we can perform the cuts with the following commands:
For file 1 (file1.avi):
#create a file with the last second of video. # clip1starttime is expressed as hh:mm:ss.ss and represents 1 second from the end of the file. #use ffmpeg -i file1.avi to see the duration of the file. Then subtract 1 second. ffmpeg -ss clip1starttime -i file1.avi -vcodec ffv1 -acodec pcm_s16le -ar 44100 -ac 2 clip1.avi #create the body of the video (all but last second). ffmpeg -t clip1starttime -i file1.avi -vcodec ffv1 -acodec pcm_s16le -ar 44100 -ac 2 body1.avi
#create a file with the first second of video ffmpeg -t 00:00:01.00 -i file2.avi -vcodec ffv1 -acodec pcm_s16le -ar 44100 -ac 2 clip2.avi #create the body of the video (all but first second) ffmpeg -ss 00:00:01.00 -i file2.avi -vcodec ffv1 -acodec pcm_s16le -ar 44100 -ac 2 body2.avi
ffmpeg -i clip1.avi clip1_image%d.bmp ffmpeg -i clip2.avi clip2_image%d.bmp
Note: I'm using bitmap images here instead of png images because I've run into intermittent problems with ffmpeg not liking the png images imagemagick creates.
Once you run your transition script, you will now have a stream of images representing the finished transition. We will use ffmpeg to convert this stream of images back into video shortly, but first we need to handle the audio track.
First use ffmpeg to extract the audio tracks from clip1 and clip2 as wav files:Code:
ffmpeg -i clip1.avi -acodec copy clip1.wav ffmpeg -i clip2.avi -acodec copy clip2.wav
#Create a wave file with a straight line fade out of the audio from clip1.wav sox clip1.wav clip1fade.wav fade t 0 0 1 #Create a wave file with a straight line fade in of the audio from clip2.wav sox clip2.wav clip2fade.wav fade t 1 0 0 #Merge the two fade wave files into a single file named clipcomb.wav: sox -m clip1fade.wav clip2fade.wav clipcomb.wav
ffmpeg -r 29.97 -i frame%d.bmp -i clipcomb.wav -vcodec ffv1 -r 29.97 -s 720x480 -acodec copy transition.avi
mencoder -oac copy -ovc copy body1.avi transition.avi body2.avi -o finalmovie.avi
Note on ffmpeg and file timing: You can pull the duration of a movie or wav file into a bash script using the following command:
duration=$(ffmpeg -i movie.avi 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,// )
ffmpeg -t $videoonlyduration -i videoonly.avi -i audioonly.wav -vcodec copy -acodec copy newfile.avi
- 1) Join two movie files together.