Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Newbies

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th September 2008, 14:35   #1  |  Link
padeen
Registered User
 
Join Date: Sep 2008
Posts: 2
Intro titles with avisynth

Hi all, long time reader, first time poster.

I wanted to add a vanity Title Intro clip to a DVD to distribute to relatives. After playing around MS Movie Maker, Wax and Gimp animation, I ended up using avisynth. The result is very pleasing and it came out exactly with what I'd had in mind.

It was very easy in the end, you can see the result here. I learnt a lot about layers, masks and animation.

The script does a lot for about 20 lines of code. I had thought about writing a tutorial on it, but I don't want to teach my grannie how to suck eggs, so will wait for a request first.

(Quick question: what is the advantage of using Layer()? From what I could discover, Overlay() seems to be the go for most situations.)

Thanks,
padeen is offline   Reply With Quote
Old 10th September 2008, 17:32   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by padeen View Post
Quick question: what is the advantage of using Layer()? From what I could discover, Overlay() seems to be the go for most situations.
Layer is slightly simpler to use for alpha-channel compositing as it works directly with the alpha channel of RGB32 clips. With Overlay you have to use the ShowAlpha function as well.

Why not here so others can learn from your experience?
Gavino is offline   Reply With Quote
Old 10th September 2008, 23:37   #3  |  Link
talen9
Registered User
 
Join Date: Aug 2007
Location: Italy
Posts: 286
I'll be interested in the script too

Simple but/and very nice results
talen9 is offline   Reply With Quote
Old 11th September 2008, 15:41   #4  |  Link
[P]ako
A geek wannabe
 
[P]ako's Avatar
 
Join Date: Apr 2007
Posts: 231
It is easier to code text in ASS/SSA format using Aegisubs. One can apply a lot of effects to text and then use avisynth to create a blank clip to apply the text on with vsfilter.
[P]ako is offline   Reply With Quote
Old 12th September 2008, 01:22   #5  |  Link
padeen
Registered User
 
Join Date: Sep 2008
Posts: 2
Pa[k]o: thanks for the tip on Aegisub, it looks good for next time I do this.

Since this is the newbie forum, here's plenty of detail for later readers on why I originally decided to use avisynth and about the script. I'm fine with scripting (Unix background) and AvsP just makes it all so easy. Kudos to AvsP's developer.

The code is heavily commented. I hope some newbies find it useful in discovering things about what you can do with avisynth and just how versatile it is beyond simple video filters.

Why Avisynth
I wanted to learn more about avisynth. I read a post in the avisynth forum about animation and wanted to try it, I hadn't realised there was animation in avisynth. I wanted to play with layers as I hadn't used them much. I wanted to try masks for the same reason. Eval() was a bit of a revelation too. In fact, with Eval() and recursion, there's pretty much nothing you can't do to simulate control functions like do...while and for...next.

The first page's animation design was inspired from MS Movie Maker which makes it very easy to create effects like this. It can't handle subsequent title credits though, so it was binned. Wax is confusing for me, I get it and the concepts, but the user interface is a bit flaky on my machine, sometimes a click works and sometimes it doesn't. If I needed a Wax effect, I'd put the time in to learn it better. Gimp was too clumsy for what I'm doing.

What we want to achieve
I wanted a simple multi-page intro video (the video is amusing because the texts are all family in-jokes) for my family DVDs, and it needed to be adjustable for NTSC and PAL and also let me change it later. For me, scripting is easier for things that need constant repetitive adjusting, like fine-tuning the position of text, as my mouse control just isn't good enough for pixel adjustements.

How I did it
Have a quick look at the 16 seconds of output (link in first post). It shows a title page with scrolling background text, a link page, another title page with three lines of text appearing at different times, then a final link page.

I used layers to add text that appears at different times and kept that clip for a later join/merge. I used separate clips for each page. Dissolves and fadein/outs help things transition smoothly, otherwise the text seems to jump out at you. The final page fades out slowly to give the psychological effect of changing to the DVD menu which appears next.

Code:
# import the colour names
import("C:\Program Files\AviSynth 2.5\plugins\colors_rgb.avsi")

# set up some constants that may be changed on a needs basis
back = color_darkslateblue
back_tr = back + $FF000000  # This adds transparency to the colour.  I'm not sure if this works (suspect not).
text_color = color_white
text_color_tr= text_color + $55000000
length=400

frame_w=720
frame_h=480  # 480 or 576
NTSC = (frame_h == 480 ? true : false )  # NTSC flag for later use
framerate = ( NTSC ? 30000/1001 : 25.0)   # framerate depends on NTSC or PAL

# blankclip needs to be RGB for some of the functions below. 
base = BlankClip(length=length, width=frame_w, height=frame_h, pixel_type="rgb32", fps=framerate,color=back)

# animation parameters
align = 5   # 5 is centre both horiz and vertically
text_sz = 500   #  change this according to the font so it looks good
#  Calculate some positions for text (still have to figure out how text is positioned; it seems to vary among the fonts in an inconsistent way (caused by kerning or drops perhaps?)
y3 = frame_h/2 + 160/2
y1 = frame_h/2 - 160/2  +  (NTSC ? 50 : 170/2 - 20 )       # NTSC or PAL?    fine tune the placement via the last number
y2 = frame_h/2 + text_sz/2 + frame_h/(NTSC ? -130 : -100 )

