Log in

View Full Version : Random Blends In Otherwise Standard Telecine Source


simple_simon
6th December 2020, 08:22
Is there a good way to remove odd blends in an otherwise standard telecined source. I have a series of videos that, somehow after being ivtc'd back to 23.976, have random blends. I tried using tfm() with a clip2 input that had been bobbed with qtmc().srestore(frate=23.976) but it doesn't seem to do anything. Maybe using clip2 in tfm doesn't do what I thought it was supposed to do but I expected it to take a clean frame from the bobbed clip when it encountered interlacing.

I could bob it with qtmc and use srestore directly on the whole thing of course but it seems unnecessary to degrade all the progressive frames just to get rid of a few blended ones. It seems there should be a way of detecting blended frames and replacing them with a clean frame from before or after the blend. My source is animation and there is a clean frame before and after with a blend of the two in between. (Again, not sure how that would happen. If it was a bad pal to ntsc conversion or something like that there should be blends throughout.)

I thought srestore was supposed to be able to do exactly what I'm needing by detecting blends and replacing them with a clean frame (and it does improve it) but it seems to let a lot of blends through that should be removed. And I've also noticed that it's replacing perfectly good frames with dups when it's unnecessary. Never noticed this behavior before and wondering if maybe it's a bug introduced in the latest updates, v2.796.

So, is there a way to detect blends, bob the blend and replace blend with clean frame without manually reviewing every clip and removing each blend one at a time?

real.finder
6th December 2020, 12:14
post untouched video sample

simple_simon
6th December 2020, 21:58
http://www.mediafire.com/file/agr8z5ri7haovqi/sample.mkv/file

real.finder
6th December 2020, 22:22
your source is filtered with Temporal Denoiser so it make srestore work harder

anyway


source()
sanimebob
srestore(frate=23.976,speed=-4,thresh=5,cache=5)

