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 > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Display Modes
Old 10th December 2006, 03:22   #1  |  Link
rkr1958
Registered User
 
Join Date: Jan 2005
Location: Huntsville, AL
Posts: 96
What is causing a glitch at frame 294 in my script?

I wrote the following script to illustrate to someone on videohelp.com how he might (I could) scroll text across a video using AVISynth.

PHP Code:
# Deshook, DeNoised Video
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=n1width=720height=40fps=frcolor=color_blackaudio_rate=0).ConvertToYUY2()
rib2 blankclip(length=n2width=720height=40fps=frcolor=color_blackaudio_rate=0).ConvertToYUY2()
rib3 blankclip(length=n3width=720height=40fps=frcolor=color_blackaudio_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_text7204140nf"Arial"24color_yellow
       
Scrolling_text, -round(9.87*StrLen(scrolling_text)), 4140nf"Arial"24color_yellow)

# Add Audio
audio WAVSource("G:\MUMC_Preschool_Christmas_Show_2005\RAW-Song-1.wav")
clip AudioDub(clipaudio)

return 
clip 
Here's the glitch I got,



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?

Last edited by rkr1958; 10th December 2006 at 03:25.
rkr1958 is offline   Reply With Quote
Old 11th December 2006, 03:21   #2  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 2,246
The Animate target value become -1 at that frame.
Quote:
Originally Posted by documentation
... The parameters x and y can be set to -1 to automatically calculate and use the horizontal or vertical center coordinate.
Ahhhgggg magic values

Performance Hint: To avoid unnecessary colour space conversions, use the Pixel_type="YUY2" on AviSource() and BlankClip() where appropriate.

Alternate approach: Declare an appropriatly wide, 40 high ribbon clip. Write all text onto the ribbon in 1 go. Use Animate of Layer of the ribbon to do the scroll.
IanB is offline   Reply With Quote
Old 11th December 2006, 23:49   #3  |  Link
rkr1958
Registered User
 
Join Date: Jan 2005
Location: Huntsville, AL
Posts: 96
Quote:
Originally Posted by IanB View Post
The Animate target value become -1 at that frame.Ahhhgggg magic values

Performance Hint: To avoid unnecessary colour space conversions, use the Pixel_type="YUY2" on AviSource() and BlankClip() where appropriate.

Alternate approach: Declare an appropriatly wide, 40 high ribbon clip. Write all text onto the ribbon in 1 go. Use Animate of Layer of the ribbon to do the scroll.
Thanks. The magic value -1 must be it. I guess it's just the luck of the draw on whether or not that value gets used in subtitle when using animate. That would explain why I would sometimes, but not all the time, see the glitch. I think I'll give the alternate approach a try.

Also, thanks for your performance hint. A couple of questions. So would the command,

a = AVISource("G:\MUMC_Preschool_Christmas_Show_2005\Song-1.avi",Pixel_type = "YUY2", audio = false)

produce the same result (but only faster) as

# Deshook, DeNoised Video
a = AVISource("G:\MUMC_Preschool_Christmas_Show_2005\Song-1.avi",audio = false).ConvertToYUY2() ?

Are there also quality differences between these two?
rkr1958 is offline   Reply With Quote
Old 14th December 2006, 04:53   #4  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 2,246
The main point was not to convert the BlankClips. Generate them as YUY2 directly.

In the the 1st case you are explicitly asking the codec to decode to YUY2 pixel type ONLY!

In the second case, the codec will be asked for in turn YV12, YUY2, RGB32 then RGB24, The first type the codec can deliver will be used. If YUY2 is returned anyway the ConvertToYUY2 will be a noop.

There are many scenarios I will mention a few.

1. The codec cannot do YUY2 - Script Error.
2. The codec can do YV12 but does YUY2 better - Better Quality.
3. The internal data is natively YV12, the codec has inferior or slow YV12 -> YUY2 code - Worse quality or slower.
4. The internal data is natively YV12, the codec knows the data is interlaced and can correctly deinterlace the chroma to YUY2 - Correct chroma sampling.
5. The internal data is natively YV12, the codec does not knows the data is interlaced and incorrectly deinterlaces the chroma to YUY2 - Chroma Sampling Error.
6. The internal data is RGB, the codec has inferior or slow RGB -> YUY2 code - Worse quality or slower.

It pays to know a little about your codec. At a minimum test with pixel_type="YV12" and "YUY2" and compare the results.



Also one catch with layer and YUY2 is mod 2 horizontal pixel alignment, this means the text will scroll 2 pixels at a time.

In your original approach you could add a number of spaces to the start of your message so you can skip around the 720 -> -1 animate cases and start directly at -2.

Last edited by IanB; 14th December 2006 at 05:02.
IanB is offline   Reply With Quote
Reply

Thread Tools
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 02:08.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.