INDEX  F.A.Q.  SEARCH  LATEST POSTS     Rules  Register  Profile  Private messages  Login


Login:   Username:  Password:   Log me on automatically    
Register I forgot my password I forgot my username Resend the activation key

AviSynth - JDL_ApplyRange() & FadeIn() Compatibility Issue?

Forum Index -> Video -> Video Conversion Printer-friendly version
Reply to topic
Author Message
Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 17:22 Posts Comp View users profile Send private message Reply with quote

I'm trying to label my video encode with a picture at a certain point. I also want it to fade in. This is the code I'm trying to accomplish that with:
global a1=last
global a2=ImageReader("D:\David\Source Material\For Encoding or Editing\DBZ Remastered\Episode 231\Ep. 231.png", pixel_type="RGB32")
JDL_ApplyRange(1350, 1553, "Overlay(a1, a2, mask=a2.ShowAlpha().FadeIn(27))")


With just Overlay itself, the FadeIn works perfectly fine but obviously, the picture is there during the whole video. When I put it in the JDL_ApplyRange method, the image stays in between the frame numbers specified but it doesn't fade in. I think that's because JDL_ApplyRange isn't compatible with things that change frames around (though I'm not sure FadeIn does so..). I tried placing FadeIn in every place possible but it doesn't work anywhere. When I applied it to the end of JDL_ApplyRange, it told me it was incompatible with it and told me to use JDL_ApplyRangeOld. But, Overlay doesn't work in that function, so, any solutions you can think of?.. Greatly appreciated, thanks.


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 17:31 Posts View users profile Send private message Reply with quote

Why was the other thread locked on Doom9?

The easiest way IMO would be to use trim() to apply the overlay in segments


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 17:38 Posts Comp View users profile Send private message Reply with quote

poisondeathray wrote:
Why was the other thread locked on Doom9?

The easiest way IMO would be to use trim() to apply the overlay in segments


If you really want to know the whole story I'll tell you, but basically, if you take my word for it, I was not rightfully banned. So they locked the thread because it was by me... Sigh... And very cool that you're here ^^

To be honest, I tried Trim already but couldn't figure out how to use it properly. I don't really get it... I really only started all this stuff a couple months ago. I feel sorry that you practically have to baby me. Lol, but thanks man, I really appreciate it.


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 18:12 Posts View users profile Send private message Reply with quote

Gavino basically gave you the script in the other thread

Think of Trim() as cutting in segments, so Trim(0,100) would return a video with frames 0 to 100

Code:

a1=mpeg2source("file.d2v")
a2=ImageReader("logo.png",pixel_type="RGB32")

a1.Trim(0,1376) ++ Overlay(a1.Trim(1377,1553),a2,mask=a2.ShowAlpha().FadeIO(27)) ++ a1.Trim(1554,0)



There are 3 sections , from frames 0 to 1376, from 1377 to 1553, and from 1554 to end, each are split by the ++ which is an aligned splice in avisynth

For some reason, the fade out isn't working with the overlay, only fade in works... I'll fiddle with it or maybe someone else knows why


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 18:20 Posts Comp View users profile Send private message Reply with quote

poisondeathray wrote:
Gavino basically gave you the script in the other thread

Think of Trim() as cutting in segments, so Trim(0,100) would return a video with frames 0 to 100

Code:

a1=mpeg2source("file.d2v")
a2=ImageReader("logo.png",pixel_type="RGB32")

a1.Trim(0,1376) ++ Overlay(a1.Trim(1377,1553),a2,mask=a2.ShowAlpha().FadeIO(27)) ++ a1.Trim(1554,0)



There are 3 sections , from frames 0 to 1376, from 1377 to 1553, and from 1554 to end, each are split by the ++ which is an aligned splice in avisynth

For some reason, the fade out isn't working with the overlay, only fade in works... I'll fiddle with it or maybe someone else knows why

OH! I get it now. That's very cool. Thank you. I only need FadeIn anyway so that's ok. Maybe someday they'll be kind enough to unban my account on doom9... The way everything played was just messed up...


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 18:24 Posts View users profile Send private message Reply with quote

OK if you use reverse() you can use fadeIN() , and on that cut sequence reverse it again to place it in with a Trim() command and it will look like a fade out. You have to get the frame#'s exact by working backwards because the end frame is now frame 0. I'd still like to know why the FadeOUT doesn't work with the overlay, but this should work as a workaround

Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 18:32 Posts Comp View users profile Send private message Reply with quote