seems better for me (there are some that can't be removed since both fields has field blend)

simple_simon
7th December 2020, 00:14
It's an untouched sample off the dvd, just in a mkv container. How can you tell if it's been temporally denoised?

And I'm trying not to bob the whole thing since it's mostly progressive. (Not familiar with sanimebob and couldn't pull up any info about it.)

real.finder
7th December 2020, 11:48
It's an untouched sample off the dvd, just in a mkv container. How can you tell if it's been temporally denoised?

And I'm trying not to bob the whole thing since it's mostly progressive. (Not familiar with sanimebob and couldn't pull up any info about it.)

I know it's from dvd, I can tell it has been temporally denoised because it has ghosting, maybe the ghosting is there because something else but it's the problem

sanimebob is now part in AnimeIVTC 2.X https://forum.doom9.org/showthread.php?t=170364 , it's made to be anime friendly (but it can be used in others, some people used back then in non anime/cartoon)

qtgmc is bad for anime and can made ghosting (your source already has ghosting and it make it worst)

sanimebob has options to use qtgmc (called useqtgmc it's 0 by default) but with settings that not that bad for anime

also you can use smam() which use qtgmc too (and it's not that bad for anime too) see here https://forum.doom9.org/showthread.php?p=1750019

simple_simon
8th December 2020, 06:11
Ok. It's been awhile since I've used AnimeIVTC. i thought it was possible to achieve the same results with QTGMC & srestore, but I'll have to check that out. Thanks

But still, the goal is to autodetect, bob & replace the few blends without bobbing the whole progressive clip. Is there no way to do that?

real.finder
8th December 2020, 15:26
sanimebob originaly has nothing to do with AnimeIVTC, later I move it to AnimeIVTC since it's about anime, no more no less

anyway you mean "tfm() with a clip2"? I don't think it will help in this case, but you can try, you must feed it with 29.97 not 23.976

simple_simon
10th December 2020, 07:47
My whole question and first post was about trying to bob only the blended frames without bobbing the whole clip. But anyway...

Using your script from post #4, frame 86 & 88 are blends that are being left behind. But they shouldn't be because before and after those blends are the clean frames that frame 86 & 88 are blended from. That's one of the things I don't understand about srestore.
Why is it leaving those blends when it could easily remove them by replacing them with the frame before or after?

Ceppo
21st December 2020, 23:27
I'm having seeking issues with dgdecnv, try posting a demuxed section without muxing to mkv. Yes I saw the blend and since is 50/50 maybe something can be done.

simple_simon
30th December 2020, 13:07
Just use FFVideoSource or LWLibavVideoSource to index. I'm not seeing any seeking issues with those. Just can't multithread when using srestore (or if you do don't seek backwards by too many frames). But I can post another version, what container would you prefer for the file?

manono
3rd January 2021, 00:44
But I can post another version, what container would you prefer for the file?
From DVD sources, M2Vs should be provided. You can cut it using DGIndex. Use the [ and ] buttons to isolate a section of a VOB and then File->Save Project File and Demux Video. DGIndex is used to index DVD VOB files so MPEG2Source can be used to open them.

simple_simon
6th January 2021, 10:14
OK. Here's the m2v file. I think I managed to keep the same sample as the mkv but it's possible the frames I referenced having issues with won't be exactly the same in the new file.

https://www.mediafire.com/file/7w03ht4tveb3527/VTS_01_1.demuxed.m2v/file

Ceppo
6th January 2021, 12:33
1) I'm using avisynth+ and the script will work only on avisynth+.
2) This won't work on a bobbed clip.
3) There is consecutive blend sometimes and nothing can be done about it.
4) Due to the blend some frame doesn't have a field match, so you have to choose which of the 2 fields to keep and if you keep one you fix the blend somewhere and you get the blend somewhere else, I couldn't find a workaround it so you might consider to bob it to remove more blend, but the script won't work, you need another script to do it.
5) You have to remove the subtitle calls.


TFM()#any field matching here
src = last
aud = false
denoise = src.dfttest(tbsize=1)
blend = Merge(denoise.duplicateframe(0),denoise.trim(1,0))
denblend = Interleave(denoise,blend)

Scriptclip("""
a1 = CFrameDiff(denoise,blockx=4,blocky=4,chroma=true,denoise=true,ssd=true)
a2 = CFrameDiff(denoise,blockx=4,blocky=4,chroma=true,denoise=true,ssd=true,prevf=false)
b = CFrameDiff(denblend.trim(current_frame*2-current_frame,0),blockx=4,blocky=4,chroma=true,denoise=true,ssd=true,prevf=false)
if( a1 < 10 || a2 < 10 ) {
aud=false
src.subtitle("current-dup")
} else if( (b < 10) && (aud==false) ) {
aud = true
src.duplicateframe(0).subtitle("prev")
} else {
aud = false
src.subtitle("current")
}
""")

hello_hello
6th January 2021, 14:09
Normally when video is converted from one frame rate to another using field-blending, only one field from a given frame has blending, so you can bob de-interlace to convert fields into frames, then SRestore can pick out the frames without blending. Normally there's a pattern to the blending. The top fileds contain blending for a few frames then the bottom fileds and so on, and I assume SRestore expects that kind of pattern. And sometimes it takes a couple of "cycles" to lock into the blending pattern anyway. Plus SRestore would normally be used on interlaced sources, not telecined.

The trouble with your sample is, the problem section has both fields in a frame blended at the same time (after field matching), and occasionally that happens for successive frames. I don't know how it ended up that way.

I'm not sure why I finished this, but once I started....
Hopefully the audio sync will be okay, considering it's not an even 1 in 5 pattern, but I removed 25 frames.
25 x 5 = 125
So starting at frame 75, the section where I manually removed frames has to end at frame 199.
199 - 25 = 174 for the end Trim frame after frame removal.
I think that's right.

Of course if the blending is a regular occurrence, removing frames manually wouldn't be fun.

VTS_01_1.mkv (https://www.file-upload.net/en/download-14422862/VTS_01_1.mkv.html)

TFM(metric=1).ShowFrameNumber(x=width()*0.45, y=height()*0.5)
A = last
B = DeleteFrame(78,79,82,84,92,105,106,108,110,114,119,123,128,132,141,145,150,154,163,168,172,181,186,188,191)
A.Trim(0,74).TDecimate()+\
B.Trim(75,174).AssumeFPS(24000,1001)+\
A.Trim(200,0).TDecimate()

Ceppo
6th January 2021, 18:28
This will work with the bobbed clip and takes into account consecutive blend into fields.


QTGMC()

src = last
den = src.dfttest(tbsize=1)
blend1 = Interleave(den,Merge(den.DuplicateFrame(0) ,den.Trim(1,0)))#prev
blend2 = Interleave(den,Merge(den.DuplicateFrame(0) ,den.Trim(2,0)))#prev
blend3 = Interleave(den,Merge(den.DuplicateFrame(0,0),den.Trim(1,0)))#next

Scriptclip("""
a1 = CFrameDiff(den,blockx=4,blocky=4,chroma=true,denoise=true,ssd=true)
a2 = CFrameDiff(den,blockx=4,blocky=4,chroma=true,denoise=true,ssd=true,prevf=false)
b1 = CFrameDiff(blend1.trim(current_frame,0),blockx=4,blocky=4,chroma=true,denoise=true,ssd=true,prevf=false)
b2 = CFrameDiff(blend2.trim(current_frame,0),blockx=4,blocky=4,chroma=true,denoise=true,ssd=true,prevf=false)
b3 = CFrameDiff(blend3.trim(current_frame,0),blockx=4,blocky=4,chroma=true,denoise=true,ssd=true,prevf=false)
if( a1 > 10 && a2 > 10 && b1 < 10) {
src.Duplicateframe(0).subtitle("blend1-prev")
} else if( a1 > 10 && b2 < 10 ) {
src.Duplicateframe(0).subtitle("blend2-prev")
} else if( a2 > 10 && b3 < 10 ) {
src.Trim(1,0).subtitle("blend3-next")
} else {
src.subtitle("current")
}
""")