rkr1958
10th December 2006, 03:22
I wrote the following script to illustrate to someone on videohelp.com how he might (I could) scroll text across a video using AVISynth.
# Deshook, DeNoised Video
a = AVISource("G:\MUMC_Preschool_Christmas_Show_2005\Song-1.avi",audio = false).ConvertToYUY2()
nf = Framecount(a)
fr = Framerate(a)
# Segment video to add in scrolling ribbon, which will contain the scrolling text
f1 = 288 # first frame when text extends full width of the screen
f2 = 1972 # first frame when text begins to exit the right part of the screen
a1 = a.trim(0,f1) # for scrolling ribbon
a2 = a.trim(f1+1,f2) # for fixed ribbon
a3 = a.trim(f2+1,nf) # for scrolling ribbon
n1 = Framecount(a1)
n2 = Framecount(a2)
n3 = Framecount(a3)
# Create the ribbons (1 & 3 scoll)
rib1 = blankclip(length=n1, width=720, height=40, fps=fr, color=color_black, audio_rate=0).ConvertToYUY2()
rib2 = blankclip(length=n2, width=720, height=40, fps=fr, color=color_black, audio_rate=0).ConvertToYUY2()
rib3 = blankclip(length=n3, width=720, height=40, fps=fr, color=color_black, audio_rate=0).ConvertToYUY2()
# Add ribbons to the bottom of the video to house the scrolling text
# Layer (clip, layer_clip, string "op", int "level", int "x", int "y", int "threshold", bool "use_chroma")
a1 = Animate(0,n1-1,"Layer",a1,rib1,"add",255,720,408,0,true, \
a1,rib1,"add",255, 0,408,0,true)
a2 = Layer(a2,rib2,x=0,y=408)
a3 = Animate(0,n3,"Layer",a3,rib1,"add",255, 0,408,0,true, \
a3,rib1,"add",255,-720,408,0,true)
clip = a1 + a2 + a3
# Create the Scrolling Text
scrolling_text = \
"This is an example of adding scrolling text to a video. " + \
"This text was added using AVISynth and the functions antimate and subtitle. " + \
"The running time of this video is approximately 1-minute & 15-seconds. " + \
"This video is from a source that was shot without a tripod and is very shakey. " + \
"Gunnar Thalin's Deshaker v2.0 plugin to virtualdub was used to stabilize this video. " + \
"Also, AVISynth filters pre and post deshook were used to prep and denoise this video. " + \
"I hope you have enjoyed this demostration."
# Antimate the scrolling text StrLen
clip = clip.Animate(8,nf-8, "Subtitle", \
Scrolling_text, 720, 414, 0, nf, "Arial", 24, color_yellow, \
Scrolling_text, -round(9.87*StrLen(scrolling_text)), 414, 0, nf, "Arial", 24, color_yellow)
# Add Audio
audio = WAVSource("G:\MUMC_Preschool_Christmas_Show_2005\RAW-Song-1.wav")
clip = AudioDub(clip, audio)
return clip Here's the glitch I got,
http://www.knology.net/~benrunyan/Frame_294_off.jpg
Note that the text just up several pixels and that the text from Scolling_Text line 4 versus line 1 is displayed. This glitch goes away if I change,
clip = clip.Animate(8,nf-8, "Subtitle", ... to
clip = clip.Animate(6,nf-8, "Subtitle", \
Any insights why my script cause this glitch and why it went away when I made the above change?
# Deshook, DeNoised Video
a = AVISource("G:\MUMC_Preschool_Christmas_Show_2005\Song-1.avi",audio = false).ConvertToYUY2()
nf = Framecount(a)
fr = Framerate(a)
# Segment video to add in scrolling ribbon, which will contain the scrolling text
f1 = 288 # first frame when text extends full width of the screen
f2 = 1972 # first frame when text begins to exit the right part of the screen
a1 = a.trim(0,f1) # for scrolling ribbon
a2 = a.trim(f1+1,f2) # for fixed ribbon
a3 = a.trim(f2+1,nf) # for scrolling ribbon
n1 = Framecount(a1)
n2 = Framecount(a2)
n3 = Framecount(a3)
# Create the ribbons (1 & 3 scoll)
rib1 = blankclip(length=n1, width=720, height=40, fps=fr, color=color_black, audio_rate=0).ConvertToYUY2()
rib2 = blankclip(length=n2, width=720, height=40, fps=fr, color=color_black, audio_rate=0).ConvertToYUY2()
rib3 = blankclip(length=n3, width=720, height=40, fps=fr, color=color_black, audio_rate=0).ConvertToYUY2()
# Add ribbons to the bottom of the video to house the scrolling text
# Layer (clip, layer_clip, string "op", int "level", int "x", int "y", int "threshold", bool "use_chroma")
a1 = Animate(0,n1-1,"Layer",a1,rib1,"add",255,720,408,0,true, \
a1,rib1,"add",255, 0,408,0,true)
a2 = Layer(a2,rib2,x=0,y=408)
a3 = Animate(0,n3,"Layer",a3,rib1,"add",255, 0,408,0,true, \
a3,rib1,"add",255,-720,408,0,true)
clip = a1 + a2 + a3
# Create the Scrolling Text
scrolling_text = \
"This is an example of adding scrolling text to a video. " + \
"This text was added using AVISynth and the functions antimate and subtitle. " + \
"The running time of this video is approximately 1-minute & 15-seconds. " + \
"This video is from a source that was shot without a tripod and is very shakey. " + \
"Gunnar Thalin's Deshaker v2.0 plugin to virtualdub was used to stabilize this video. " + \
"Also, AVISynth filters pre and post deshook were used to prep and denoise this video. " + \
"I hope you have enjoyed this demostration."
# Antimate the scrolling text StrLen
clip = clip.Animate(8,nf-8, "Subtitle", \
Scrolling_text, 720, 414, 0, nf, "Arial", 24, color_yellow, \
Scrolling_text, -round(9.87*StrLen(scrolling_text)), 414, 0, nf, "Arial", 24, color_yellow)
# Add Audio
audio = WAVSource("G:\MUMC_Preschool_Christmas_Show_2005\RAW-Song-1.wav")
clip = AudioDub(clip, audio)
return clip Here's the glitch I got,
http://www.knology.net/~benrunyan/Frame_294_off.jpg
Note that the text just up several pixels and that the text from Scolling_Text line 4 versus line 1 is displayed. This glitch goes away if I change,
clip = clip.Animate(8,nf-8, "Subtitle", ... to
clip = clip.Animate(6,nf-8, "Subtitle", \
Any insights why my script cause this glitch and why it went away when I made the above change?