VideoHelp Forum
+ Reply to Thread
Results 1 to 14 of 14
Thread
  1. Member
    Join Date
    Jan 2011
    Location
    poland
    Search Comp PM
    hi

    I just started playing with avisynth
    and trying to make a script that "fades in" audio before video - video should show up when audio is already playig with full volume. There is "fade in/out" funcion but I know there should be some more code included

    Could anybody help me with this?

    Hope it is understandable and doable as well.

    Thanks.
    Quote Quote  
  2. The audio can't just fade in before the video. You have to have something there for the video, even if it's only black frames, which is what you mean, I think. So, add black frames to the front of the video the length of the intended fade in, add in the audio, and then do the fade in of the audio/video together.
    Quote Quote  
  3. Member
    Join Date
    Jan 2011
    Location
    poland
    Search Comp PM
    hi manono,

    that is how I thought it could be done
    but I don't know (via avisynth) how to:

    - replace some frames with black ones
    - cover frames with some kind of "fill" filter (name taken from virtualDub's filters)

    I'm trying to do this because I captured some live music from tv (long one) and now I'm cutting into smaller parts but very offen when the music starts playing (at beginning of the smaller part) camera is still showing some buildings or worse things which I'd like to get rid of.

    Anyway I decided to try avisynth for that as a good exercise.

    Could this be done somehow with "animate" and "levels" filter (to fade from black) and then just add "fade in" ("fade in" will be shorter from "animate" to keep video black while music is already playing) ?
    Quote Quote  
  4. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by manono View Post
    So, add black frames to the front of the video the length of the intended fade in, add in the audio, and then do the fade in of the audio/video together.
    Maybe I misunderstand what you mean, but won't that make the audio out of sync with the video?

    adom, I think all you need to do is apply the fade-in to the video only, rather than to both video and audio.
    Or, looking at it another way, dub the original unfaded audio onto the faded video.

    AudioDub(FadeIn(50), last)

    That gives a 50 frame fade-in for the video.
    If you want a (shorter) fade-in for the audio as well (say 10 frames), do
    AudioDub(FadeIn(50), FadeIn(10))
    Quote Quote  
  5. Member
    Join Date
    Nov 2009
    Location
    United States
    Search Comp PM
    Video=avisource("clip.avi").KillAudio
    Audio=avisource("clip.avi").KillVideo
    Black=BlankClip(Video,length=75) #3 seconds of black
    Video=Black + Video.Trim(75,0).FadeIn(25) #trim 3 seconds from video with 1 second fade in and add 3 seconds of black in front
    Audio=Audio.FadeIn(25) #1 second audio fade in
    AudioDub(Video,Audio) #Combine them again
    Quote Quote  
  6. Member
    Join Date
    Jan 2011
    Location
    poland
    Search Comp PM
    @Gavino
    your method is working very good - short and simple - thanks.

    @Khaver
    you just gave the answer to my question how to replace frames with black ones - and you did the whole thing like manono propsed - thanks a lot.
    Quote Quote  
  7. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by Khaver View Post
    Video=avisource("clip.avi").KillAudio
    Audio=avisource("clip.avi").KillVideo
    The KillVideo and KillAudio are unnnecessary, and KillAudio actually changes the timing, since audio-only clips are assumed to have a framerate of 24fps as far as FadeIn, etc, are concerned.

    Simpler would be:
    AviSource("clip.avi")
    Black=BlankClip(last,length=75) #3 seconds of black
    Video=Black + Trim(75,0).FadeIn(25) #trim 3 seconds from video with 1 second fade in and add 3 seconds of black in front
    Audio=FadeIn(25) #1 second audio fade in
    AudioDub(Video,Audio) #Combine them again

    and, if you like, the last two lines could be combined to
    AudioDub(Video, FadeIn(25))
    Quote Quote  
  8. Member
    Join Date
    Jan 2011
    Location
    poland
    Search Comp PM
    I checked avisynth wiki about that command and that's what it says:

    ... The fps parameter is optional, default=24.0, and provides a reference for num_frames in audio only clips. It is ignored if a video stream is present ...

    it can be adjusted but better to avoid it to be on safer side - frameRate doesn't change back and fore - that's how I understand this
    Quote Quote  
  9. Originally Posted by Gavino View Post
    Maybe I misunderstand what you mean, but won't that make the audio out of sync with the video?
    Not if I understood correctly what he had in mind. The audio was being thrown off synch purposely, or maybe it's a newly created audio, special to this video. What I had in mind (I was at a non-AviSynth computer when I wrote my first reply) was exactly what Kaver proposed and what you later modified.
    Quote Quote  
  10. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by adom View Post
    ... The fps parameter is optional, default=24.0, and provides a reference for num_frames in audio only clips. It is ignored if a video stream is present ...

    it can be adjusted but better to avoid it to be on safer side - frameRate doesn't change back and fore - that's how I understand this
    That's correct, that's what I meant.
    With Khaver's original script, the length of the audio fade was not 25 video frames, but 25/24 seconds.
    You would have to add the fps parameter when fading the audio.

    Note that the two clips passed to AudioDub are allowed to contain both video and audio - in that case, it takes video from its first parameter and audio from its second, so there's no need to kill the unwanted video/audio tracks.

    Originally Posted by manono View Post
    ... The audio was being thrown off synch purposely, or maybe it's a newly created audio, special to this video. What I had in mind (I was at a non-AviSynth computer when I wrote my first reply) was exactly what Kaver proposed and what you later modified.
    OK, but note that Khaver's solution maintains audio sync, it's not thrown off - the video length is unchanged, the added blank frames overwite, rather than extending, the beginning.
    Last edited by Gavino; 31st Jan 2011 at 04:04.
    Quote Quote  
  11. Member
    Join Date
    Jan 2011
    Location
    poland
    Search Comp PM
    Just one more question:
    what if I want to replace some frames from the end of the video with blakClip?
    Let's say, my video ends at frame 999 and I'd like to replace last 50 frames with blankClip (so the output is: 0 --- 949 video + 950 --- 999 blankClip)

    How the trim funcion should look like?
    I found such syntax working: trim(0,-949)
    but maybe there is a better one that lets me write only the number of frames I'd like to remove from the end - for example trim(-50) ?
    Quote Quote  
  12. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Trim(0, -949) selects the first 949 frames and is the same as Trim(0, 948).

    There is no special Trim syntax for trimming frames off the end, but to remove the last 50 frames you could use
    Trim(0, -(Framecount()-50))
    or
    Trim(0, Framecount()-51)
    Quote Quote  
  13. Member
    Join Date
    Jan 2011
    Location
    poland
    Search Comp PM
    Thank You.
    Quote Quote  
  14. Originally Posted by Gavino View Post
    OK, but note that Khaver's solution maintains audio sync, it's not thrown off - the video length is unchanged, the added blank frames overwite, rather than extending, the beginning.
    Oh yeah, you're right (as usual). Then that's not what I was attempting to explain. My intent was to add new black frames to the beginning of the complete original video. Add the audio and then fade it in, fading in the black as well, but since it was already black, the video wouldn't be faded in. I suggested doing it this way because of the way the original request was worded:
    Originally Posted by adom View Post
    ...trying to make a script that "fades in" audio before video - video should show up when audio is already playig with full volume.
    But I suppose it's academic now, if adom got what he wanted. And if there is an audio synch that has to be maintained, my idea wouldn't work. But the impression I got was that there wasn't any audio synch to be maintained, like maybe it was some unrelated music meant to be played with the video.
    Quote Quote  



Similar Threads

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