I'm using ReplaceFramesMC to fix a few frames with scratches and black streaks, but I can't figure out how to script it for more than 2 instances at a time. If I have 2 lines of ReplaceFramesMC(), it fixes both, but if I have 3 of them, it only fixes 2. I haven't tried more than 3. But in my video, I have about 20 or so frames out of the 2 hour timeline, and I don't really want to export after 2 fixes, then reopen for the next 2, then the next 2, and so on.
Here's my script:
How do I go about configuring it for more than 2 at a time?Code:video=AVISource("F:\Tape 1\Tape 1.avi") ReplaceFramesMC(video, 163465, 1) ReplaceFramesMC(video, 163479, 1) ReplaceFramesMC(video, 176731, 1) function ReplaceFramesMC(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 mflowfps interpolation start=Source.trim(N-1,-1) #one good frame before, used for interpolation reference point end=Source.trim(N+X,-1) #one good frame after, used for interpolation reference point start+end AssumeFPS(1) #temporarily FPS=1 to use mflowfps super = MSuper() backward_vec = MAnalyse(super, isb = true) forward_vec = MAnalyse(super, isb = false) MFlowFps(super, backward_vec, forward_vec, blend=false, num=X+1, den=1) #num=X+1 AssumeFPS(FrameRate(Source)) #return back to normal source framerate for joining Trim(1, framecount-1) #trim ends, leaving replacement frames Source.trim(0,-N) ++ last ++ Source.trim(N+X+1,0) }
Thanks.
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 19 of 19
Thread
-
-
Oh well, I was hoping someone had a suggestion, but I guess not. I guess I could just create a bunch of scripts, one for each section to be fixed, then add to a master script that add them all, splicing their outputs into the timeline, exporting it all in one run.
-
The instructions are right there in the source. ReplaceFramesMC(123, 3) will replace 3 consecutive frames, 123, 124, and 125, with motion interpolated between frames 122 and 126. Note that the longer the string of frames you replace the greater the chance of artifacts.
-
If you're referring to separate instances of frame ranges, call the video , and use implied "last" to keep all the changes. Otherwise only the last line is processed. The first two instances of ReplaceFramesMC are not used in your script, the changes are not cumulative because you have video=something
Code:video=AVISource("F:\Tape 1\Tape 1.avi") video ReplaceFramesMC(163465, 1) ReplaceFramesMC(163479, 1) ReplaceFramesMC(176731, 1) . . .
Code:AVISource("F:\Tape 1\Tape 1.avi") ReplaceFramesMC(163465, 1) ReplaceFramesMC(163479, 1) ReplaceFramesMC(176731, 1) . . .
-
-
Thanks. I "thought" it had processed 1 and 2 when specifying 2 instances, then 1 and 3 when specifying 3 instances, but I guess I was trippin'. I had already tried the 2nd suggestion without 'video' added, and it errored out saying invalid argument to ReplaceFrameMC. That was actually the first way I wrote it, until seeing that 'video' was in the brackets along with the frame number. But, your first suggestion works like a charm...
Code:video=AVISource("F:\Tape 1\Tape 1.avi") video ReplaceFramesMC(163465, 1) ReplaceFramesMC(163479, 1) ReplaceFramesMC(176731, 1)
-
Sorry, I guess I misread the post. I see poisondeathray gave the code for that. I've replaced many dozens of individual frames within a video that way. You can have the function default to replacing a single frame if the X argument isn't supplied: just set the default X value to 1 at the start of the function.
Code:video=AVISource("F:\Tape 1\Tape 1.avi") ReplaceFramesMC(video, 163465, 1) ReplaceFramesMC(video, 163479, 1) ReplaceFramesMC(video, 176731, 1) function ReplaceFramesMC(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 mflowfps interpolation X = Default(X, 1) start=Source.trim(N-1,-1) #one good frame before, used for interpolation reference point end=Source.trim(N+X,-1) #one good frame after, used for interpolation reference point start+end AssumeFPS(1) #temporarily FPS=1 to use mflowfps super = MSuper() backward_vec = MAnalyse(super, isb = true) forward_vec = MAnalyse(super, isb = false) MFlowFps(super, backward_vec, forward_vec, blend=false, num=X+1, den=1) #num=X+1 AssumeFPS(FrameRate(Source)) #return back to normal source framerate for joining Trim(1, framecount-1) #trim ends, leaving replacement frames Source.trim(0,-N) ++ last ++ Source.trim(N+X+1,0)
Code:ReplaceFramesMC(123)
-
Wow... now that's cool. I can write batch file in Windows, and shell scripts in linux, but my knowledge is limited and self-taught. That little bit of info you gave will definitely make things so much easier.
It's definitely only for a single frame at a time though... multiple frames create too many artifacts. But in a situation where a scratch crosses 3 frames, I found that unfolding the fields side-by-side revealed that the scratch starts in the top field in the first frame, then ends in the bottom field in the 3rd frame, but in both fields in the middle frame. So using johnmeyer's "Replace Bad Field With Motion Estimated Field from Good Field.avs", I run it 2 times... once for odd fields, then once for even fields, then splice out the first and 3rd frames with the newly created good frames, leaving me with the single frame to be replaced. That's now handled by ReplaceFramesMC. Done deal. -
-
Yes, RIFE is usually better. Here's a simple function that creates a clip where every frame is interpolated from the two frames around it. Then ReplaceFramesSimple() is used to replace frames within the original video with frames taken from the interpolated video.
Code:######################################################## # # Replace every frame with a frame motion interpolated # from the frame before and after it. No original # frames left. # ######################################################## function InterpolateAllRIFE(clip c) { c.z_ConvertFormat(pixel_type="RGBPS", colorspace_op="709:709:709:l=>rgb:709:709:f") e = SelectEven().RIFE(gpu_thread=1, model=4).SelectOdd() o = SelectOdd().RIFE(gpu_thread=1, model=4).SelectOdd() Interleave(e,o) Loop(2,0,0) z_ConvertFormat(pixel_type=c.pixeltype, colorspace_op="rgb:709:709:f=>709:709:709:l") } ######################################################## LWLibavVideoSource("video.ext") interp = InterpolateAllRIFE() ReplaceFramesSimple(interp, Mappings="500 505 509 515") # list of frames to be replaced with interpolated frames
Note this works only for single bad frames. If there are more than one in a sequence the interpolated frames will include some of the junk from the bad frames.Last edited by jagabo; 23rd Aug 2024 at 18:15.
-
-
Thank you jagabo, I'll play with this tomorrow. Although ReplaceFramesMC does what I want, I'll give this a try as well.
Working on a tape last night, making 5 captures to run through Median. But while lining the clips up, 1 of the captures had a duplicate that was actually an inserted extra frame. I didn't know at the time it was extra, so proceeded to run RemoveFramesMC on it. The clip didn't didn't line up properly. Upon closer inspection, I realized it was an extra frame. Instead of 86, 87, 88, it was 86, 87, 87, 88. So after interpolating the frame, it became 86, 87, 87.5, 88. It took me close to an hour to figure out it was an extra frame. Doh! -
Do you have this installed? http://avisynth.nl/index.php/Avsresize
2.6 and + cannot be installed at the same time unless you have one in 32 bit, the other in 64 bit. Although someone wrote a utility that allows you to easily switch between the two.
I'm not sure if RIFE requires +. It does require you download a bunch of models and put them in a folder called "models" in the plugins folder. -
Thanks jagabo. I didn't have it, but I do now. It's still complaining about no z_ConvertFormat. I even installed the VisualC++ package. The requirements listed on the RIFE page only says AviSynth+, so I guess regular AviSynth isn't going to work. I guess I'll look into an x64 install, then use VirtualDub2 to run it. Now that I have AviSynth regular all set up with the filters I need, I don't want to mess with it.
Code:Requirements Vulkan compatible device [x64]: AviSynth+ r3682 or greater (AviSynth+ 3.7.3 (test 6, r3935 can be downloaded from here) Microsoft VisualC++ Redistributable Package 2022 (can be downloaded from here) Supported color formats: RGBPS models must be located in the same folder as RIFE.
-
I didn't realize you don't have AviSynth+. And 64 bit is highly recommended. 32 bit AviSynth and 64 bit AviSynth+ can both be installed on the same Windows64 system. I highly recommend you use 64 bit AviSynth+. All the new development is happening there. Of course, you'll have to find 64 bit versions of all the 32 bit dll files you're using now.
-
Here's aversion of InterpolateAll() that uses InterFrame (another frame rate doubler):
https://www.spirton.com/uploads/InterFrame/InterFrame2.html
Code:# replace every frame with a motion interpolated frame (between the frame before and the frame after) function InterpolateAll(clip c) { e = SelectEven(c).InterFrame(FrameDouble=true, cores=4).SelectOdd() o = SelectOdd(c).InterFrame(FrameDouble=true, cores=4).SelectOdd() Interleave(e,o) Loop(2,0,0) }
-
Similar Threads
-
Why the subtitles aren't going away instantly?
By cns00 in forum SubtitleReplies: 2Last Post: 11th Mar 2024, 09:14 -
Aren't Subtitles Based on Time?
By Spiffy577 in forum Newbie / General discussionsReplies: 1Last Post: 5th Oct 2023, 10:06 -
Apparently on-board OTA tuners aren't all created equally
By brassplyer in forum DVB / IPTVReplies: 7Last Post: 3rd Jan 2022, 18:59 -
RF Modulator For DVD on TV with only coax in - any that aren't pure crap?
By MisterF in forum Newbie / General discussionsReplies: 6Last Post: 25th Dec 2021, 15:55 -
YouTube is remastering old music vids. Aren't they?
By eobardthawne in forum RestorationReplies: 5Last Post: 16th Oct 2021, 07:22