I'm trying to create an AviSynth script that replaces one shot in a video using two images.
Is it possible to overlay one image over a second one, and gradually fade the top one out so that the one underneath slowly appears?
If so, does anyone have a script example or tutorial I could take a look at?
+ Reply to Thread
Results 1 to 30 of 30
-
-
Probably easier to use dissolve() to get the same effect . It's basically a crossfade what you're describing how one image fades into the next
http://avisynth.nl/index.php/Dissolve
Unless you need to use overlay() for some specific reason ?
In that case one way to do it is to use a mask and animate() the opacity of the mask over time e.g .using levels(). (Mask opacity white to black controls the fade and overlay operation) . The other way is to animate() the overlay() opacity over time) -
Thanks! I think Dissolve is exactly what I need. I've almost got it working right. The problem I'm having is that there are two dissolves instead of one. The first image is dissolving in, which I don't want. How do I remove that dissolve, but not the one between the two images?
Here's my script:
Code:LoadPlugin("C:\DVD\DGDecode.dll") clip1 = MPEG2Source("C:\DVD\04\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl3 = ImageSource("C:\Images\1.png", fps=clip1.framerate) ovl4 = ImageSource("C:\Images\2.png", fps=clip1.framerate) ovl3 = ovl3.ConvertToYV12() ovl4 = ovl4.ConvertToYV12() clip2.Trim(28,2714)FadeOut(19) + clip1.Trim(2688,11277) + clip1.Trim(11278,11549).Dissolve(ovl3, ovl4, 271) + clip1.Trim(11550,0)
-
Did you want a hard cut from clip1 to ovl3? You probably wanted +Dissolve, not .Dissolve
-
Thanks! I do want +Dissolve, but I'm having problems with timing the cuts. The images are displaying for a long time before and after the dissolve begins and ends.
How do I make the dissolve begin as soon as the first image appears, and end as soon as the second image disappears? -
When you debug something, strip everything out and look at it individually. It's the same for checking filters, you remove them one by one and check
Probably you didn't account for the default length of imagesource(), because you didn't enter any values. Default length is 1000 frames.
What do you think this is supposed to do? How long do you think it should be?
Code:Dissolve(ovl3, ovl4, 271)
It's not clear what you want to do. Is clip1 going from 11278 to 11549. Did you want the end of that to cross dissolve into ovl3 ? Or is clip1 a hard cut into ovl3 which begins abruptly ?
If you wanted 2 dissolves - 1) end of clip 1 into ovl3, 2) end ovl3 into ovl4, then include them in dissolve() . You can think of it is
Dissolve(A,B,C, 271) , where the cross dissolve occurs between A and B, B and C.
Code:Dissolve(clip1.Trim(11278,11549), ovl3, ovl4, 271)
-
That's exactly what I did wrong. Thank you!
11278 to 11549 was supposed to specify the frames over which the image replacements would be applied, and also the frames over which the dissolve would take place. Adding that in was the other part I was doing wrong.
clip 1 was supposed to hard cut into ovl3.
ovl3 was supposed to dissolve into ovl4.
ovl4 was supposed to hard cut into the next part of clip 1.
Everything works perfectly now! Thank you. Here's the script I came up:
Code:LoadPlugin("C:\DVD\DGDecode.dll") clip1 = MPEG2Source("C:\DVD\04\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl3 = ImageSource("C:\Images\04\1.png", start=0, end=270, fps=clip1.framerate) ovl4 = ImageSource("C:\Images\04\2.png", start=0, end=270, fps=clip1.framerate) ovl3 = ovl3.ConvertToYV12() ovl4 = ovl4.ConvertToYV12() clip2.Trim(28,2714)FadeOut(19) + clip1.Trim(2688,11277) + Dissolve(ovl3, ovl4, 270) + clip1.Trim(11550,0)
-
Actually it turns out I am having an issue. At first I thought it was because I set QTGMC to the Draft preset, but now that it's on Placebo, I'm still seeing the same effect:
Parts of the replacement images looks as though they are bouncing up and down by about a pixel or two. And I only see this effect in the final video, no in VirtualDub. Is there something I did wrong in my script? Same script as above. -
You're going to have to provide more info, there are some inconsistencies in your description
You say it's the same script , but mention QTGMC, but there is no QTGMC in the script
Was source interlaced, or telecined ? I'm assuming interlaced because you're using QTGMC.
If the problem isn't visible in the vdub preview, that suggests it's an encoding problem. So what encoder, what settings did you use? , or a playback configuration issueLast edited by poisondeathray; 17th Sep 2015 at 13:20.
-
Sorry about that, I wrongly assumed those parts of the script weren't relevant. I believe the source is interlaced. There are normally broken horizontal lines in the video, as well as some pixelated edges. QTGMC gets rid of both for me, greatly improving the video quality. I use Xvid (see attachment for complete settings). Here's the complete script:
Code:LoadPlugin("C:\DVD\DGDecode.dll") clip1 = MPEG2Source("C:\DVD\04\VTS_01_1.d2v") clip2 = MPEG2Source("C:\DVD\24\VTS_01_1.d2v") ovl3 = ImageSource("C:\Images\04\1.png", start=0, end=270, fps=clip1.framerate) ovl4 = ImageSource("C:\Images\04\2.png", start=0, end=270, fps=clip1.framerate) ovl3 = ovl3.ConvertToYV12() ovl4 = ovl4.ConvertToYV12() clip2.Trim(28,2714)FadeOut(19) + clip1.Trim(2688,11277) + Dissolve(ovl3, ovl4, 270) + clip1.Trim(11550,0) LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") QTGMC( Preset="Placebo" ) Srestore(Frate=23.976)
-
I have two new findings regarding certain areas of the replacement images bouncing up and down during the dissolve:
- The dissolve only bounces up and down when both QTGMC and Srestore are used together. If I take either one of them out of the script, the dissolve is smooth.
- The dissolve doesn't bounce when the video source is cut into a smaller chunk (I used Mpg2Cut2 to clip a sample, but note that using it to create a clip of the entire video instead only gives me the same bouncy results).
I also have a correction to make:
It turns out I do see the dissolve bounce when I preview the video in VirtualDub before processing.
Here's my current script:
Code:LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") clip1 = MPEG2Source("C:\04\VTS_01_1.d2v") ovl3 = ImageSource("C:\Images\04\3.png", start=0, end=270, fps=clip1.framerate) ovl4 = ImageSource("C:\Images\04\4.png", start=0, end=270, fps=clip1.framerate) ovl3 = ovl3.ConvertToYV12 ovl4 = ovl4.ConvertToYV12 clip1.Trim(2689,11277) + Dissolve(ovl3, ovl4, 270) + clip1.Trim(11550,0) QTGMC( Preset="Placebo" ) Srestore(Frate=23.976)
Video source:
It's encoded interlaced and has interlaced frames, and there's field blending.
Software:
VirtualDub-1.10.4
AviSynth 2.5
Xvid
DGIndex
DVDFab HD Decrypter
Specs:
Windows 7 Professional, 64-bit
AMD Phenom(tm) II X6 1090T Processor 3.21 GHz
AMD 6870
AMD 6850
8.00 GB RAM - The dissolve only bounces up and down when both QTGMC and Srestore are used together. If I take either one of them out of the script, the dissolve is smooth.
-
Try running QTGMC and SRestore on the interlaced clip before adding/dissolving the stills. Of course, that means all your frame numbers have to change.
-
That gives me the following error on the line with QTMGC:
VirtualDub Error
Avisynth open failure:
Script error: Invalid arguments to function "QTMGC" -
Did you specify a video for QTGMC to deinterlace?
This won't work:
Code:clip1 = MPEG2Source("C:\04\VTS_01_1.d2v") QTGMC( Preset="Placebo" ) ...
Code:clip1 = MPEG2Source("C:\04\VTS_01_1.d2v").QTGMC( Preset="Placebo" ) ...
Code:clip1 = MPEG2Source("C:\04\VTS_01_1.d2v") clip1 = clip1.QTGMC( Preset="Placebo" ) ...
Code:clip1 = MPEG2Source("C:\04\VTS_01_1.d2v") clip1 = QTGMC( clip1, Preset="Placebo" ) ...
-
Thank you, jagabo! The dissolve is now smooth. Running QTGMC and Srestore before adding and dissolving the stills works.
Thank you very much for breaking down the options like that. I've read about this stuff, but it's much more clear to see the examples applied to what I'm more familiar with. Your example of what doesn't work is exactly what I did wrong.
One thing though: how do I apply Srestore to more than one video source when I'm doing it in the middle of the script like this instead of at the end? I've done a lot of reading and experiments and can't come up with anything functional. There's something about the grammar or operators I'm just not getting. -
Most filters take an input video and produce an output video:
Code:output = filter(input)
Code:Mpeg2Source("filename.d2v") QTGMC() SRestore()
Code:last = Mpeg2Source("filename.d2v") last = QTGMC(last) last = SRestore(last)
Using a "." between two filters on the same line pipes the output of the filter on the left directly to the filter on the right, without creating a named stream.
Code:clip1 = Mpeg2Source("filename.d2v").QTGMC().SRestore()
Be careful when piping, clip parameters are not available. For example:
Code:Mpeg2Source("filename.d2v") BilinearResize(width/2, height/2)
Code:last = Mpeg2Source("filename.d2v") last = BilinearResize(last, last.width/2, last.height/2)
Code:Mpeg2Source("filename.d2v").BilinearResize(width/2, height/2)
Code:clip1 = Mpeg2Source("filename.d2v").BilinearResize(clip1, clip1.width/2, clip1.height/2)
If you have different clips that need different handling the best thing to do is to use explicit names and pipes:
Code:clip1 = Mpeg2Source("30fps.d2v") # a field blended PAL to NTSC conversion clpi2 = Mpeg2Source("25 fps.d2v) # a 25p PAL video clip1 = clip1.QTGMC().SRestore(frate=25.0) # convert clip1 to 25 fps clip1+clip2 # append clip1 and clip2, both now 25 fps, and implied return(last)
-
-
The point of that example was to show different handling of two clips. If the second clip requires the same handling then apply the same QGMGC and SRestore it too. In the example the two videos are simply appended so you are going to use QGTGMC.SRestore on both you could append them first.
Code:clip1 = Mpeg2Source("30fps1.d2v") clip2 = Mpeg2Source("30pfs2.d2v") clip1+clip2 QTGMC().SRestore(frate=25.0) # convert them to 25 fps
-
Thanks again, but the result I'm getting using this method is that Srestore and QTGMC are not applied to either video source (according to what I see in Vdub). Everything else appears to be functioning. Here's my current script:
Code:LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") clip1 = MPEG2Source("C:\04\VTS_01_1.d2v") clip2 = MPEG2Source("C:\24\VTS_01_1.d2v") clip1+clip2 QTGMC( Preset="Placebo" ).Srestore(Frate=23.976) ovl3 = ImageSource("C:\Images\04\3.png", start=0, end=216, fps=clip1.framerate) ovl4 = ImageSource("C:\Images\04\4.png", start=0, end=216, fps=clip1.framerate) ovl3 = ovl3.ConvertToYV12 ovl4 = ovl4.ConvertToYV12 clip2.Trim(23,2268).FadeOut0(16) + \ clip1.Trim(2690,11277) + \ Dissolve(ovl3, ovl4, 216) + \ clip1.Trim(11550,0)
-
Think: What does clip1+clip2 do? What is the name of the resulting clip? Is it appropriate to do this in the context of the rest of your script?
-
clip1+clip2 appends clip1 and clip2 together, the name of the resulting clip is last...and I'm guessing it's not appropriate to do this in the context of the rest of my script, based on your reply, but I'm completely lost as to what would work.
Can you give me another clue? -
-
-
No. Let's rearrange your clip a bit for clarity:
Code:# first load all the external dependencies LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") # then load all the source clips clip1 = MPEG2Source("C:\04\VTS_01_1.d2v") clip2 = MPEG2Source("C:\24\VTS_01_1.d2v") ovl3 = ImageSource("C:\Images\04\3.png", start=0, end=216, fps=clip1.framerate).ConvertToYV12() # and convert to YV12 ovl4 = ImageSource("C:\Images\04\4.png", start=0, end=216, fps=clip1.framerate).ConvertToYV12() # and convert to YV12 # then join clip1 and clip2 and QTGMC/Srestore them to 23.976 fps clip1+clip2 QTGMC( Preset="Placebo" ).Srestore(Frate=23.976) # last is now your 23.976 clip # clip1, clip2, ovl3 and ovl4 are unchanged <--- HINT clip2.Trim(23,2268).FadeOut0(16) + clip1.Trim(2690,11277) + Dissolve(ovl3, ovl4, 216) + clip1.Trim(11550,0)
Last edited by jagabo; 13th Mar 2018 at 18:29.
-
-
Yes, exactly. So what you want is something like:
Code:# first load all the external dependencies LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") # then load all the source clips clip1 = MPEG2Source("C:\04\VTS_01_1.d2v").QTGMC( Preset="Placebo" ).Srestore(Frate=23.976) clip2 = MPEG2Source("C:\24\VTS_01_1.d2v").QTGMC( Preset="Placebo" ).Srestore(Frate=23.976) ovl3 = ImageSource("C:\Images\04\3.png", start=0, end=216, fps=clip1.framerate).ConvertToYV12() # and convert to YV12 ovl4 = ImageSource("C:\Images\04\4.png", start=0, end=216, fps=clip1.framerate).ConvertToYV12() # and convert to YV12 # finally join the clips with all the effects clip2.Trim(23,2268).FadeOut0(16) + clip1.Trim(2690,11277) + Dissolve(ovl3, ovl4, 216) + clip1.Trim(11550,0)
-
I was able to arrive at a similar solution when I asked my question in post #15, and now I'm getting the same result, which is that the script won't load in Vdub. Srestore can only be called once, right? How is it you're able to run such a script?
-
Get the latest (2013!) version:
http://avisynth.nl/images/Srestore_27h.avsi
# 10/28/2013 martin53
# - Update v2.7e -> v2.7f
# Callable more than once from the same script with help of unique global variables per instance. -
If you were stuck with a filter tha can only be called once you could use something like:
Code:clip1+clip2 CallableOnlyOnceFilter() clip1=last.Trim(0,N) clip2=last.Trim(N+1,0)
By the way, you can return any of the named clips at any time after the clip has been created within the script. This can be useful for debugging or fine tuning:
Code:# first load all the external dependencies LoadPlugin("C:\DGDecode.dll") LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mt_masktools-25.dll") Import("C:\Program Files (x86)\AviSynth 2.5\plugins\Srestore.avsi") # then load all the source clips clip1 = MPEG2Source("C:\04\VTS_01_1.d2v").QTGMC( Preset="Placebo" ).Srestore(Frate=23.976) return(clip1) clip2 = MPEG2Source("C:\24\VTS_01_1.d2v").QTGMC( Preset="Placebo" ).Srestore(Frate=23.976) ovl3 = ImageSource("C:\Images\04\3.png", start=0, end=216, fps=clip1.framerate).ConvertToYV12() # and convert to YV12 ovl4 = ImageSource("C:\Images\04\4.png", start=0, end=216, fps=clip1.framerate).ConvertToYV12() # and convert to YV12 # finally join the clips with all the effects clip2.Trim(23,2268).FadeOut0(16) + clip1.Trim(2690,11277) + Dissolve(ovl3, ovl4, 216) + clip1.Trim(11550,0)
Last edited by jagabo; 14th Mar 2018 at 06:53.
-
Similar Threads
-
Getting a transparent png from a bmp
By supercain in forum EditingReplies: 8Last Post: 17th May 2015, 08:37 -
MP4s Fading In and Out
By box-turtle in forum Software PlayingReplies: 1Last Post: 22nd Jan 2015, 18:52 -
Transparent subtitles problem.
By rayden54 in forum Newbie / General discussionsReplies: 3Last Post: 15th Oct 2014, 01:16 -
avisynth - overlay fadein from transparent
By doma79 in forum EditingReplies: 12Last Post: 6th Dec 2011, 11:38 -
subs look transparent (sub/idx)
By X_Splinter in forum SubtitleReplies: 2Last Post: 22nd Dec 2010, 10:26