Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th June 2017, 15:46   #21  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,340
Quote:
Originally Posted by StainlessS View Post

EDIT: I trust that below format will work with whatever the RX script is
Code:
10  14
210 215
Sorry I should have posted the details. The OP couldn't post for some reason early on and we had a discussion in PM

It's just an mvtools2 interpolation function, to interpolate over bad frames. It allows for runs of more than single frames, but the problem is it requires manual identification of frame ranges. If you could ID them "automatically" with some degree of accuracy it might be a good option. It's certainly "cleaner" than QTGMC in this case, and fixes the aliasing . But we all know that's only because this example scene was "simple" - mvtools2 interpolation can make a big mess of things on more complex scenes/motion

Here is the PM

Quote:
Quote:
Originally Posted by poisondeathray
In this zip file there are 2 versions, one done with avisynth "rx.mp4", and another with motion tracking guided replace "tracking.mp4" . No other filtering, just replacing
https://www.mediafire.com/?c53a9afmpticcl5


"rx" is a function I wrote a long time ago (with big help from gavino) for replacing frames using adjacent "good" frames . You write the frame number, and the number of frames to replace. For example (10,2) would replace frames 10,11 using frames 9 and 12 as guidance

If you look critically at the 2 examples, you will notice the avisynth version has a bit of slight "wobbling" or "warping" in the repaired frames . You might be able to fix by playing with blocksize or other mvtools2 settings.

The motion tracked repair is more "stable" , but motion tracked repairs are only suitable for some types of scenes. If there was other types of motion, more foreground object movement etc... you might have to resort to other types of approaches.

Global filtering (e.g. QTMGC) on all frames is a last resort IMO, because you damage all the frames. But on the other hand , it's "easier" and faster. Or another approach is you could replace select frames with QTMGC (or other filtered) . e.g. using clipclop or replaceframes functions

Code:
MPEG2Source("VTS_02_1.demuxed.d2v", cpu=0)
rx(175,3)
rx(187,1)
rx(196,1)
rx(198,3)
rx(203,1)
rx(206,4)
rx(211,2)
rx(215,1)
rx(218,1)
rx(221,1)
rx(223,1)


function RX(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)
}
poisondeathray is offline   Reply With Quote
Old 15th June 2017, 00:22   #22  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thanx PDR, unfortunately, dont think that I'm in any fit state to do anything, at the mo.
Will come back again in the morn.

EDIT: Ive had a post from user about not being able to post, perhaps a site problem. (originally thought that I was blocking him).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 15th June 2017 at 00:26.
StainlessS is offline   Reply With Quote
Old 15th June 2017, 05:46   #23  |  Link
kriNon
Registered User
 
Join Date: Jul 2016
Posts: 39
Hey, thought that I should post an update.

So far I've managed to run the script on the first four episodes, and it has been quite successful in finding any errors. From what I have seen the script does tend to find a lot of false positives, but it is also quite sensitive to actual errors, finding some errors so small that I couldn't even notice straight away. The script especially finds a lot of false positives when the video is either panning, shaking or fading between two clips as a transition. What I have been doing is running the script and then checking each frame output manually for errors, which has sped up this process significantly.

What I have noticed is that there are three main different types of error that are detected.
The first type being where in some frames, most visible near lines, it seems like two frames have been overlaid but with a very slight offset, resulting in double lines running parallel. This is most often not very noticeable by eye.
The second type typically occurs during motion, and is where to some limited extent, the frame has elements of the frame before/after it overlaid upon it with.
The third type is the type that is shown in the sample I posted, which results in aliasing.

It seems that each type of error would require some slightly different filtering, some individual frames might even need to be modified in an image editing program.

For now I am going to prioritise checking each episode for errors using the script, and then rechecking the list of errors manually.

I will probably end up using a mixture of QTGMC, RX, Image editing software, and possibly After Effects if I can figure out how to achieve results like what poisondeathray did.
kriNon is offline   Reply With Quote
Old 15th June 2017, 06:15   #24  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,340
Quote:
Originally Posted by kriNon View Post
What I have noticed is that there are three main different types of error that are detected.
The first type being where in some frames, most visible near lines, it seems like two frames have been overlaid but with a very slight offset, resulting in double lines running parallel. This is most often not very noticeable by eye.
The second type typically occurs during motion, and is where to some limited extent, the frame has elements of the frame before/after it overlaid upon it with.
The third type is the type that is shown in the sample I posted, which results in aliasing.
Do you want to post examples of the other types ? It's not entirely clear to me but it almost sounds like you're referring to field blending ? There might be other approaches you could try