# Page One with a strong text and scrolling transparent background.
# Transparency works differently than I expected, but the result was good enough.

# The method is to build up layers of clips, with each clip containing its own text starting to scroll at a different time to the others.

#  right to left background scrolling text, large transparent outlined font.    -1200 as a start X was determing by experimenting.
title1 = animate(base,0,length,"subtitle","Eschatonia",frame_w,y1,0,99999,"Segoe UI",text_sz,back_tr, text_color, align - 1, \
                                                "Eschatonia", -1200,y1, 0, 9999,"Segoe UI",text_sz, back_tr, text_color,align)

# left to right background scrolling text, large transparent outlined font
title2 = animate(title1,0,length,"subtitle","Eschatonia",-1220,y2,0,99999,"Segoe UI",text_sz,back_tr, text_color, align +1, \
                                                "Eschatonia", 1300,y2, 0, 9999,"Segoe UI",text_sz, back_tr, text_color,align)                                                

# foreground stationary text
title3 = subtitle(title2  ,"Eschatonia",-1,y3-32,0,99999,"Segoe UI",160,text_color,back,align,1,0)

# trim the clip so the result has scrolling text has already scrolled into a nice looking position.
#  fadein at the beginning so it doesn't just appear (jump) on the screen.  A fadein looks nicer.  ditto fadeout.
title3 = title3.trim(171,270).fadein(50,back).fadeout(25,back)

#  Joiner page with quick fade in and out
title4=base.trim(0,70).subtitle( "in conjunction with",-1,-1,0,75, "Times New Roman",32,text_color,back_tr,align).fadein(10,back).fadeout(20,back)

# animation and positioning parameters for Page Two
y4 = frame_h/2 - (NTSC ? 100 : 176/2 + 25)

#  Page Two
# Use the same principles as Page One, three lines of text appearing at different times, so use overlays and merge into the final effect.

#  fadein the first line of text, starting with frame 0.  reuse baseclip since we have finished with it above.
title5 = subtitle(base,"The Kitty",-1,y4,0,99999,"papyrus",100,text_color,back,align,1,0).fadein(10,back)

#  The mask is the same as the text so that lighten parameter in Overlay() only affects the text area.  
#  I only realised this late and it was a bit of a revelation in getting it to work.
#  If masking isn't clear to you, have a play around with Photoshop or Gimp.  There are plenty of tutorials on the web about using masks.

# fade in the second line of text at frame 30, about 1 second after the first
mask1 = subtitle(base,"and",-1,-1,30,9999, "Times New Roman",32,text_color,back_tr,align)
title6=overlay(title5 ,mask1,mask=mask1,opacity=1,mode="lighten",greymask=false)

# fadein the third line of text, with a mask as above, at frame 50, giving about two seconds from 1st line to this one.
mask2 = subtitle(base,"Miss Pat",-1,y4 + frame_h/2 + (NTSC ? -20: 176/2 - 125),50,99999,"Segoe Script",100,text_color,color_black,align,1,0).fadein(65)
title6 = overlay(title6,mask2,mask=mask2,opacity=1,mode="lighten",greymask=true).trim(0,125).fadeout(5,back)

#  We now have three clips containing the three lines of text, each line appearing at a different position on the time line.

# The final page which will slowly fade out at the end into the main menu on the DVD.
title9=base.trim(0,110).subtitle("present",-1,-1,0,100, "Times New Roman",48,text_color,back_tr,align).fadein(10,back).fadeout(40)

# For some reason, the framerate we set in base clip doesn't seem to get carried through (muxman complains about invalid framerate), so we reset it here.
settings = (NTSC ?  """.assumefps("ntsc_video")""" : "")  #  need to change fps here for NTSC.  For some reason, the BlankClip setting of 29.97 doesn't get carried through the script.

# Note use of Eval() to add a function depending on the NTSC flag above.  Dissolve() gives the join a nice looking blend effect.  ConvertTo YV12() is for muxman.
return eval("dissolve(blankclip(10,frame_w,frame_h),title3,title4,title6,title9,5).converttoyv12(interlaced=false)" + settings)
I hope this is useful. If anyone wants to criticise, go right ahead. I especially have no clue on optimising for avisynth, so I'm sure I've used some clumsy methods. Thanks for reading,
padeen is offline   Reply With Quote
Old 12th September 2008, 09:58   #6  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
padeen, thanks and congratulations for such a well-written description which will be very useful to lots of people.

Your problems with the NTSC framerate are due to this line:
Code:
framerate = ( NTSC ? 30000/1001 : 25.0)   # framerate depends on NTSC or PAL
You need to use floating point division, not integer, so use 30000.0/1001.

Some other comments:
- there's no need to import the color names, as avsi files in the plugins folder are imported automatically;
- although it is a useful technique, you don't really need eval in this case because you could have written
Code:
dissolve(blankclip(10,frame_w,frame_h),title3,title4,title6,title9,5).converttoyv12(interlaced=false)
return (NTSC ?  assumefps("ntsc_video") : last)
(and if you fix the divide problem the last line should be unnecessary too)
Gavino is offline   Reply With Quote
Reply

Tags
intro, layer, overlay, subtitle, vanity

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.