digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: Subtitle fade in/out (http://www.digitalfaq.com/archives/avisynth/1707-avisynth-subtitle-fade.html)

muaddib 11-25-2002 05:06 PM

subtitle fade in/out
 
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,

muaddib 11-28-2002 12:31 AM

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?

Graal_CPM 11-28-2002 03:16 AM

Pseudo-help
 
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,

muaddib 11-29-2002 12:08 AM

Re: Pseudo-help
 
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,448)
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?

Graal_CPM 11-29-2002 05:05 AM

:idea: Well, reading doc at http://www.avisynth.org I understand that synthax is "FRAMERATE(clip)", not FRAMERATE alone.

Very nice script indeed.

Cheers,

muaddib 11-29-2002 11:34 AM

Hey! Thanks again, Graal_CPM!
Now it's working. :lol:
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)
}



All times are GMT -5. The time now is 01:15 PM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2026 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2026 Jelsoft Enterprises Ltd.