poisondeathray wrote:
OK if you use reverse() you can use fadeIN() , and on that cut sequence reverse it again to place it in with a Trim() command and it will look like a fade out. You have to get the frame#'s exact by working backwards because the end frame is now frame 0. I'd still like to know why the FadeOUT doesn't work with the overlay, but this should work as a workaround

Try it with these instead and see if it works.

Code:
function FadeOutX(clip c, int frames)
{
   return c.DeleteFrame(c.FrameCount-1).FadeOut(frames)
}

function FadeInX(clip c, int frames)
{
   return c.DeleteFrame(0).FadeIn(frames)
}


manono
Member


Joined: 28 Aug 2003

Post Posted: May 04, 2009 18:37 Posts View users profile Send private message Reply with quote

I was fooling around with it while you guys were posting back and forth, and came up with a different way to do it, using the Dissolve command:

A=MPEG2Sourcempeg2source("file.d2v")
B=ImageSource("logo.png",pixel_type="RGB32",End=203)
X=A.Trim(0,1376)
X=Dissolve(X,B,27)
Y=A.Trim(1377,0)
X+Y

It's a 27 frame Dissolve (fade in), ending at frame number 1376 with the PNG lasting a total of 203 frames before going back to the original video. It could be made to dissolve out the same way (not needed apparently).


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 18:44 Posts View users profile Send private message Reply with quote

Typhoon - That function is basically the same as using FadeIn or FadeOut manually, but it has to be applied to the overlay segment, not the actual video portion. The problem seems to be with all types of FadeOUT, FadeOUT1, FadeOUT2, and the "out" portion of fadeIO versions for the overlay, not the video portion

I can confirm, the reverse trick does work for the fade out, for the transparent overlayed section

manono's script looks interesting, I'll play with it in a sec..


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 18:46 Posts Comp View users profile Send private message Reply with quote

manono wrote:
I was fooling around with it while you guys were posting back and forth, and came up with a different way to do it, using the Dissolve command:

A=MPEG2Sourcempeg2source("file.d2v")
B=ImageSource("logo.png",pixel_type="RGB32",End=203)
X=A.Trim(0,1376)
X=Dissolve(X,B,27)
Y=A.Trim(1377,0)
X+Y

It's a 27 frame Dissolve (fade in), ending at frame number 1376 with the PNG lasting a total of 203 frames before going back to the original video. It could be made to dissolve out the same way (not needed apparently).


I will try this. The way PoisonDeathRay suggested works perfectly though.


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 18:47 Posts Comp View users profile Send private message Reply with quote

poisondeathray wrote:
Typhoon - That function is basically the same as using FadeIn or FadeOut manually, but it has to be applied to the overlay segment, not the actual video portion. The problem seems to be with all types of FadeOUT, FadeOUT1, FadeOUT2, and the "out" portion of fadeIO versions for the overlay, not the video portion

I can confirm, the reverse trick does work for the fade out, for the transparent overlayed section

manono's script looks interesting, I'll play with it in a sec..


I thought it might be because of the frame problem - that's why I suggested it.


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 18:56 Posts Comp View users profile Send private message Reply with quote

manono wrote:
I was fooling around with it while you guys were posting back and forth, and came up with a different way to do it, using the Dissolve command:

A=MPEG2Sourcempeg2source("file.d2v")
B=ImageSource("logo.png",pixel_type="RGB32",End=203)
X=A.Trim(0,1376)
X=Dissolve(X,B,27)
Y=A.Trim(1377,0)
X+Y

It's a 27 frame Dissolve (fade in), ending at frame number 1376 with the PNG lasting a total of 203 frames before going back to the original video. It could be made to dissolve out the same way (not needed apparently).


Dissolve won't work because A and B have to be the same formats.


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 18:58 Posts View users profile Send private message Reply with quote

This would be the "hack" using reverse() for the overlay fade out. I split it out to make it more clear for analysis

Code:

a1=Mpeg2Source("file.d2v")
a2=ImageReader("logo.png",pixel_type="RGB32")

b1=a1.Trim(0,1376)
b2=Overlay(a1.Trim(1377,1500),a2,mask=a2.ShowAlpha().FadeIn(27))
b3=Overlay(a1.Trim(1501,1553).Reverse(),a2,mask=a2.ShowAlpha().FadeIn(27))
b4=a1.Trim(1554,0)

b1++b2++b3.Reverse()++b4


Last edited by poisondeathray on May 04, 2009 19:02, edited 1 time in total


manono
Member


