VideoHelp Forum
+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Hi,

    I'm new to avisynth but am loving the control it offers. I'm having major problems creating a fadein title for one of my videos.

    I have the clip, and on top i'd like to fade in a smaller rectangle with some writing on it.

    This is what I have so far

    Code:
    base= DirectShowSource(\"sequencer.avi\").ConvertToYUY2().Sharpen(0.5)
    
    temp1 = BlankClip(base, 180, 500, 250)
    temp2 = Subtitle(temp1, \"Test Subtitle\n and some more\",250,125,0, 180,\"Arial\", 60 ,$FFFFFF, align=5, lsp=1)
    temp3 = Trim(base, 5106, 5300)
    
    Overlay(temp3, temp2.fadein(30), 110, 100, opacity=0.5)
    The opaque rectangle is placed correctly but does not fade in.

    I've tried every different combination of multiple overlays and layers but cannot seem to get it to work.

    I understand that because I'm in YUY2, I can't create a mask and do a showalpha()?
    I want the background clip to be constantly there, thus preventing a overall FadeIn on the Overlay
    I'm also trying to get the subtitle to have no opacity (while the background plate is 0.5 opacity)

    (PS is there a good resource on explaining masks in a avisynth setting? I still haven't fully grasped it yet)

    Thanks for any help you might be able to shed, these forums have been invaluable to me so far.

    cheers
    damo
    Quote Quote  
  2. **bump**

    Can anyone help me out or point me in the right direction?

    cheers
    damo
    Quote Quote  
  3. are you trying to fade in the black box from 0 to 50% opacity ? and they fade out or stay at 50%?

    what about the timing of the text ? how do you want it to fade in or out or stay ? and do you want it timed in unison with the black box ?

    the problem you have right now is your 50% opacity black box is controlled by the overlay command, so you would have to animate the opacity parameter from 0 to 0.5 ; but animate() is difficult to use in that fashion - it is usually used to control a filter, not part of a filter. I don't know how to do it, maybe someone else does.

    There are probably better ways to do this, but one approach this would be to create your 50% opacity black box in an image editor (e.g. photoshop, irfanview, gimp) . I attached one below. You have to use an image format that supports alpha channel (e.g. png) , and use RGBA or RGB32 (in order to use the alpha channel later)

    in this example, the black box and the white text fade in at the same time, but you weren't clear about how you wanted the timing or if you wanted it to fade out. Because the opacity is controlled by the the asset itself instead of through the overlay command (it was made in an image editor and when at max opacity, is actually 50%), you can use the fadein() to control it

    base=AVISource("video.avi").trim(5106,5300)
    black=ImageSource("50.png",pixel_type="RGB32")
    temp2 = Subtitle(black, "Test Subtitle",250,125,0, 180,"Arial", 60 ,$FFFFFF, align=5, lsp=1)

    overlay(base,black,mask=black.showalpha().fadein(3 0), 110,100, opacity=0.1)
    a=last

    overlay(a, temp2,mask=temp2.showalpha().fadein(30), 110,100)

    The only reference I know of is
    http://avisynth.org/mediawiki/Overlay

    Note: as in that link, the levels of your clip or overlay might need to be adjusted if you are using PC vs. TV Levels with the coloryuv command . Since you used ConvertToYUY2() in your example (instead of specifying a PC matrix), I'm assuming your clip is TV levels.

    Or you can "cheat" and adjust the opacity of the black clip by using the opacity parameter of the overlay command. If your AVI clip was TV levels (16-235), if you add opacity=0.1 to the black overlay, it will approximate what you had in your first example in terms of black opacity (since overlay and RGBA are all done in full range 0-255, and the 50% black clip was done using 0-255), instead of having to do the levels conversions - I changed the post above to reflect that
    Image Attached Thumbnails Click image for larger version

Name:	50.png
Views:	32939
Size:	1.1 KB
ID:	3298  

    Last edited by poisondeathray; 29th Aug 2010 at 11:56.
    Quote Quote  
  4. Thanks so much for that.

    I was hoping to fadein the box and subtitle at the same time, and then fade them out together as well.

    I like the idea of doing a 50% transparent png instead of creating a blankclip. I'm in yuy2 space (only because that is what the original video is) so will convert to RGB32 just for this trim/overlay and then back again.

    Thanks again for your help!

    cheers
    damo
    Quote Quote  
  5. I was hoping to fadein the box and subtitle at the same time, and then fade them out together as well.
    You can use fadeIO (for fade in out) , but you have to specify the length of the clip for it to work in the imagesource function (for the black clip)
    http://avisynth.org/mediawiki/Fade

    e.g.

    base=AVISource("video.avi").trim(5106,5300)
    black=ImageSource("50.png",pixel_type="RGB32",0,80 )
    temp2 = Subtitle(black, "Test Subtitle",250,125,0, 180,"Arial", 60 ,$FFFFFF, align=5, lsp=1)

    overlay(base,black,mask=black.showalpha().fadeIO(2 0), 110,100, opacity=0.1)
    a=last

    overlay(a, temp2,mask=temp2.showalpha().fadeIO(20), 110,100)
    This is probably too short duration for you - I'm sure you can fiddle with the lengths for the fades to where you want it

    Personally , I don't like converting to RGB and back to YV12 if I don't have to (quality loss) , but it's up to you .
    Last edited by poisondeathray; 29th Aug 2010 at 18:56.
    Quote Quote  
  6. Thank you so much!!!

    All working now.

    RGB vs YUY2? I've kept it in YUY2 as that is what it was originally encoded in. I'm chopping and rearranging the original clip. Would I be better off converting to RGB to start with and leaving it that way?

    cheers
    damo
    Quote Quote  
  7. There is a bit of quality loss when you convert colorspaces (rounding errors). I can't see any advantage to converting to RGB and back to YUY2, if it looks ok now. Overlay() can overlay the RGBA overlay onto YUV sources , it's not a problem. Only if your final format goal was RGB or you are bringing this into another application that expects RGB (e.g. compositing programs, or some editors) would I consider converting the base clip to RGB (but if you were going to do that, you could just as easily add the overlay in those programs....)
    Quote Quote  
  8. Member
    Join Date
    May 2011
    Location
    Paris (France)
    Search Comp PM
    Hi,

    I do not open a new thread because what I want to do is very similar to the issue of doma79.
    I wrote this following script whish is working fine. It makes appear an animated logo in the upper right corner of the video :
    vid=DirectShowSource("video.wmv", 25.00, convertfps=true).ConvertToRGB32
    logo=CoronaSequence("i*.bmp",sort=2,textmode=1).Co nvertToRGB32
    # mask the grey background but leave the other colors unchanged
    logo=ColorKeyMask(logo,$4d4d4d,$000000)
    overlay(vid,logo,mask=logo.showalpha().fadein(30), 110,100, opacity=0.1)
    # place the image into the upper right corner of the video
    ovl=Layer(vid,logo,"add",255,370,0)
    return ovl
    I'd like to combine this script found on this thread :

    base=AVISource("video.avi")
    logo=ImageSource("image.jpg",pixel_type="RGB32",0, 80 )
    overlay(base,logo,mask=logo.showalpha().fadeIO(20) , 110,100, opacity=0.8)
    In fact, I'd like the animated logo to fade in then fade out, after a while. Unfortunately I am not sure, opacity could work with CoronaSequence filter.

    Thanks for helping. I apologize for my poor english.
    Of course, I can move and open another thread.
    Quote Quote  
  9. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by kaskaï View Post
    I wrote this following script whish is working fine. It makes appear an animated logo in the upper right corner of the video :
    Code:
    vid=DirectShowSource("video.wmv", 25.00, convertfps=true).ConvertToRGB32
    logo=CoronaSequence("i*.bmp",sort=2,textmode=1).ConvertToRGB32
    # mask the grey background but leave the other colors unchanged
    logo=ColorKeyMask(logo,$4d4d4d,$000000)
    overlay(vid,logo,mask=logo.showalpha().fadein(30), 110,100, opacity=0.1)
    # place the image into the upper right corner of the video
    ovl=Layer(vid,logo,"add",255,370,0)
    return ovl
    The 'overlay' command here is not used (its result is ignored) and can be removed from the script - the Layer command is what is doing the overlay.

    I'd like the animated logo to fade in then fade out, after a while. Unfortunately I am not sure, opacity could work with CoronaSequence filter.
    The CoronaSequence filter is irrelevant as far as the fading is concerned - what you need to do is apply a fade to the alpha layer of the logo after doing the chroma key (ColorKeyMask).
    As I said, remove the 'overlay' line. In its place, put this:
    logo = Mask(logo, logo.ShowAlpha().FadeIO(30))
    Quote Quote  
  10. Member
    Join Date
    May 2011
    Location
    Paris (France)
    Search Comp PM
    Oups, of course the 'overlay' command is not used; I think this was a "scorrie" of a previous test.
    Anyway, thanks for your answer; this is exactly what I wanted to do.

    Maybe you could help me for the last step of my script. I'd like this sequence of animated logo to stop after 25 frames and restart every 30 seconds during the whole video. I have found this filter ApplyEvery.dll but I need firstly to order the logo animation to stop and disappear after 25 frames.

    I hope that what I say makes sense for you.


    Thanks Gavino ...
    Quote Quote  
  11. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    How many frames are you currently getting from CoronaSequence?
    If less than 25, use Loop() to repeat an appropriate number, otherwise use Trim() to reduce the length (or delete some source image files).
    Obviously, you will also have to reduce the alpha fade in and out time (FadeIO) to something below 12 frames.
    Quote Quote  
  12. Member
    Join Date
    May 2011
    Location
    Paris (France)
    Search Comp PM
    Thanks Gavino,


    here is my new script using loop :

    Code:
    vid=DirectShowSource("video.wmv", 25.00, convertfps=true).ConvertToRGB32
    logo=CoronaSequence("F:\Windows7  Documents\logo\i*.bmp",sort=2,textmode=1).ConvertToRGB32.ColorKeyMask($4d4d4d,$000000).fadeio(10).loop()
    ovl=Layer(vid,logo,"add",176,370,0)
    return ovl
    It is working fine, BUT :

    What I failed to do, is to introduce a kind of "pause"between each loop. It means that I'd like my logo animation to start its sequence every 30 seconds. Here in this video, you can watch excatly what I mean : http://rutube.ru/tracks/50456631.html

    Thanks
    Last edited by kaskaï; 12th May 2012 at 16:05.
    Quote Quote  
  13. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    I can't see anything on that site (perhaps because of my security settings, which I'm reluctant to change).

    As I understand it, you want the logo sequence to last 25 frames and restart every 30 seconds. Is that right?

    Loop() by default makes the clip repeat (almost) indefinitely.
    But the idea was to use it to repeat the logo sequence for up to 25 frames - say you had 5 frames, then you would use Loop(5).
    Then, as you suggested, use ApplyEvery to overlay that 25-frame logo sequence every 30 seconds.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!