(I guess I should have mentioned this too)
In our PM's , I mentioned the NTSC version probably being better, but the OP apparently has examined all versions including broadcasted versions and apparently they all have even worse issues...

But I want to emphasize when you are combining techniques (including some manual work), you want to have access to all material that you can. It can save lots of time when you are compositing repairs. A botched part of frame on the PAL version might be able to be masked out with a NTSC version and so forth.
poisondeathray is offline   Reply With Quote
Old 17th June 2017, 16:42   #25  |  Link
kriNon
Registered User
 
Join Date: Jul 2016
Posts: 39
So it turns out that I had made a mistake, and when I was looking through the list of errors I had been checking the frame numbers against the QTGMC'd track, instead of the source. Without having checked extensively, it looks like the first and second types of artifacting were caused by QTGMC and don't exist in the source. I will be rechecking errors using the proper source, and I'll post again either if I run into a problem, or when I have finished checking for errors. This might take a while.

Also, all of the issues that exist in the PAL version also exist in the NTSC version, however the NTSC version has further issues. Using the NTSC version for compositing repairs isn't an option.
kriNon is offline   Reply With Quote
Old 21st June 2017, 14:54   #26  |  Link
kriNon
Registered User
 
Join Date: Jul 2016
Posts: 39
Alright, so I ran the script correctly this time, and after getting a list of frame numbers I then checked them manually, which resulted in me finding many damaged frames. However in the time that I was checking for errors, I found an example of an entire scene which was not detected by the script, nor was even really that close to being detected. From that I've realized that I'm going to need to find a better method of checking for errors.
Here's the scene where it wasn't detected: https://mega.nz/#!fQ8jRTKL!PR9dEmjEC...PJg5hIasyQv2UI

Nonetheless I do suspect that we found the majority of the damaged frames. I have been looking into better detection methods, however I haven't been able to find anything that is able to detect the above scene. From what I have seen I believe that the damage occurs only in the luma component of the video.
kriNon is offline   Reply With Quote
Old 22nd June 2017, 15:47   #27  |  Link
kriNon
Registered User
 
Join Date: Jul 2016
Posts: 39
So I have spent some time trying to find another better method of detection and I believe I have found one, although I do still need to figure out some of the logic. What I found is that the previous method used relied heavily on Motion Analysis to work, which meant that in some scenarios where there is little to no motion, errors will not be detected.

After doing some testing using a variety of different detection methods, I have found one that I believe will work well. What I found is that it is possible to detect the bad frames using this script:

Code:
video1=MPEG2Source("I:\[NHK]\Welcome to the NHK [DVDISO-PAL]\Disk1\episode1.d2v", cpu=0)
track2=binarize(CombMask(video1)).greyscale().invert()

ConditionalFilter(video1, video1, video1, "AverageLuma(track2)", ">", "0", show=true)
return(last)
Whenever there is an error, the AverageLuma of track2 will fall significantly, relative to the surrounding frames.

As shown in this graph here:http://i.imgur.com/5K71kII.png

It is not possible to check if the AverageLuma of track2 is below a threshold because it changes significantly throughout the episode.
I am in the process of trying to figure out a way of separating these values which do not fit the trend of the graph.
I will also need to use some kind of scene detection to run this test on a per scene basis, because the graph I posted is discontinuous at each scene change.

EDIT:
I have found a way of detecting the outliers in the data using matlab which I will post here:
Code:
%mydata is the array of AverageLuma values
x=1:length(myData);
TF=smooth(x,myData,0.1,'rloess');

Test=(TF-myData)./TF;
for i=1:length(myData)
    if Test(i)<0
        Test(i)=-1;
    elseif Test(i)
    end
end

alpha=0.15;
for i=1:length(myData)
    if Test(i)>alpha
        disp(i);
        disp(Test(i));
    end
end
From here all I would need to do is implement scene detection.

I am thinking maybe it would be best to detect scene changes, output each frame number to a text document with its corresponding scene number and AverageLuma value, and then do all of the logic in matlab.

I'll post my results tomorrow, hopefully this works!

Last edited by kriNon; 22nd June 2017 at 17:49. Reason: Clarification
kriNon is offline   Reply With Quote
Reply

Tags
deinterlace, ivtc, qtgmc

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:22.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.