Joined: 28 Aug 2003

Post Posted: May 04, 2009 19:01 Posts View users profile Send private message Reply with quote

Typhoon859 wrote:
Dissolve won't work because A and B have to be the same formats.

You want to explain what you mean by "same formats"? I've already tested this. Admittedly I used an AVI and a PNG, but it worked great - did just what I said it does in my post. I don't know why it has to be RGB32, as a DVD (and my AVI) is YV12, but I converted to RGB32 for the testing. It's simple and in its own little way, elegant, I think.


Last edited by manono on May 04, 2009 19:03, edited 2 times in total


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 19:02 Posts Comp View users profile Send private message Reply with quote

poisondeathray wrote:
This would be the "hack" using reverse() for the overlay fade out. I split it out to make it more clear for analysis

Code:

a1=Mpeg2Source("file.d2v")
a2=ImageReader("logo.png",pixel_type="RGB32")

b1=a1.Trim(0,1376)
b2=Overlay(a1.Trim(1377,1500),a2,mask=a2.ShowAlpha().FadeIn(27))
b3=Overlay(a1.Trim(1501,1553).Reverse(),a2,mask=a2.ShowAlpha().FadeIn(27))
b4=a1.Trim(1554,0)

b1++b2++b3.reverse()++b4


Wow. That's pretty smart. Indeed strange that FadeOut doesn't work regularly...


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 19:15 Posts View users profile Send private message Reply with quote

@manono - I think typhoon wants the transparent overlay to dissolve or fade, not the underlying video. It's not clear from this thread opening post what typhoon wanted, but I had the benefit of viewing the other thread, and he really should have made a better/more clear OP.... The RGB has to be 32 for the alpha channel to show through on the .png image, and the alpha needs to be called with ShowAlpha() in avisynth or the image will be 100% opaque, and the underlying video portion will not be visible behind the overlay section

I might be missing something, but I can't get your script to work either...


Typhoon859
Member


Joined: 04 May 2009
Location: United States

Post Posted: May 04, 2009 19:23 Posts Comp View users profile Send private message Reply with quote

poisondeathray wrote:
@manono - I think typhoon wants the transparent overlay to dissolve or fade, not the underlying video. It's not clear from this thread opening post what typhoon wanted, but I had the benefit of viewing the other thread, and he really should have made a better/more clear OP.... The RGB has to be 32 for the alpha channel to show through on the .png image, and the alpha needs to be called with ShowAlpha() in avisynth or the image will be 100% opaque, and the underlying video portion will not be visible behind the overlay section

I might be missing something, but I can't get your script to work either...


Oh, right. My bad. I should've made that more clear. Ummm, well, I knew that it was the video that would be faded in there but I just wanted to see if it worked to then modify it for my purposes. I'm sure that idea can be worked out somehow, with the Disolve.


manono
Member


Joined: 28 Aug 2003

Post Posted: May 04, 2009 19:24 Posts View users profile Send private message Reply with quote

poisondeathray wrote:
@manono - I think typhoon wants the transparent overlay to dissolve or fade, not the underlying video. It's not clear from this thread opening post what typhoon wanted, but I had the benefit of viewing the other thread, and he really should have made a better/more clear OP

Oh, OK. I don't know the other thread. You seem to be saying that the underlying video is still visible after the PNG is faded in which, of course, my script won't do. But then, as you also say, there's nothing at all about requiring that in the earlier posts. All I see is him wanting a picture to be faded in and kept there for a few seconds. Thanks for the clarification.

I guess there's no need now for anyone to get it to work. But by fooling around and doing it myself I learned something that may come in handy in the future. About all I did that's not in the posted script was to resize the PNG to the resolution of my test AVI and convert the AVI's colorspace to RGB32.


poisondeathray
Member


Joined: 07 Sep 2007
Location: Canada

Post Posted: May 04, 2009 19:29 Posts View users profile Send private message Reply with quote

manono wrote:
About all I did that's not in the posted script was to resize the PNG to the resolution of my test AVI and convert the AVI's colorspace to RGB32.


OK thanx, I did resize the png to match , but I forgot the AVI colorspace! redface.gif Overlay() doesn't require matching colorspaces


Reply to topic All times are GMT - 6 Hours
Forum Index -> Video -> Video Conversion Page 1 of 1





You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Jump to:  
Display:   
Replay Media Catcher lets you record ANY streaming video and save on your computer! More info or download trial!
About   Advertise   Forum Archive   RSS Feeds   Statistics