Quantcast Avisynth: Subtitle Fade in/Out - digitalFAQ.com Forums [Archives]
Go Back    digitalFAQ.com Forums [Archives] > Video Production Forums > Avisynth Scripting

Reply
 
LinkBack Thread Tools
  #1  
11-25-2002, 06:06 PM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Hi all!

I need some help with a simple task...
Is there a way to fade in a line of text into a movie, make it stay for a couple of seconds the fade it out?
I'm using the avs native subtitle() function, but it doesn’t fade in/out.
Any ideas?

Thanks,
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Site Staff / Ad Manager
 
Join Date: Dec 2002
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
  #2  
11-28-2002, 01:31 AM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Well... I think I got it. Here is the script:

Quote:
source1 = mpeg2source("C:\Temp\cassia_eller\malandragem.d2v" )

subtitle1 = Subtitle(source1, "Malandragem", 465,390, 70,280, "arial",33,$FFFFFF,$000000)
subtitle2 = Subtitle(subtitle1, "(Cazuza/Frejat)", 465,414, 70,280, "arial",21,$FFFFFF,$000000)

sub_fadein = Dissolve(trim(source1,70,100), trim(subtitle2,70,280), 30)
sub_fadeout = Dissolve(sub_fadein, trim(source1,250,0), 30)

trim(source1,0,69) + sub_fadeout
This script FadeIn 2 text lines (1 sec fadein), show it for 5sec, then FadeOut (1sec fadeout).
I would like to make a function with it. The function should have the same arguments that the "subtitle" has, plus the fadein/out time and stay time.
But I never did any function with avs... can someone help me?
Reply With Quote
  #3  
11-28-2002, 04:16 AM
Graal_CPM Graal_CPM is offline
Free Member
 
Join Date: Jun 2002
Location: Paris, France
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Hi!

Sorry I cannot help you. However, checking the script at http://www.avisynth.org/index.php?page=VirtualDub_II might help you to get an idea about functions.

Cheers,
Reply With Quote
  #4  
11-29-2002, 01:08 AM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Graal_CPM
Hi!

Sorry I cannot help you. However, checking the script at http://www.avisynth.org/index.php?page=VirtualDub_II might help you to get an idea about functions.

Cheers,
Hi Graal_CPM!

Thanks for the link!
I made a function, and it works!
Here is the script:

Quote:
LoadPlugin("D:\DVD Rip Tools\AviSynth2\filters\mpeg2dec.dll")
mpeg2source("C:\Temp\cassia_eller\malandragem.d2v" )

FadeSub("Malandragem", 465,390, "arial",33,$FFFFFF,$000000, 3, 7, 1)
FadeSub("(Cazuza/Frejat)", 465,414, "arial",21,$FFFFFF,$000000, 3, 7, 1)

BilinearResize(448,448,24,16,672,44
clip3=AddBorders(16,16,16,16)

clip4=Dissolve(Blackness(clip3,60),clip3,60)
Dissolve(trim(clip4,0,7202),Blackness(clip3,250),1 50)


#----------------------#
# FadeSub Function #
#----------------------#
function FadeSub(clip clip, string "text", int "x", int "y", string "font", int "size",
\ int "text_color", int "halo_color", int "start", int "stay", int "fade")
{
framerate = 29.976
first_frame = round(framerate * start)
last_frame = round((framerate * stay) + first_frame)
fade_frames = round(framerate * fade)
fin_frame = fade_frames + first_frame
fout_frame = last_frame - fade_frames

solid_sub = Subtitle(clip, text, x, y, first_frame, last_frame, font, size, text_color, halo_color)
sub_fin = Dissolve(trim(clip, first_frame, fin_frame), trim(solid_sub, first_frame, last_frame), fade_frames)
sub_fout = Dissolve(sub_fin, trim(clip, fout_frame, 0), fade_frames)

return (trim(clip, 0, first_frame-1) + sub_fout)
}
But I have one problem. See the line that says "framerate = 29.976"? That line should not exist... cause framerate is a function that should return the framerate of the clip. Well, if I erase that line, AVS give me the message: I don't know what "framerate" means

Anyone know what I'm doing wrong?
Reply With Quote
  #5  
11-29-2002, 06:05 AM
Graal_CPM Graal_CPM is offline
Free Member
 
Join Date: Jun 2002
Location: Paris, France
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Well, reading doc at http://www.avisynth.org I understand that synthax is "FRAMERATE(clip)", not FRAMERATE alone.

Very nice script indeed.

Cheers,
Reply With Quote
  #6  
11-29-2002, 12:34 PM
muaddib muaddib is offline
Free Member
 
Join Date: Jun 2002
Location: São Paulo - Brasil
Posts: 879
Thanks: 0
Thanked 0 Times in 0 Posts
Hey! Thanks again, Graal_CPM!
Now it's working.
I just changed the start, stay and fade variables to float, so you can use fraction of seconds.
I'm using this script to show the name of the music (and composer) of music-videos that are missing that information.

Quote:
#----------------------#
# FadeSub Function #
#----------------------#
function FadeSub(clip clip, string "text", int "x", int "y", string "font", int "size",
\ int "text_color", int "halo_color", float "start", float "stay", float "fade")
{
frame_rate = framerate(clip)
first_frame = round(frame_rate * start)
last_frame = round(first_frame + (frame_rate * stay))
fade_frames = round(frame_rate * fade)
fin_frame = fade_frames + first_frame
fout_frame = last_frame - fade_frames

solid_sub = Subtitle(clip, text, x, y, first_frame, last_frame, font, size, text_color, halo_color)
sub_fin = Dissolve(trim(clip, first_frame, fin_frame), trim(solid_sub, first_frame, last_frame), fade_frames)
sub_fout = Dissolve(sub_fin, trim(clip, fout_frame, 0), fade_frames)

return (trim(clip, 0, first_frame-1) + sub_fout)
}
Reply With Quote
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
Avisynth: Fade to Black? Shibblet Avisynth Scripting 3 01-17-2005 05:35 PM
Fade In/ Fade Out no script: como? FlavioMetal Conversão e Codificação de Vídeo (Português) 6 07-21-2004 08:27 AM
Ayuda con AviSynth (Subtitle) Schamann Convertir y Codificar Video (Español) 4 01-07-2004 12:04 AM
Avisynth: Fade in / fade out not working? TKS Avisynth Scripting 0 11-07-2002 10:20 PM
Avisynth: Fade in/out subtitle muaddib Avisynth Scripting 0 10-08-2002 02:16 PM




 
All times are GMT -5. The time now is 05:50 AM  —  vBulletin © Jelsoft Enterprises Ltd