Log in

View Full Version : Fading in and out with image?


color
17th April 2021, 13:23
I dont know if dissolve or fadein/fadeout is what I should use and what is best. I wan't the fade to begin at 405 with 29 frames fading in (only the image not the avi-file) and fading out with 29 frames and end at frame 558. This is the script I have so far:


A=DirectShowSource("D:\0000.avi")
B=ImageSource("D:\present.png", start=0, end=A.framecount-1, fps=A.framerate, pixel_type="RGB32")
C=Overlay(A,B, mask=B.showalpha())

A.Trim(0,404) ++ C.Trim(405,558) ++ A.Trim(558,0)

StainlessS
17th April 2021, 14:21
Maybe you want to restate your requirement a little more clearly.
Fade, transitions from black to normal image, or the other way around. [in or out]
Dissolve overlaps [in your case 29 frames], so that your result length clip is 29 frame shorter due to the overlap. It starts out using
all of one image/clip, and at end of dissolve uses all of the other image/clip, so result contains a bit of both, hence the overlap requirement.

patul
17th April 2021, 15:30
As StainlessS mentioned, the requirement is not quite clear, and we can only guess from the script that you have.

However I gave it a try, excuse my newbieness though.


A = FFmpegSource2("D:\App\youtube-dl\S2_E09_clip.mkv").KillAudio().TFM().TDecimate().ConvertToRGB32(matrix = "Rec601")
B = ImageSource("D:\App\youtube-dl\flintstones.png", start=0, end=100, fps=A.framerate, pixel_type="RGB32")
fdin = B.FadeIn(100)
fdout = B.FadeOut(100)
Afin = A.Trim(200,300)
Afout = A.Trim(300,400)
C = Overlay(Afin, fdin, mask=fdin.ShowAlpha())
D = Overlay(Afout, fdout, mask=fdout.ShowAlpha())

# if you want the image is faded in and then faded out WITHOUT overlay to the video
#A.Trim(0,200) ++ fdin ++ fdout ++ A.Trim(200,687)

# if you want the image is faded in and then faded out WITH overlay to the video
A.Trim(0,200) ++ C ++ B ++ D ++ A.Trim(400,687)


I use 100 frames instead of 29 to display the effect for a longer time.

johnmeyer
17th April 2021, 16:26
It takes less than one second to do this in any NLE. This is the wrong tool for the job.

Richard1485
17th April 2021, 18:50
I wan't the fade to begin at 405 with 29 frames fading in (only the image not the avi-file) and fading out with 29 frames and end at frame 558.

Assuming that I've understood correctly, try the following:
A=AviSource("D:\0000.avi")
B=ImageSource("D:\present.png", start=0, end=152, fps=A.framerate, pixel_type="RGB32")

Dissolve(
\Dissolve(
\Trim(A, 0, 433),
\B,
\29),
\Trim(A, 529, 0),
\29)


Explanation
To begin a fade at 405, count forward the required number of frames, and adjust the call to Trim() accordingly, so that Dissolve() gives you the result that you want. The same principle applies to the fade out (although you count backwards instead).

I've replaced DirectShowSource() with AviSource(). Use KillAudio() if necessary.

color
19th April 2021, 17:26
Oh sorry. I see it's quite vage. What i ment was that the image has an transparent (png) and i want it to fade in from "invisible". I did however solved it. I did a "trim" similar to patul. :)

Thank you. ��

wonkey_monkey
19th April 2021, 17:34
It takes less than one second to do this in any NLE. This is the wrong tool for the job.

I think it's reasonable to assume that if someone asks a question in the Avisynth Usage forum, then they want to use Avisynth to do it.

StainlessS
19th April 2021, 18:41
then they want to use Avisynth to do it.
Yip, I aint used an NLE since about W2K. [although I think I got one somewhere from W2K era].

johnmeyer
19th April 2021, 21:55
I think it's reasonable to assume that if someone asks a question in the Avisynth Usage forum, then they want to use Avisynth to do it.Yes, I fully understand that, but people often "assume a solution" before they have thought through all the alternatives. This is especially true of AVISynth which, for some people, has a certain mystique of being the "best" way to do something, or somehow achieving better results than other alternatives.

If all the OP wants to do are fades and crossfades, it can be done using any one of 99 different programs, including using AVISynth, but compared to the flexibility offered by an NLE, the results are going to take a long time to achieve, and the results will be less pleasing because of the lack of interactivity and GUI.

As just one example, I have twelve defaults in my NLE of how quickly a fade or crossfade happens. I can change the crossfade behavior in one second with a single click of the mouse, and I can change the duration of the fade just by sliding video clips back and forth on the timeline. I can also change the fade to a dissolve (not the same thing) or can apply some other effect (e.g., wipe) if I want.

Richard1485
19th April 2021, 23:35
For my purposes, AviSynth accomplishes this sort of work perfectly well. In a matter of seconds, I can type exactly what I want to achieve without leaving the script that contains the rest of my processing/editing. This avoids involving another program, generating intermediate files, making additional renders, etc. For me, it's easier than using an NLE, but different strokes...

wonkey_monkey
20th April 2021, 00:15
Yes, I fully understand that, but people often "assume a solution" before they have thought through all the alternatives.

It's also an assumption to declare that someone is doing the wrong thing based on only their immediate question. We have no idea what the rest of color's requirements or plans are. If he was a first-time poster without a script in progress and asking how to use AviSynth to do a fade, then a suggestion that he might have better luck with an NLE would certainly be warranted. But to declare it as fact is presumptuous in any case.

poisondeathray
20th April 2021, 00:39
Yes, I fully understand that, but people often "assume a solution" before they have thought through all the alternatives. This is especially true of AVISynth which, for some people, has a certain mystique of being the "best" way to do something, or somehow achieving better results than other alternatives.


In cases with overlay and fade operations, avisynth often produces better results quality wise, because those operations are performed in YUV, and most video is in YUV

Many/most NLE's operate in RGB, especially the transition and overlay operations - it's easy to demonstrate that this produces lower quality, more banding in the base video layer




If all the OP wants to do are fades and crossfades, it can be done using any one of 99 different programs, including using AVISynth, but compared to the flexibility offered by an NLE, the results are going to take a long time to achieve, and the results will be less pleasing because of the lack of interactivity and GUI.


I agree, but OP has 1 fade in/out. It's trivial to do in avisynth


As just one example, I have twelve defaults in my NLE of how quickly a fade or crossfade happens. I can change the crossfade behavior in one second with a single click of the mouse, and I can change the duration of the fade just by sliding video clips back and forth on the timeline. I can also change the fade to a dissolve (not the same thing) or can apply some other effect (e.g., wipe) if I want.

I agree, you can't compete with NLE simplicity of those types of operations, and if you had dozens of transitions, multiple layers, it would take many times longer in avisynth to do. Very tedious...

But OP asked for 1 fade in/out with a transparent overlay

johnmeyer
20th April 2021, 08:10
I give up. Why even bother trying to help strangers? This has become pointless.

StainlessS
20th April 2021, 15:16
For me, I mainly can't be bothered to try an NLE, its just something new to learn and easier to use what I know, old dog, old tricks.
Dont give up John, its just this damn Covid silly season getting you down. :)