Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An idea for a useful new feature #8

Open
radpopl opened this issue Nov 16, 2024 · 6 comments
Open

An idea for a useful new feature #8

radpopl opened this issue Nov 16, 2024 · 6 comments

Comments

@radpopl
Copy link

radpopl commented Nov 16, 2024

Many people as I see on the videohelp.com forum use RIFE to remove corrupted frames or entire sequences of frames.

I have a suggestion/idea to add such a function:

RIFE_ReplaceFrames(src, from_frame, number_of_frames, model (optionally)

where:
src = video
from_frame = from which frame to insert interpolated frames
number_of_frames = number of frames to replace

and/or

RIFE_ReplaceFrames(src, file="frames.txt")

where in the file there would be frame numbers to replace:
100,1 (1 frame with number 100)
101,2 (frames 101 and 102)
200,5 (frames from 200 to 204)
#300,5 (comment, ignore this line)
[...]

I have such a script in AviSynth, but it only works for about 10-15 frames in the script. Above that, a large increase in memory usage causes AviSynth error.

function ReplaceFrameRIFE(clip Source, int N, int X, int "model")
{
  # N is number of the frame in Source that needs replacing. 
  # X is total number of frames to replace
  # e.g. (101, 5) would replace 101,102,103,104,105 , by using 100 and 106 as reference points for interpolation
  
  model = default(model, 41)

  Trim(Source, N-1, length=1)+Trim(Source, N+X, length=1)
  Rife(gpu_thread=1, model=model, factor_num=X+1, factor_den=1, sc=false)
  AssumeFPS(Source.FrameRateNumerator, Source.FrameRateDenominator)
  Trim(1,X)
#Subtitle("RIFE", align=5) "" # optional label to verify replacement
  Source.trim(0,end=N-1) ++ last ++ Source.trim(N+X,0)
}
@Asd-g
Copy link
Owner

Asd-g commented Dec 17, 2024

Isn't this the same thing what you want?

@radpopl
Copy link
Author

radpopl commented Dec 17, 2024

RIFE mode seems to be very limited. Max 3 frames, no model selection.

@Asd-g
Copy link
Owner

Asd-g commented Dec 21, 2024

The required feature is out of the scope of this plugin.
Also if it would be added it would be not different than script version.

I attached a modified version of your script. It takes array for X and N. It has also added arg frames_file.
Usage example:

  • with arrays - ReplaceFrameRIFE([10044, 49050], [3, 4])
  • with file -ReplaceFrameRIFE(frames_file="file_containing N and X")
    file format:
    10044 3
    49050 4
    

ReplaceFrameRIFE.avsi.txt

@radpopl
Copy link
Author

radpopl commented Feb 17, 2025

Thanks, but unfortunately this does not solve the main problem I get with a large number of swaps.

I thought that placing such operations in the RIFE.dll library would eliminate this problem and it would be possible to freely swap a large number of frames.

Image

Edit:


    for (i = 0, file_lines - 1)
    {
      line_text = RT_ReadTxtFromFile(frames_file, lines=1, start=i)
      if (LeftStr(line_text, 1) >= "0" && LeftStr(line_text, 1) <= "9")
      {
		  N = Int(Value(LeftStr(line_text, FindStr(line_text, " "))))
		  X = Int(Value(RightStr(line_text, StrLen(line_text) - FindStr(line_text, " "))))
		  
		  Trim(output, N-1, length=1)+Trim(output, N+X, length=1)
		  Rife(gpu_thread=1, model=model, factor_num=X+1, factor_den=1, sc=false)
		  AssumeFPS(output.FrameRateNumerator, output.FrameRateDenominator)
		  Trim(1,X)
		  output = output.trim(0,end=N-1) ++ last ++ output.trim(N+X,0)
      }
    }

I changed some code because my AVS (latest) doesn't recognize the "continue" command

@Asd-g
Copy link
Owner

Asd-g commented Feb 19, 2025

Did you try RemapFrames or FrameSel+FrameRep?

@radpopl
Copy link
Author

radpopl commented Feb 20, 2025

RemapFrames doesn't seem to work properly when inside a function. It takes frames from "last" instead of sourceClip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants