Log in

View Full Version : Restoring a butchered (PAL 25i(?) to NTSC 29.97i) clip


Boulder
19th April 2020, 14:48
I have a DVD of an older short movie made at our local high school. Someone has screwed up something big time when the final result was created as you can see from this example clip.

https://drive.google.com/open?id=1aCMCJHv_3j91qtl53m9gebrQQJ4ef4CZ

My best guess is that the original was shot using a PAL DV camera, so the resolution was 720x576 and it was truly interlaced. During the process, maybe when the f/x were added, it has been handled as a NTSC clip and so the final result is a mess.

Is there any way of restoring anything or should I just leave it as it is? It's surprising how your brain adjusts to visual anomalies, it doesn't bother you nearly as much once you watch the whole movie for a while :D

Sharc
19th April 2020, 16:51
It has probably been resized without deinterlacing.
I don't think you like this any better even when watching it for a while .... :scared:

TFM().tdecimate()
bilinearresize(720,120).blur(0.0,0.8).bilinearresize(720,480)

johnmeyer
19th April 2020, 16:56
My best guess is that the original was shot using a PAL DV camera, so the resolution was 720x576 and it was truly interlaced. Yes, this is what happens when interlaced video is re-sized without first deinterlacing. I don't know if there are other problems as well, because I only took a casual look.

The general consensus is that this cannot be fixed. However, with the help of StainlessS, I was able to create technology that did a pretty decent job of removing those "big teeth:"

repair bad deinterlacing (https://forum.doom9.org/showthread.php?p=1685187#post1685187)

The code I posted in post #42 in that long thread did a really good job:

Post #42 (https://forum.doom9.org/showpost.php?p=1686309&postcount=42)

However, I never made it into a generalized function. It has to be tuned for the height of the "teeth" because that depends on the ratio of the original video vertical resolution to the scaled resolution. I never took the time to figure out how to replace my hand-tuned code with that function. However, if you understand AVISynth, and if you read what I wrote in my various posts, you should be able to do the tuning yourself.

real.finder
19th April 2020, 17:59
if it was NTSC and resized in this way to PAL then DeBilinearResizeMT will did a good job, but unfortunately, you have the opposite

Boulder
19th April 2020, 18:41
Yes, this is what happens when interlaced video is re-sized without first deinterlacing. I don't know if there are other problems as well, because I only took a casual look.

The general consensus is that this cannot be fixed. However, with the help of StainlessS, I was able to create technology that did a pretty decent job of removing those "big teeth:"

repair bad deinterlacing (https://forum.doom9.org/showthread.php?p=1685187#post1685187)

The code I posted in post #42 in that long thread did a really good job:

Post #42 (https://forum.doom9.org/showpost.php?p=1686309&postcount=42)

However, I never made it into a generalized function. It has to be tuned for the height of the "teeth" because that depends on the ratio of the original video vertical resolution to the scaled resolution. I never took the time to figure out how to replace my hand-tuned code with that function. However, if you understand AVISynth, and if you read what I wrote in my various posts, you should be able to do the tuning yourself.
I'm probably doing something a bit wrong here.. trying to mangle things from old Avisynth to -plus is not my cup of tea when anything more complex like GScript is involved.

https://thumbs2.imagebam.com/b2/3e/7c/adf4e71340979465.jpg (http://www.imagebam.com/image/adf4e71340979465)

StainlessS
20th April 2020, 02:18
Boulder, can you post exact script that you are using, I'm gonna give it a try.

Green stuff looks like possible MvTools or avs+ bug.

Also, which Avs+ and Mvtools versions.

Maybe one of them dont quite like YUY2 (which I assume is colorspace as s_Exlogo only works with that [I think, maybe also RGB32 not sure]).

Boulder
20th April 2020, 05:23
Boulder, can you post exact script that you are using, I'm gonna give it a try.

Green stuff looks like possible MvTools or avs+ bug.

Also, which Avs+ and Mvtools versions.

Maybe one of them dont quite like YUY2 (which I assume is colorspace as s_Exlogo only works with that [I think, maybe also RGB32 not sure]).

You were right, the green thing was because of MVTools. I updated to the latest version and it's gone now. Anyway, here's the script so you can see that I've done it right:

Import("c:\program files (x86)\avisynth+\plugins64\s_exlogo.avs")
source=DGSource("f:\temp\captures\butchered.dgi").ConverttoYUY2(interlaced=true)
source=TFM(source)
source=TDecimate(source)

global scenethreshold=4
clp=source
RowStart= 1
RowStep = 18
RowStart= (RowStart % RowStep)
TOP_ROW_FIRST=False

Function Select_Op(clip clp,int current_frame) { # Detect first frame after scene change
clp
nd= RT_YDifference(Last,n=current_frame - 1, delta= 1) # We detect relative to previous frame, ie for 1st frame after SC
pd=Max(RT_YDifference(Last,n=current_frame - 1, delta=-1), 0.00001)
Sc = (nd / pd > scenethreshold) ? 0 : 1
SC # 0=scene change 1st frame : 1=not scene change
}

BotRow = clp.Crop(0,(RowStart>0)?RowStart:RowStep,-0,RowStep)
for(y=((RowStart>0)?RowStart:RowStep)+RowStep*2,clp.Height-RowStart,RowStep*2) {
botRow = BotRow.StackVertical(clp.Crop(0,y,-0,Min(clp.Height-y,RowStep)))
}

if(TOP_ROW_FIRST) {
Offset_BotRow = BotRow.DuplicateFrame(BotRow.FrameCount-1).DeleteFrame(0)
} Else {
Offset_BotRow = BotRow.DeleteFrame(BotRow.FrameCount-1).DuplicateFrame(0)
}

super_BotRow=MSuper(Offset_BotRow,pel=2)
vfe_BotRow=manalyse(super_BotRow,truemotion=true,isb=false,delta=1,blksize=8,overlap=4,search=6)
vbe_BotRow=manalyse(super_BotRow,truemotion=true,isb=true,delta=1,blksize=8,overlap=4,search=6)
est_BotRow=mflowinter(Offset_BotRow,super_BotRow,vbe_BotRow,vfe_BotRow,time=50,blend=false,mL=100)

newClip = clp
for(y=0,est_BotRow.Height-RowStep,RowStep) {
newClip=newClip.Overlay(est_BotRow.Crop(0,y,-0,Min(est_BotRow.Height-y,RowStep)),x=0,y=((RowStart>0)?RowStart:RowStep)+y*2)
}

################

EXL_AMOUNT = 256 # Strength of S_Exlogo mixing, greater more opaque delogo (256 max)

Exl_2=newClip
for(y=RowStart,Exl_2.height-2,RowStep) {
Exl_2 = Exl_2.S_Exlogo(0,y,-0,2,BlurMode=5,amount=EXL_AMOUNT)
}

Fixed_1 = Exl_2

# *** WE SWITCH ON SCENE CHANGE OF THE NEW CLIP, NOT SOURCE, SOURCE CLIP CAN SC SWITCH AT BAD FRAME ***
# *** See eg 3331(Bad) and 3958(Good)
Result_1 = Fixed_1.ConditionalSelect ("Last.Select_Op(current_frame)" ,source, Fixed_1, show=true)

stackhorizontal(source,Result_1)

return Last

Now I just have to start testing and try finding out if there is a way to repair any damage at all :p