VideoHelp Forum
+ Reply to Thread
Results 1 to 29 of 29
Thread
  1. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Suppose I wish to apply different settings of a particular filter to a clip (or) different filters to different parts of a clip.

    How can I do this in avisynth?

    Thanks
    Quote Quote  
  2. You can divide up your video into segments using trim, then join with aligned splice or use applyrange()

    http://avisynth.org/mediawiki/ApplyRange


    e.g

    Code:
    a= avisource()
    
    a1 = a.trim(0,100).filter1()
    a2 = a.trim(101,200).filter2()
    a3 = a.trim(201,300)
    
    a1 ++ a2 ++ a3
    This would apply filter1 to frames 0-100, filter2 to 201-300, and leave 201-300 same as original
    Quote Quote  
  3. You can use applyrange but it's use is limited otherwise the solution above is certainly a 1st option
    *** DIGITIZING VHS / ANALOG VIDEOS SINCE 2001**** GEAR: JVC HR-S7700MS, TOSHIBA V733EF AND MORE
    Quote Quote  
  4. I usually use ReplaceFramesSimple which is part of stickboy's RemapFrames:

    http://avisynth.org/stickboy/

    The usage goes something like this:

    BaseClip=Last
    SourceClip=BaseClip
    SourceClip=SourceClip.YourFilterHere
    ReplaceFramesSimple(BaseClip,SourceClip,Mappings="[0 189] [7607 7613]")

    That uses the filter from frames 0-189 and 7607-7613. It can be called (and different filters used) as many times as you like in a single script.
    Quote Quote  
  5. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Thanks.
    Quote Quote  
  6. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    Thank heaven I have TMPGenc Plus and TMPGenc MPEG editors. I'd have a nervous breakdown cutting/joining the typical 10 to 20 segments you need for color-correcting several minutes of bad VHS. All the methods mentioned above will work, though. I've used 'em a few times - - my last (3-hour) VHS restoration had more than 300 color-corrected segments.
    Last edited by sanlyn; 21st Mar 2014 at 07:40.
    Quote Quote  
  7. Member AlanHK's Avatar
    Join Date
    Apr 2006
    Location
    Hong Kong
    Search Comp PM
    Originally Posted by poisondeathray View Post
    Code:
    a= avisource()
    
    a1 = a.trim(0,100).filter1()
    a2 = a.trim(101,200).filter2()
    a3 = a.trim(201,300)
    
    a1 ++ a2 ++ a3
    I prefer to avoid using named variables when possible. It makes it simpler and more extensible -- you don't have to keep thinking up new names (even if they're a9, a10 a11...)

    Code:
    avisource()
    
    trim(0,100).filter1() ++\
    trim(101,200).filter2() ++\
    trim(201,300)
    Note that since the three trims form a single statement, all the frame number references are to the "last" video, i.e. from the avisource().

    ReplaceFramesSimple is good too, especially when I need to use the same filter (such as a delogo) on a number of disconnected segments.
    Quote Quote  
  8. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Or I could just cut the segments in Virtualdub (keyframes, of course). Then I could save them, apply whatever filter I need, and rejoin them.
    Quote Quote  
  9. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Yes, you could ....
    But since you're using Avisynth anyway, you might as well do it all in one script, using one of the three techniques suggested above.

    Then, you have no need for intermediate files and are not restricted to keyframes for your segments.
    Quote Quote  
  10. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    Originally Posted by unclescoob View Post
    Or I could just cut the segments in Virtualdub (keyframes, of course). Then I could save them, apply whatever filter I need, and rejoin them.
    I don't think AVI files have keyframes.

    Someone jump up and hit me with a correction if I'm wrong on that. Well, don't hit me -- just nudge.

    If you do all this cutting in Avisynth, remember that the audio might not match up at the end of the cut segments. Better to Trim() in Avisynth to keep audio aligned at the edit point.
    Last edited by sanlyn; 21st Mar 2014 at 07:41.
    Quote Quote  
  11. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Originally Posted by sanlyn View Post
    Someone jump up and hit me with a correction if I'm wrong on that.
    No, please. Someone don't jump up with anymore corrections. Even a simple question in this forum turns into an unecessary, triple-bypass, neurotically egotistical smartboy debate that does nothing but lead to further confusion.

    I got it. Thanks.

    But yes, Virtualdub does give you the option to trim your MPEG with keyframes, then save as an AVI
    Quote Quote  
  12. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Oh and sanlyn, did you get my PM about that other thing?
    Quote Quote  
  13. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    Yep. I have other questions about the last script I posted, but can't get to it now. Later.
    Last edited by sanlyn; 21st Mar 2014 at 07:41.
    Quote Quote  
  14. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    This isn't working out guys. Trim only TRIMS from one selected frame to another. Alan, I tried it your way:

    avisource()

    trim(0,100).filter1() ++\
    trim(101,200).filter2() ++\
    trim(201,300)

    But it will just select frame from 0 - 100 and that's it. It won't divide my clip into different segments where I can apply different filters. What am I doing wrong?
    Quote Quote  
  15. vid1 = AVISource("C:\MyVideo.avi").trim(0,100).filter1(). filter2().filter3()....
    vid2 = AVISource("C:\MyVideo.avi").trim(101,200).filter1( ).filter2().filter3()....
    vid3 = AVISource("C:\MyVideo.avi").trim(201,300).filter1( ).filter2().filter3()....
    vid1 ++ vid2 ++ vid3

    That's how i do personally
    *** DIGITIZING VHS / ANALOG VIDEOS SINCE 2001**** GEAR: JVC HR-S7700MS, TOSHIBA V733EF AND MORE
    Quote Quote  
  16. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by unclescoob View Post
    avisource()
    trim(0,100).filter1() ++\
    trim(101,200).filter2() ++\
    trim(201,300)

    But it will just select frame from 0 - 100 and that's it. It won't divide my clip into different segments where I can apply different filters. What am I doing wrong?
    It should work.
    Is that your complete script? You've probably got something else that's interfering with the final result.

    Originally Posted by themaster1 View Post
    vid1 = AVISource("C:\MyVideo.avi").trim(0,100).filter1(). filter2().filter3()....
    vid2 = AVISource("C:\MyVideo.avi").trim(101,200).filter1( ).filter2().filter3()....
    vid3 = AVISource("C:\MyVideo.avi").trim(201,300).filter1( ).filter2().filter3()....
    vid1 ++ vid2 ++ vid3
    You're unnecessarily opening the file three times, using more memory, etc. Better would be:
    v = AVISource("C:\MyVideo.avi")
    vid1 = v.trim(0,100).filter1().filter2().filter3()....
    vid2 = v.trim(101,200).filter1().filter2().filter3()....
    vid3 = v.trim(201,300).filter1().filter2().filter3()....
    vid1 ++ vid2 ++ vid3
    Quote Quote  
  17. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Oh shit, it works! Thanks!
    Quote Quote  
  18. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Spoke to soon. Yes, trim works perfectly for what I needed to do with this video. Then came authoring time. When I played my dvd, the audio is completely out of sync. My video looks fine. Doesn't appear too slow or anything. The audio is going faster than the video. Does trim result in this nonsense or was it a coincidence and just a bad author?
    Quote Quote  
  19. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    If you play the joined AVI in MediaPlayer or VLC Player, etc., is the sound in sync? If the AVI is outta sync in a media player before you encode or author, it won't be in sync later.

    Avisynth has two symbols for joining AVI video that has audio as well as video. The single plus sign (+) is an unaligned splice, the double plkus sign (++) is an aligned splice. Audio is treated differently with each type of join. See the Avisynth doc with examples: http://avisynth.org/oldwiki/index.php?page=Crop
    Last edited by sanlyn; 21st Mar 2014 at 07:41.
    Quote Quote  
  20. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Well, the video that I work with is demuxed from audio. And I join the separate segments as such at the end of my script:

    vid1 ++ vid2 ++ vid3
    Quote Quote  
  21. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by sanlyn View Post
    Eh? Don't you mean http://avisynth.org/mediawiki/Splice?

    Originally Posted by unclescoob View Post
    Well, the video that I work with is demuxed from audio.
    Do you mean your script is handling only video and you are trying to sync the audio afterwards?
    That should work as long as the video stays the same length.
    If any of your filters changes the video length (or you have cut bits out), it will go out of sync.
    Quote Quote  
  22. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    Originally Posted by Gavino View Post
    Originally Posted by sanlyn View Post
    Eh? Don't you mean http://avisynth.org/mediawiki/Splice?
    Yep. Ya caught me again, Gavino! Forgot to clear my clipboard. I corrected my post. Thanks.
    Last edited by sanlyn; 21st Mar 2014 at 07:41.
    Quote Quote  
  23. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    If I recall earlier posts, the toon posted earlier had no audio but video was then IVTC'd, apparently without audio. I don't IVTC that way, but wouldn't that throw off audio sync if audio was joined later?
    Last edited by sanlyn; 21st Mar 2014 at 07:41.
    Quote Quote  
  24. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    Wait, so you're not supposed to IVTC without audio? I never had a problem before when it came time to remux my audio and video in the authoring process. This is the first time this happened to me, (after using trim() in my script to apply different filters to different sections of the video). Gavino, no, none of my filters involved clipping the video. Just cleaning. I did not clip my video at all and it looks fine during playback. I'm thinking it was a bad author, so I will re-author it again and see.

    In any event, for you to get Mpeg2Source(), you're supposed to create an index file of your VOB first. In the process of creating this index file, your audio and video are demuxed. Also, considering the fact that HcEnc doesn't do audio, my audio and video would not mux until the authoring process anyway.
    Quote Quote  
  25. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    Originally Posted by unclescoob View Post
    Wait, so you're not supposed to IVTC without audio?
    Since a normal IVTC preserves the video duration, this should not give a problem for the audio.

    In any event, for you to get Mpeg2Source(), you're supposed to create an index file of your VOB first. In the process of creating this index file, your audio and video are demuxed.
    Did you take into account the audio delay reported by DGIndex (and written into the audio file name) when remuxing?
    Quote Quote  
  26. It sounds to me like you cut sections out. Go over your Trim lines very carefully. Even for sections where you don't do any filtering you have to include them or else they'll be cut out and the audio will go out of synch. You can confirm (or disprove) this by checking the length of the video, before any Trims and then again after using all your Trims. Just typing a frame number incorrectly can mess the whole thing up. And also make sure your video matches (pretty closely) the length of the audio.

    And if you're careful the Trims when added all back together will give you the same length video as when you started, but like sanlyn I no longer (usually) filter sections with Trims.
    Quote Quote  
  27. Banned
    Join Date
    Oct 2004
    Location
    New York, US
    Search Comp PM
    I've used Trim(), but not exactly in this way. For every d2v I have its matching uncompressed WAV. In both Avisynth and/or VirtualDub, I rejoin the audio and d2v video as soon possible into AVI and seldom keep them apart -- especially if I expect to cut or otherwise change the video structure. When I don't process them together it can always be fixed, but it's a hassle every time.
    Last edited by sanlyn; 21st Mar 2014 at 07:42.
    Quote Quote  
  28. Yeah, but like unclescoob I don't change the length of the video and almost always keep the audio separate from the video. It's no problem if the video length remains the same throughout.
    Quote Quote  
  29. Banned
    Join Date
    Dec 2010
    Location
    New York
    Search Comp PM
    manono, I'm gonna check for a possible error in my script. I'll get back to you guys. Thanks.
    Quote Quote  



Similar Threads

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