VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. I'm wondering if this can be done at all using a trim on AviSynth. I'm trying but the whole clip gets cropped, rather then the 10 seconds that I want.



    Code:
    Trim(29455,31313)+Trim(32339,33019)+Trim(35042,35196)+Trim(36132,36530).Crop(0,-24,0,24)fadeout(50)

    So I want the last trim to be cropped but instead all them are. Is there a way to prevent that?
    Quote Quote  
  2. The output height and width of an AviSynth script is fixed.

    What exactly is your end goal/target format? Usually people just encode with black bars. That's the most compatible way. Variable encoded heights can be problematic.
    Quote Quote  
  3. Yes, clips that are joined together must have the same frame dimensions.
    Quote Quote  
  4. Okay then. I just wanted to see if it could be done. I guess not.
    Quote Quote  
  5. It can be done if you create two clips from the same video source,
    then crop the second source and resize it to the same width and height as the clip 1.

    Something like this should work
    Code:
    v1=avisource("vid1.avi")
    v2=avisource("vid1.avi")
    v1 = Trim(29455,31313)+Trim(32339,33019)+Trim(35042,35196)
    v2 = Trim(36132,36530).Crop(0,-24,0,24).resize(<remaining width>+48,<keep height>)
    
    v3 = v1+v2
    v3.fadeout(50)
    
    return v3
    Quote Quote  
  6. Originally Posted by cd090580 View Post
    It can be done if you create two clips from the same video source,
    then crop the second source and resize it to the same width and height as the clip 1.

    Something like this should work
    Code:
    v1=avisource("vid1.avi")
    v2=avisource("vid1.avi")
    v1 = Trim(29455,31313)+Trim(32339,33019)+Trim(35042,35196)
    v2 = Trim(36132,36530).Crop(0,-24,0,24).resize(<remaining width>+48,<keep height>)
    
    v3 = v1+v2
    v3.fadeout(50)
    
    return v3
    Your script isn't going to work at all. And if he wanted to resize the cropped segment he could have just added it to his existing script:

    Code:
    Trim(29455,31313)+Trim(32339,33019)+Trim(35042,35196)+Trim(36132,36530).Crop(0,-24,0,24).Spline36Resize(width, height) fadeout(50)
    Of course, the last segment will be distorted.
    Quote Quote  
  7. Here is a function that crops, then resizes to match the size of a 'master' clip so the clips can be spliced together.

    Note, this function does additional cropping - beyond what you ask for - to preserve aspect ratio (see example below).

    Example: need to crop out 16 lines top and bottom, then resize to original size.
    Code:
    CropMatch(Last, Last, 0, 16, 0, -16)
    Image
    [Attachment 43170 - Click to enlarge]

    Image
    [Attachment 43171 - Click to enlarge]

    Code:
    ##################################
    ### crop, then resize to match template clip T;
    ### crop as needed to maintain aspect ratio
    ##
    ## @ C - Source clip. RGB or YUV444 recommended to avoid size modulus restrictions.
    ## @ T - Template clip. Output wil match dimensions of clip <T>.
    ## @ left, top, width, height - cf. [[Crop]]
    ##
    function CropMatch(clip C, clip T,
    \               int left, int top, int width, int height)
    {
        tmpWid = (width>0)  ? (width)  : (C.Width-left+width)
        tmpHgt = (height>0) ? (height) : (C.Height-top+height)
    
        Assert(tmpWid<=C.Width, 
        \   "CropMatch: output width larger than input")
        Assert(tmpHgt<=C.Height, 
        \   "CropMatch: output height larger than input")
    
        scaleX = Float(T.Width)  / tmpWid
        scaleY = Float(T.Height) / tmpHgt
    
        tmpWid2 = (scaleX>=scaleY) ? Float(tmpWid) : (scaleX / scaleY * tmpWid)
        tmpHgt2 = (scaleY>=scaleX) ? Float(tmpHgt) : (scaleY / scaleX * tmpHgt)
    
        x   = (scaleX>=scaleY) ? Float(left)   : (left + 0.5 * (tmpWid - tmpWid2))
        y   = (scaleY>=scaleX) ? Float(top)    : (top  + 0.5 * (tmpHgt - tmpHgt2))
        wid = (scaleX>=scaleY) ? Float(tmpWid) : (tmpWid2)
        hgt = (scaleY>=scaleX) ? Float(tmpHgt) : (tmpHgt2)
    
        return C.Spline64Resize(T.Width, T.Height, x, y, wid, hgt)
    }
    Last edited by raffriff42; 21st Sep 2017 at 21:05. Reason: note
    Quote Quote  



Similar Threads

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