VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. ReplaceFrameX is an Avisynth function for replacing bad frames. It can't look for bad frames itself, only replace those you tell it to. Frames can be replaced with duplicates, blended versions of the surrounding frames, or by interpolating frames using FrameRateConverter or MVTools2. The default is to replace frames with duplicates.

    InsertFrameX is similar to ReplaceFrameX, but new frames are inserted into the video increasing the frame count (ie to add missing frames). There's an additional argument for inserting silent audio to match, although by default any audio is passed through untouched.

    StartBlack, EndBlack, ReplaceBlack, AddBlack & AppendBlack are functions for adding black frames.

    Usage instructions at the top of each script.

    Edit 2023-01-07 Re-uploaded ReplaceFrameX to fix an error when the number of frames to be replaced wasn't specified. The version date remains the same.
    ReplaceFrameX 2022-12-17.avsi
    InsertFrameX 2022-12-17.avsi
    Black (Start, End, Replace, Add, Append) 2022-10-16.avsi

    Some ReplaceFrameX "Blend" and "FRC" examples.

    ReplaceFrameX(56488, Mode="Blend", Position=true) - Replacing frame 56488



    ReplaceFrameX(56488, Mode="FRC", Position=true) - Replacing frame 56488



    ReplaceFrameX(56488, 2, "Blend", Position=true) - Replacing frames 56488 & 56489



    ReplaceFrameX(56488, 2, "FRC", Position=true) - Replacing frames 56488 & 56489



    ReplaceFrameX(56488, 3, "Blend", Position=true) - Replacing frames 56488, 56489 & 56490



    ReplaceFrameX(56488, 3, "FRC", Position=true) - Replacing frames 56488, 56489 & 56490

    Last edited by hello_hello; 6th Jan 2023 at 21:38.
    Quote Quote  
  2. I just realised the handling of the first couple, and possibly last couple of frames is bad (otherwise it's okay). I'll upload a new version dated 2022-10-16 sometime soon(ish).
    Quote Quote  
  3. There's a link for the fixed version dated 2022-10-16 in the opening post.

    To atone for my silliness, I've also added a link for some functions for replacing frames with black ones, or appending black frames to the beginning and/or end of the video.
    Quote Quote  
  4. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Nice!
    Quote Quote  
  5. I've added a link for a function called InsertFrameX to the opening post. It's quite similar to ReplaceFrameX, but instead of replacing existing frames it inserts new ones.

    There's also a link for a new version of ReplaceFrameX dated 2022-12-05. It's functionality hasn't changed but I fixed an error message relating to "out of range" frame numbers.
    Quote Quote  
  6. I had no idea those functions existed so I suppose I've re-invented the wheel. My functions came from helping a forum member via PM and I thought someone else might find them useful.

    I like manono's idea for inserting frames with the ReplaceFramesMC function.
    Loop(2,1325,1325)
    ReplaceFramesMC(1326,1)
    It's not obvious (at least to me) but quite simple.

    If you don't mind I'll add MBlockFPS and MFlowFPS from your ReplaceFramesMC functions as options for ReplaceFrameX too.

    Something like
    ReplaceFrameX(56488, Replace=2, Mode="MBlock")

    I compared MVTools2 with FrameRateConverter again and sometimes the MVTools2 frames look better and sometimes not, depending on picture content and resolution etc. Of course block size etc can change the result for both quite a bit, but it can't hurt to include MVTools2 as an option too.
    Quote Quote  
  7. I also have a version that uses SVPFlow.
    Quote Quote  
  8. I would consider adding RIFE versions options for interpolation, since it has finally made it to avisynth now . The avisynth version uses NCNN - so it can use basically any GPU that supports Vulkan , not just NVidia.

    If you haven't used it yet - RIFE generally produces better results than MVTools2, especially with object occlusions. I posted several comparisons in the past

    I translated the vapoursynth versions that I posted earlier at doom9 to AVS versions here, feel free do modify/add/improve.
    https://forum.videohelp.com/threads/407773-Help-with-8mm-frame-rate-conversion#post2674302

    If you're wondering why there are separate RXr1, RXr2... etc.. in addition to the RXr generic function, it's because RIFE 4.x models are faster and can achieve any non integer multiple, but the quality tends to be lower. So to use <4.x models, a separate downconversion step is required

    I hardcoded it for YUV input, but one way it might be improved is to use isRGB, isY
    Quote Quote  
  9. I've been distracted by the real world lately, so I haven't played with RIFE interpolation yet, but I have added support for Dogway's two flavours of FrameRateConverter, along with new RIFE presets. I've also added MVTools2 modes based on jagabo's scripts. New links in the original post.

    Mode = "Dup", "DupP", "DupN", "Blend", "FRC", "FRCEX", "FRCMIX", "MFlow", "MBlock"
    Means
    Duplicate Previous/Next, Blend, FrameRateConverter, FrameRateConverterEX, FrameRateConverterMIX, MFlowFPS or MBlockFPS (MVTools2).

    Preset = "Slowest", "Slower", "Slow", "Normal", "Fast", "Faster", "Anime", "Rife", "RifeHQ", "RifeAnime".

    There's updated instructions at the top of each script.
    Last edited by hello_hello; 17th Dec 2022 at 04:56.
    Quote Quote  
  10. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Great plugin! MBlock with one frame works effectively, but with two, the effectiveness is usually about 50%. RIFE is missing
    Quote Quote  
  11. Here's a little hack to get RIFE working with my old ReplaceFramesMC:

    Code:
    function ReplaceFramesRIFE(clip Source, int N, int "X")
    {
      # N is number of the 1st frame in Source that needs replacing. 
      # X is total number of frames to replace
      # e.g. RX(101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for interpolation
      #
      # requires YV12, YV16, or YV24 input, outputs same as input
    
      Trim(Source, N-1, 1)+Trim(Source, N+X, 1)
      z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f")
      Rife(gpu_thread=1, model=9, factor_num=X+1, factor_den=1, sc=false) # model 9 needed for custom factor/rate
      Source.IsYV12 ? z_ConvertFormat(pixel_type="YV12", colorspace_op="rgb:709:709:f=>709:709:709:l") : last
      Source.IsYV24 ? z_ConvertFormat(pixel_type="YV24", colorspace_op="rgb:709:709:f=>709:709:709:l") : \
                    z_ConvertFormat(pixel_type="YV16", colorspace_op="rgb:709:709:f=>709:709:709:l") 
      AssumeFPS(Source.FrameRateNumerator, Source.FrameRateDenominator)
      Trim(1,X)
    #Subtitle("RIFE") # optional label to verify replacement
    
      Source.trim(0,N-1) ++ last ++ Source.trim(N+X,0)
    }
    As implemented it only supports 8 bit YV12, YV16, and YV24. You an easily modify it for other color formats/depths.
    Last edited by jagabo; 22nd Jul 2023 at 11:20.
    Quote Quote  
  12. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Thanks, that's the script I was thinking of

    Is there any difference between z_ConvertFormat and traditional convertbits and converttoplanarRGB(with matrix)?

    Can this script be included as an integral part of AviSynth so as not to add to every script?
    Quote Quote  
  13. Originally Posted by rgr View Post
    Is there any difference between z_ConvertFormat and traditional convertbits and converttoplanarRGB(with matrix)?
    Using z_ConvertFormat is a little faster (though it hardly matters given how slow RIFE is) but the end result is the same (aside from any rounding error differences).

    Originally Posted by rgr View Post
    Can this script be included as an integral part of AviSynth so as not to add to every script?
    As with any AviSynth function you can put it in an AVSI file in your plugins folder and it will autoload every time you start AviSynth.
    Last edited by jagabo; 23rd Jul 2023 at 11:43.
    Quote Quote  
  14. You could use "pixel_type=Source.PixelType" , to convert back to source pixel type , that would support higher bitdepths, other pixel types for sources
    Quote Quote  
  15. Thanks pdr. So it becomes the less unwieldy

    Code:
    function ReplaceFramesRIFE(clip Source, int N, int "X")
    {
      # N is number of the 1st frame in Source that needs replacing. 
      # X is total number of frames to replace
      # e.g. RX(101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for interpolation
      #
      # requires YV12, YV16, or YV24 input, outputs same as input
    
      Trim(Source, N-1, 1)+Trim(Source, N+X, 1)
      z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f")
      Rife(gpu_thread=1, model=9, factor_num=X+1, factor_den=1, sc=false) # model 9 needed for custom factor/rate
      z_ConvertFormat(pixel_type=Source.PixelType, colorspace_op="rgb:709:709:f=>709:709:709:l") 
      AssumeFPS(Source.FrameRateNumerator, Source.FrameRateDenominator)
      Trim(1,X)
    #Subtitle("RIFE") # optional label to verify replacement
    
      Source.trim(0,N-1) ++ last ++ Source.trim(N+X,0)
    }
    Last edited by jagabo; 23rd Jul 2023 at 12:00.
    Quote Quote  
  16. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    I don't know how AviSynth works internally, so I have a question.

    If, for example, I have 20 frame swaps in the script, will the YV24->RGB->YV24 conversion occur only for these swapped frames?
    Quote Quote  
  17. Originally Posted by rgr View Post
    I don't know how AviSynth works internally, so I have a question.

    If, for example, I have 20 frame swaps in the script, will the YV24->RGB->YV24 conversion occur only for these swapped frames?
    Yes, because of the Trim() calls in that function . Only the replaced frames are affected. The other frames are copied as unaltered input uncompressed data

    YV24->RGBPS (float)->YV24 such as in that function is a lossless roundtrip transform (I mean if you didn't apply something else like RIFE in the RGBPS step, just referring to the pixel format conversions). A YV12 source would not be, unless the chroma up/down sampling was changed to "point" resampling (nearest neighbor)
    Last edited by poisondeathray; 23rd Jul 2023 at 19:03.
    Quote Quote  
  18. Member
    Join Date
    Aug 2018
    Location
    Wrocław
    Search PM
    Thx.

    Not to spam this thread:

    'ReplaceFramesRIFE & "System exception - Access violation"'

    https://forum.videohelp.com/threads/410735-ReplaceFramesRIFE-System-exception-Access-v...on#post2700891
    Quote Quote  
Visit our sponsor! Try DVDFab and backup Blu-rays!