View Full Version : Duplicate Frames in original DVD interlaced
kle500
20th September 2006, 17:31
Hello there.
I have a strange problem that i see for the first time.
I have a DVD NTSC (30i) interlaced (adult content), that i am trying to convert to PAL.
Although, i am using a straight procedure on all these Originals (all of them are same 30i), i found that this one has a strange problem.
I will try to describe the problem.
The movie is 2hours 40min, and the first thing i saw is that this original, in a specific point (after chapter 12), has been encoded with the wrong field order.
So i demuxed the video in 2 parts (chapt 1-12) & (chapt 13-35), and by using the Restream, i changed succesfully the field order of the 2nd part.
So far i solved the problem, but as i was watching the original again, i saw another strange thing.
By loading the .avs simple (without any conversion or filters), in virtualDub, i saw that there are 5 correct fields, but the 6th is the same as the 5th.
As a ressult, the video is jerky, because fields 5&6 are the same, they act like Pause.
Note that from start to end, the duplicate frames are in same order (5 & 6 same).
Need some help people.
What can i do to fix this?
Realy appreciate any help.
Kind regards
George
Guest
20th September 2006, 17:40
Your post says duplicated fields in one place and duplicated frames in another!
If it is duplicated fields, then bob it to 60fps, decimate the dups, and then reinterlace. Something like this:
Bob # or use a better bobber
Decimate(6)
separatefields()
selectevery(4,0,3)
weave()
If it is duplicated frames, then just:
Decimate (6)
or
selectevery(6,0,1,2,3,4) # get the phase correct
kle500
20th September 2006, 17:55
Your post says duplicated fields in one place and duplicated frames in another!
If it is duplicated fields, then bob it to 60fps, decimate the dups, and then reinterlace. Something like this:
Bob # or use a better bobber
Decimate(6)
separatefields()
selectevery(4,0,3)
weave()
If it is duplicated frames, then just:
Decimate (6)
Sorry for that mistake.
It's frames, as the video is Handycam shooting (adult material).
After a test, with Multidecimate, i found out that the second duplicate frame, was actually needed, cause now, after removal, i see jump in motion.
The motion is not smooth, (hmmm it is), but only up to frame 5.
Now the frame 6 is more far than the 5th.
I am not sure if i explain correctly.
For example: When a hand is moving,
frames 1,2,3,4,5 are OK, but frame 6 is farther.
So how can i create a frame No5 that will create the missing frame?
Notice that this is going to be Converted to PAL later on.
Regards
Edit: @Neuron
I will try that and i will come back
Edit2: It is exactly the same as using the Multidecimate (i didn't know the Decimate function).
P.S. I can post a sample if you want
Guest
20th September 2006, 19:54
P.S. I can post a sample if you want Yes. Be sure it is unprocessed! And try to pick a tame section (not a heavy XXX section) to abide by forum rules. Preferred is the clip before Restream is applied, i.e., a fragment of the original capture.
kle500
20th September 2006, 21:00
It is just a part of the original video.
I have only loaded the d2v file and encoded a part.
Remember that the final will be on PAL DVD, so it will get a conversion.
I am waiting for your reply
Regards
Here is the link
http://www.sendspace.com/file/wge8tt
Guest
20th September 2006, 22:23
I asked for a tame section. I can't have that on my work PC! You'll have to wait now.
Guest
20th September 2006, 23:37
The frames are indeed dups. When you remove them you are missing the real frames so it's jerky. You can try something like MotionPerfect to try to recreate them but I wouldn't get my hopes up (especially since it is interlaced).
kle500
21st September 2006, 00:01
The frames are indeed dups. When you remove them you are missing the real frames so it's jerky. You can try something like MotionPerfect to try to recreate them but I wouldn't get my hopes up (especially since it is interlaced).
Thank's.
I think i will procced with
Decimate (6) and then my script to PAL.
One question:
How the studio made that mistake?
Cause i can't beleive that they did this deliberately.
Regards!
LogicDeLuxe
21st September 2006, 08:27
selectevery won't help, since the pattern actually is quite irregular, it seems.
Sometimes it's: 1,2,3,4,5,5, sometimes 1,1,2,3,4,5 sometimes 1,2,2,3,4,5 and on so on. On a few occasions there are also 6 different frames in a row before the duplicate.
decimate(6) will eliminate the duplicates, but will sometimes fail on occurance of 6 different frames, of course.
The real problem is detecting where the missing frames go. Unless you really find a regular pattern in that video, I doubt you'll ever get rid of the jerkiness.
I noticed, the aspect ratio is something strange either. In VirtualDubMod it appears distorted with 4:3 and with 16:9. They probably used a somewhat exotic camera and did a really bad conversion to NTSC video.
Write your complains to the manufacturer.
kle500
21st September 2006, 09:26
selectevery won't help, since the pattern actually is quite irregular, it seems.
Sometimes it's: 1,2,3,4,5,5, sometimes 1,1,2,3,4,5 sometimes 1,2,2,3,4,5 and on so on. On a few occasions there are also 6 different frames in a row before the duplicate.
decimate(6) will eliminate the duplicates, but will sometimes fail on occurance of 6 different frames, of course.
The real problem is detecting where the missing frames go. Unless you really find a regular pattern in that video, I doubt you'll ever get rid of the jerkiness.
I noticed, the aspect ratio is something strange either. In VirtualDubMod it appears distorted with 4:3 and with 16:9. They probably used a somewhat exotic camera and did a really bad conversion to NTSC video.
Write your complains to the manufacturer.
I didn't noticed the irregular pattern, but i did noticed something else.
The pattern goes like this: 1,2,3,4,5,5 all the time, but i notice that frames 3,4 look like they are farther than normal, producing another jump.
So if i remove frame 5, i will eventually have 2 jumps on motion.
1,2, 3&4 5&1 ............. or not.
Hmmm...........
As for the aspect ratio, don't worry, (the orginal is 16:9), but i was accidently encoded as 4:3.
I will put another file (this time directly cut from the vob), for better analysis.
EDIT: The link for the new unedited file
http://www.sendspace.com/file/ph6zv2
LogicDeLuxe
21st September 2006, 10:42
The pattern goes like this: 1,2,3,4,5,5 all the time, but i notice that frames 3,4 look like they are farther than normal, producing another jump.It is not always 3,4 which are more far apart, sometimes it's 1,2 sometimes 4,5 and so on. That's what I meant to say before, asuming there is a frame 6 which is always missing.
kle500
21st September 2006, 10:54
It is not always 3,4 which are more far apart, sometimes it's 1,2 sometimes 4,5 and so on. That's what I meant to say before, asuming there is a frame 6 which is always missing.
Did you noticed that in the first sample?
If yes, please download the new file and let me know.
Cause accidenlty, the first file has been encoded in wrong way.
Test and tell me
Regards
LogicDeLuxe
21st September 2006, 11:15
In your second example, at the beginning, the missing frame seems to be between 2 and 3 and later between 3 and 4.
There are no 6 different frames in a row this time.
kle500
21st September 2006, 11:29
In your second example, at the beginning, the missing frame seems to be between 2 and 3 and later between 3 and 4.
There are no 6 different frames in a row this time.
In VirtualDub, frames 3&4 are the same, but 6&7 has jump (notice the stick).
Later 9&10 are the same, but 12&13 has jump (it look that between 12-13 there should be a frame for smooth movement).
15-16 (same)
18-19 (jump)
21-22 (same)
24-25 (jump)
27-28 (same)
30-31 (jump)
33-34 (same)
36-37 (jump)
39-40 (same)
42-43 (jump)
45-46 (same)
48-49 (jump)
..........
and so on.
so i assume that pattern goes ever 6th frame.
Is there anything i can do ?
Regards
Guest
21st September 2006, 12:40
Cause accidenlty, the first file has been encoded in wrong way.
Why can't you give us a fragment of the original UNPROCESSED capture??? It's possible that your problems are coming from your processing.
kle500
21st September 2006, 12:44
Why can't you give us a fragment of the original UNPROCESSED capture??? It's possible that your problems are coming from your processing.
The second sample that i posted above, (i mentioned above), is unprocesed.
It is dirrectly a CUT from the original.
Please take a look.
Here it is: (Uprocessed)
http://www.sendspace.com/file/ph6zv2
Regards
kle500
22nd September 2006, 08:57
Did anyone gave a try on this second (uprocessed) clip?
Also, if i use Decimate(6), it will remove one frame, right?
The 6th i think.
But can i add a new frame (some sort of motion blur from the previous and next)in between the jerky frames, so finaly i will end up with the same amout of frames, and have a "smooth" movement?
Is there any possiblity that i can do something to this video?
Or that's all there is?
Thank's again everyone for any help.
Regards
Guest
22nd September 2006, 13:42
Did anyone gave a try on this second (uprocessed) clip? Same result. There are missing content frames.
Also, if i use Decimate(6), it will remove one frame, right? The 6th i think. Please read the documentation.
But can i add a new frame (some sort of motion blur from the previous and next)in between the jerky frames, so finaly i will end up with the same amout of frames, and have a "smooth" movement? Yes. Decimate(cycle=6,mode=1,threshold=0) will do that. Please see the documentation. It is thoroughly described. Usually this is used on progressive video. Let me know how it looks on interlaced content. :) You could deinterlace first and then apply this.
leakkerneldeint(order=0,threshold=7) # get the order right for your clip!
decimate(cycle=6,mode=1,threshold=0)
It will appear a bit smoother, but of course you still have missing temporal content (in addition to what you lost by deinterlacing). The brain will try to make it up.
Is there any possiblity that i can do something to this video? Or that's all there is?Don't get hung up on any one woman. It's bad for your psyche. :)
kle500
22nd September 2006, 14:34
Same result. There are missing content frames.
Please read the documentation.
Yes. Decimate(cycle=6,mode=1,threshold=0) will do that. Please see the documentation. It is thoroughly described. Usually this is used on progressive video. Let me know how it looks on interlaced content. :) You could deinterlace first and then apply this.
leakkerneldeint(order=0,threshold=7) # get the order right for your clip!
decimate(cycle=6,mode=1,threshold=0)
It will appear a bit smoother, but of course you still have missing temporal content (in addition to what you lost by deinterlacing). The brain will try to make it up.
Don't get hung up on any one woman. It's bad for your psyche. :)
Thank's for that.
I will try and report back.
Also i noticed that, whatever thresh value i use in Leakkerneldeint, i get horizontal black lines during fades (intro of the video, or scene changes), so i gave up on any deinterlacer, and got back to my old method of:
SmoothDeinterlace(doublerate=true,tff=true,lacethresh=1,staticthresh=10,showlace=false)
This way, i never have problem with ghost's or lines.
Once again i must say that my contents are intelaced and shot on camera.
Regards
George
Guest
22nd September 2006, 15:02
Also i noticed that, whatever thresh value i use in Leakkerneldeint, i get horizontal black lines during fades (intro of the video, or scene changes), so i gave up on any deinterlacer That shouldn't happen. Can you post a clip that shows this problem so that I can see what is going on? You should never give up on something before investigating it fully. That should include speaking to the developer about it. :)
You may have the wrong field order set.
kle500
22nd September 2006, 15:19
That shouldn't happen. Can you post a clip that shows this problem so that I can see what is going on? You should never give up on something before investigating it fully. That should include speaking to the developer about it. :)
You may have the wrong field order set.
It happens, trust me! But i don't know why.
In the past i was investigating this with "xesdeeni" via e-mails, and the only solution was to use a blur vallue after deinterlacing.
So after modifying the smoothdeint, i get it correct.
I was doing tests last week on another XXX video, on using Leakkerneldeint, and allthough there was no visible lines on PCmonitor, on TV there was a total mess (especially durring the credits and fades). Oh... by using threshold=2, if i try something like 7 as you say, the lines are obvious on PCmonitor too.
I will try to upload test grabs from within virtualdub.
Guest
22nd September 2006, 15:56
It's not a matter of trust. If you want me to investigate it, I need an original unprocessed source clip and a description of how to duplicate the issue. It's up to you. If you prefer to conclude that the tool is broken and can't be fixed (without even consulting the developer), fine, I have other stuff to do.
And BTW, smoothdeint(doublerate=true) is a bobber (splits fields into frames), so obviously it is going to totally eliminate combing. For a fair comparison, try LeakKernelBob().
kle500
22nd September 2006, 16:40
By all means, i didn't meant to offend you.
(My mistake) I was using, LeakKernelBob(order=1,threshold=2), and i had terrible lines during fades, white sparkles on Black background.
I did try Leakkernerdeint(order=1,threshold=7), and i also see the black lines during fades, on TV.
This is the script i am using for conversion to PAL:
ConvertToYUY2(interlaced=true)
SmoothDeinterlace(doublerate=true,tff=true,lacethresh=1,staticthresh=10,showlace=false)
LanczosResize(720,576)
ConvertFPS(50)
SeparateFields()
SelectEvery(4,0,3)
Weave()
But i prepared 3 folders containing 3 frames (before-midle-after) of the fade.
There are 3 different conversions to PAL.
1) with Leakkernerdeint
2) with Smoothdeint
3) with Mvbob
On TV, the Leakkernedeint conversion shows the black lines.
Instead of Threshold=7 i tryied 2 or 5, but the results where the same.
Note: All the above will be targeted for TV viewing.
Thank's alot
http://www.sendspace.com/file/rl0nz8
Guest
22nd September 2006, 17:03
Maybe I should put this in BOLD as you seem to be ignoring it:
I need an original unprocessed source clip and a description of how to duplicate the issue.
Frame grabs of your processing results are not useful. Just give me the raw clip of the fade!
Also, on your grabs I see combing on all three sets. What are you trying to show with them?
And you keep saying you are using LeakKernelDeint. Please take some trouble to be precise. If you don't care, why should I?
kle500
22nd September 2006, 17:49
I need an original unprocessed source clip and a description of how to duplicate the issue.
Ok, i will do my best to put a sample.
Also, on your grabs I see combing on all three sets. What are you trying to show with them?
Maybe i am so noobie to explain, but on TV (interlaced), the Leakkerneldeint, shows big horizontal black lines during the fade.
And you keep saying you are using LeakKernelDeint. Please take some trouble to be precise. If you don't care, why should I?
I didn't understand what you mean by that.
But anyway, when i find a litle spare time, i will send you more (unprocessed) samples to give you examples.
P.S. Forgive me, but i am not so technical experienced in avisynth and in the differences between deinterlacers.
Regards!
Guest
22nd September 2006, 18:27
Maybe i am so noobie to explain, but on TV (interlaced), the Leakkerneldeint, shows big horizontal black lines during the fade. There you go again with the LeakKernelDeint. I told you you have to use LeakKernelBob!
I didn't understand what you mean by that. See above.
But anyway, when i find a litle spare time, i will send you more (unprocessed) samples to give you examples. Maybe I'll have some spare time when you get around to it. :)
Tell ya what, stick with SmoothDeinterlacer, as you don't seem very motivated about this. Thanks for the trouble report.
kle500
22nd September 2006, 18:44
There you go again with the LeakKernelDeint. I told you you have to use LeakKernelBob!
See above.
Maybe I'll have some spare time when you get around to it. :)
Tell ya what, stick with SmoothDeinterlacer, as you don't seem very motivated about this. Thanks for the trouble report.
I will send you some sample, and i will tell you what script i use.
Right now, i am unable to upload anything (upload problem from my isp), but Yes, i was using Lekakernerbob lately (that's where i saw the problem).
I think i've gone offtopic (talking about deinterlacers) in this particular topic.
Thank's for your patience!
Regards
scharfis_brain
22nd September 2006, 20:27
I looked on your sample.
It has the following characteristics:
it is/was pure NTSC interlaced video.
in a cycle of 6 frames (NOT fields!) the following was applied:
- drop one frame each cycle. (missing two fields!, causes the jump)
- to compensate this one frame each cycle was duplicated (cause the forward-backward-forward jump)
to recover this, you need to:
- drop the dupes of each cycle
- reinterpolate the two missing fields each cycle
this script automatically deletes the dupes, but needs you to find out the framenumbers to interpolate the missing two fields.
loadplugin("c:\x\DGDecode.dll")
loadplugin("c:\x\Decomb.dll")
loadplugin("c:\x\masktools.dll")
import("c:\x\motionprotectedfps.avs")
Function insert2(Clip Input, Int Frame)
{
Inter = Input.MotionProtectedFPS(Input.FrameRate() * 3.0, Iterate = 4).deleteframe(0).deleteframe(0).deleteframe(0) #.duplicateframe(0)
Inter1 = Inter.SelectEvery(3, 1).Trim(Frame - 1, -1).assumefps(framerate(Input))
Inter2 = Inter.SelectEvery(3, 2).Trim(Frame - 1, -1).assumefps(framerate(Input))
Start = Input.Trim(0, Frame).assumefps(framerate(Input))
End = Input.Trim(Frame + 1, 0).assumefps(framerate(Input))
Start ++ Inter1 ++ Inter2 ++ End
}
in=mpeg2source("C:\forum\kle500\test.d2v") #,cpu=6)
in
decimate(6) #drop every dupe
assumebff()
bob(0,0.5) # bob deinterlace
# now smooth out every jump over the missing fields by inserting two fields (= one frame)
insert2( 1)
insert2( 13)
insert2( 25)
insert2( 37)
insert2( 49)
insert2( 61)
insert2( 73)
insert2( 85)
insert2( 97)
insert2(109)
insert2(121)
insert2(133)
insert2(145)
insert2(157)
insert2(169)
insert2(181)
insert2(195) #pattern break!
insert2(207)
insert2(219)
insert2(231)
insert2(243)
insert2(255)
# reinterlace
assumebff().separatefields().selectevery(4,0,3).weave()
#restore original framerate
assumefps(in.framerate())
the script returns full fluid NTSC.
kle500
22nd September 2006, 21:13
Damn...That was very very cool.
It works like charm, but i must ask a couple of questions (as a not skilled avisynther).
First, i noticed a color change between the original and the final.
I had to insert:
ConvertToYUY2(interlaced=true) after the wave(), to get back the original color.
Second:
but needs you to find out the framenumbers to interpolate the missing two fields
How can i do that? (again forgive my ignorance). Can i automatically generate something like this:
insert2( 1)
insert2( 13)
insert2( 25)
insert2( 37)
insert2( 49)
insert2( 61)
insert2( 73)
insert2( 85)
insert2( 97)
insert2(109)
insert2(121)
.........utill 40492
I have divided the whole video in 2 parts.
1st part has 40492 frames (according to virtualdub), and i assume that the frames are all in a cycle of 6.
Third:
Can i continue the script afterwards, for standards conversion?
Or i must fisrt encode it as NTSC (recovered) and the convert it in PAL?
Realy appreciate your help people.
Regards
Didée
22nd September 2006, 21:55
That can be automated, too. One has to make a mask clip as:
- find dups by compairing full interlaced frames to predecessors
- if dup: frame=white, else: frame=black
then
- bob the source
- framedouble the created mask clip
- MaskedMerke the interpolation onto the source, by the mask clip
After that, separate and re-weave, and ah, there is the fully automated restored NTSC interlaced clip.
I've once tried a similar procedure on a similar problem - clip was 23.976 fps, decimated from 29.97 fps.
The harder part, compaired to this here, was that no dups were available for detection. (Solution was a routine that detected the "motion jumps" themselves.)
The easier part was that only one frame per cycle had to be restored ... whereas here, two fields per cycle are needed. This is more like to produce noticeable artefacts from motion interpolation.
The question is, how much effort and processing time are justifiable to invest into this problem? After all, a conversion to PAL is pending, too. It would be ridiculous to make a laborious, time-consuming restoration of the missing fields, only to follow it with a poor sledgehammer-conversion from NTSC to PAL ...
kle500
22nd September 2006, 22:22
That can be automated, too. One has to make a mask clip as:
- find dups by compairing full interlaced frames to predecessors
- if dup: frame=white, else: frame=black
then
- bob the source
- framedouble the created mask clip
- MaskedMerke the interpolation onto the source, by the mask clip
After that, separate and re-weave, and ah, there is the fully automated restored NTSC interlaced clip.
I've once tried a similar procedure on a similar problem - clip was 23.976 fps, decimated from 29.97 fps.
The harder part, compaired to this here, was that no dups were available for detection. (Solution was a routine that detected the "motion jumps" themselves.)
The easier part was that only one frame per cycle had to be restored ... whereas here, two fields per cycle are needed. This is more like to produce noticeable artefacts from motion interpolation.
The question is, how much effort and processing time are justifiable to invest into this problem? After all, a conversion to PAL is pending, too. It would be ridiculous to make a laborious, time-consuming restoration of the missing fields, only to follow it with a poor sledgehammer-conversion from NTSC to PAL ...
Thank you very much, but i tottaly lost you (technical avisynth).
I am unable on doing this myself.
So, Is it possible , that you can give me an example or the script that i can use?
I know is a little too much, but....
As for the conversion, i did that:
After the(smooth out of the missing fields) of the above (excellent script of scharfis_brain) (Thank's a lot), offcource removing the:
#restore original framerate
assumefps(in.framerate())
I placed:
#Framerate conversion
Lanczos4Resize(720,576).motionprotectedfps(50)
ConvertToYUY2(interlaced=true)
# reinterlace
assumebff().separatefields().selectevery(4,0,3).weave()
Am i in the correct road here?
As for the deinterlacing part, i assume there not much i can do here, cause i see that Bob(0,0.5) is beeing used.
So if i am on the right side, the only thing missing, is the automated part. Otherwise, i must write it down by hand.
Again thank's guys for all your help.
I really appreciate
Regards
scharfis_brain
22nd September 2006, 22:42
#restore original framerate
assumefps(in.framerate()) IS NEDED!
if you want to produce PAL, you need to use a script like this:
in=mpeg2source("C:\forum\kle500\test.d2v") #,cpu=6)
in
decimate(6) #drop every dupe
assumebff()
securedeint()
# now smooth out every jump over the missing fields by inserting two fields (= one frame)
insert2( 1)
insert2( 13)
.
.
.
assumefps(in.framerate()*2)
motionpretectedfps(50, iterate=4)
bicubicresize(width, 576)
converttoyuy2()
assumetff()
separatefields().selectevery(4,0,3).weave()
you should place all insert() commands needed, before you add the standard conversion stuff.
kle500
22nd September 2006, 23:11
Just a couple of questions:
#restore original framerate
assumefps(in.framerate()) IS NEDED!
I only need to produce PAL, so, shall i remove the above? (i assume that in my case, is not needed).
securedeint()
Do i have to stick with it? Cause allthough i have mvbob loaded (mvbob() works), i get error: There is no function named "securedeint"
bicubicresize(width, 576)
does this work better than: LanczosResize(720,576) ?
Regards
Didée
22nd September 2006, 23:26
Step by step ... here's the masking part:
o = last
ox = o.width()
oy = o.height()
dup = mt_lutxy(o,o.selectevery(1,-1),"255 x y - abs 16 * -",U=-128,V=-128).lanczos4resize(64,64)
dupD = mt_lutf(dup,dup,mode="average",yexpr="x",U=2,V=2)
dupD5 = dupD.selectevery(1,-5)
dupD4 = dupD.selectevery(1,-4)
dupD3 = dupD.selectevery(1,-3)
dupD2 = dupD.selectevery(1,-2)
dupD1 = dupD.selectevery(1,-1)
dupDmax = dupD.mt_logic(dupD1,"max").mt_logic(dupD2,"max").mt_logic(dupD3,"max")
\ .mt_logic(dupD4,"max").mt_logic(dupD5,"max")
themask = mt_lutxy(dupD,dupDmax,"x y - abs 2 < 255 0 ?").greyscale.pointresize(ox,oy)
stackhorizontal(o,themask)
Can't say if I can finish the rest now ... my wife will return home, soon ... :D
However, that insertion stuff really SHOULD be automated. Seeing the source is, how long was it? 2.5 hours? That would require about (roughly) 43 THOUSANDS of insert2() calls!! Not only it would take ages to produce all of'em manually ... it's not even sure that the script would execute correctly.
kle500
22nd September 2006, 23:48
The original source file has 136 frames (according to virtualdub),
but everything i try, either has less frames, or more.
For example:
The scharfis_brain script for PURE NTSC, has 135 frames.
This following produces 112 frames
# reinterlace
assumebff().separatefields().selectevery(4,0,3).weave()
#restore original framerate
assumefps(in.framerate())
mvbob()
motionprotectedfps(50)
LanczosResize(720,576)
ConvertToYUY2(interlaced=true)
SeparateFields()
SelectEvery(4,0,3)
Weave()
This (according to the above example for PAL) gives 69 frames.
assumefps(in.framerate()*2)
motionprotectedfps(50, iterate=4)
bicubicresize(width, 576)
converttoyuy2()
separatefields().selectevery(4,0,3).weave()
if i remove the (*2), i get 139 frames.
assumefps(in.framerate())
all these differences comes from a 4 sec clip.
What's it gonna be in a 2:40 hours video? (suppose will do the automation).
Where is the mistake?
Regards
kle500
22nd September 2006, 23:53
Step by step ... here's the masking part:
o = last
dup = mt_lutxy(o,o.selectevery(1,-1),"255 x y - abs 16 * -",U=-128,V=-128).lanczos4resize(64,64)
dupD = mt_lutf(dup,dup,mode="average",yexpr="x",U=2,V=2)
dupD5 = dupD.selectevery(1,-5)
dupD4 = dupD.selectevery(1,-4)
dupD3 = dupD.selectevery(1,-3)
dupD2 = dupD.selectevery(1,-2)
dupD1 = dupD.selectevery(1,-1)
dupDmax = dupD.mt_logic(dupD1,"max").mt_logic(dupD2,"max").mt_logic(dupD3,"max")
\ .mt_logic(dupD4,"max").mt_logic(dupD5,"max")
themask = mt_lutxy(dupD,dupDmax,"x y - abs 2 < 255 0 ?").greyscale.pointresize(ox,oy)
stackhorizontal(o,themask)
Can't say if I can finish the rest now ... my wife will return home, soon ... :D
However, that insertion stuff really SHOULD be automated. Seeing the source is, how long was it? 2.5 hours? That would require about (roughly) 43 THOUSANDS of insert2() calls!! Not only it would take ages to produce all of'em manually ... it's not even sure that the script would execute correctly.
LOL, forgive me, but how can i use the above?
Or better, can i use it as it is, or it needs some more to get done?
LOL i am realy been lost here in all those avisynth programming.
Thank you very much for your effort Didée:)
and offcource all the people who are trying to help me, work this out.
Regards
Didée
23rd September 2006, 00:20
OK, wife returned, fiddling is over now. ;)
The following is a functional framework for the basic problem of automatically replacing all duplicates with motion interpolations. Result is 59.94 fps, so conversion to PAL still has to be done.
For evaluation, the used routine for motion interpolation is very basic! (Have a look at this thread (http://forum.doom9.org/showthread.php?t=113256&highlight=alchemist) to get an idea about how much effort can be put into motion interpolation, to get slightly better results.)
The script requires MaskTools v2 (mt_masktools.dll) and the latest version of MVTools.dll.
o = last
ox = o.width()
oy = o.height()
dup = mt_lutxy(o,o.selectevery(1,-1),"255 x y - abs 16 * -",U=-128,V=-128).lanczos4resize(64,64)
dupD = mt_lutf(dup,dup,mode="average",yexpr="x",U=2,V=2)
dupD5 = dupD.selectevery(1,-5)
dupD4 = dupD.selectevery(1,-4)
dupD3 = dupD.selectevery(1,-3)
dupD2 = dupD.selectevery(1,-2)
dupD1 = dupD.selectevery(1,-1)
dupDmax = dupD.mt_logic(dupD1,"max").mt_logic(dupD2,"max").mt_logic(dupD3,"max")
\ .mt_logic(dupD4,"max").mt_logic(dupD5,"max")
themask = mt_lutxy(dupD,dupDmax,"x y - abs 2 < 255 0 ?").greyscale.pointresize(ox,oy)
bobbed = o.bob(0,0.5) #.showframenumber()
themask2 = interleave(themask,themask)
evn = bobbed.selecteven()
odd = bobbed.selectodd()
bw_vec_evn = evn.MVAnalyse(isb = true, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=1)
fw_vec_evn = evn.MVAnalyse(isb = false, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=1)
bw_vec_odd = odd.MVAnalyse(isb = true, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=2)
fw_vec_odd = odd.MVAnalyse(isb = false, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=2)
evn_comp = evn.MVFlowFps(bw_vec_evn, fw_vec_evn, num=2997, den=50, ml=100, idx=1).selectodd()
odd_comp = odd.MVFlowFps(bw_vec_evn, fw_vec_evn, num=2997, den=50, ml=100, idx=2).selectodd()
comp = interleave(evn_comp,odd_comp)
mt_merge(bobbed,comp,themask2,luma=true,Y=3,U=3,V=3)
(If anyone notices that the references for motion search are slightly suboptimal ... sure, I know. It's tricky, because of the two-fields-situation, and decimate() is not-at-all an option for an *automated* *replacing* routine. The selecteven/odd method however was easy to do.) :)
BTW,
your sample ... has the following characteristics:
it is/was pure NTSC interlaced video.
in a cycle of 6 frames (NOT fields!) the following was applied:
- drop one frame each cycle. (missing two fields!, causes the jump)
- to compensate this one frame each cycle was duplicated (cause the forward-backward-forward jump)
is not quite complete. Apart from the duplicates, there still is the problem with jumping motion between the duplicates. So something additional must have been involved in the destruction process, but I've no idea what that might have been ...
kle500
23rd September 2006, 00:23
[QUOTE=Didée;878867]Step by step ... here's the masking part:
o = last
dup = mt_lutxy(o,o.selectevery(1,-1),"255 x y - abs 16 * -",U=-128,V=-128).lanczos4resize(64,64)
dupD = mt_lutf(dup,dup,mode="average",yexpr="x",U=2,V=2)
dupD5 = dupD.selectevery(1,-5)
dupD4 = dupD.selectevery(1,-4)
dupD3 = dupD.selectevery(1,-3)
dupD2 = dupD.selectevery(1,-2)
dupD1 = dupD.selectevery(1,-1)
dupDmax = dupD.mt_logic(dupD1,"max").mt_logic(dupD2,"max").mt_logic(dupD3,"max")
\ .mt_logic(dupD4,"max").mt_logic(dupD5,"max")
themask = mt_lutxy(dupD,dupDmax,"x y - abs 2 < 255 0 ?").greyscale.pointresize(ox,oy)
stackhorizontal(o,themask)
It gives me: I don't know what ox means.
Problem is in my script?
Regards
foxyshadis
23rd September 2006, 00:30
In Didée's stuff, ox=o.width() and oy=o.height().
If you don't have securedeint, you're using a very outdated version of mvbob.
Didée
23rd September 2006, 00:31
Ooops, sorry.
below "o = last", place "ox = o.width() oy = o.height()".
(Above scripts were corrected.)
kle500
23rd September 2006, 00:56
In Didée's stuff, ox=o.width() and oy=o.height().
If you don't have securedeint, you're using a very outdated version of mvbob.
The folder of Mvbob has 12 files and the "mvbob.avs" is dated as 14/9/06
Ooops, sorry.
below "o = last", place "ox = o.width() oy = o.height()".
(Above scripts were corrected.)
lol, i will again look like a noobie lol
The complete script will be like this?
import("C:\Program Files\AviSynth 2.5\plugins\mvbob\mvbob.avs")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\Decomb521.dll")
loadplugin("C:\Program Files\AviSynth 2.5\plugins\masktools.dll")
import("C:\Program Files\AviSynth 2.5\plugins\motionprotectedfps.avs")
Function insert2(Clip Input, Int Frame)
{
Inter = Input.MotionProtectedFPS(Input.FrameRate() * 3.0, Iterate = 4).deleteframe(0).deleteframe(0).deleteframe(0) #.duplicateframe(0)
Inter1 = Inter.SelectEvery(3, 1).Trim(Frame - 1, -1).assumefps(framerate(Input))
Inter2 = Inter.SelectEvery(3, 2).Trim(Frame - 1, -1).assumefps(framerate(Input))
Start = Input.Trim(0, Frame).assumefps(framerate(Input))
End = Input.Trim(Frame + 1, 0).assumefps(framerate(Input))
Start ++ Inter1 ++ Inter2 ++ End
}
in=mpeg2source("5.d2v") #,cpu=6)
in
decimate(6) #drop every dupe
assumebff()
bob(0,0.5) # bob deinterlace
# now smooth out every jump over the missing fields by inserting two fields (= one frame)
o = last
ox = o.width()
oy = o.height()
dup = mt_lutxy(o,o.selectevery(1,-1),"255 x y - abs 16 * -",U=-128,V=-128).lanczos4resize(64,64)
dupD = mt_lutf(dup,dup,mode="average",yexpr="x",U=2,V=2)
dupD5 = dupD.selectevery(1,-5)
dupD4 = dupD.selectevery(1,-4)
dupD3 = dupD.selectevery(1,-3)
dupD2 = dupD.selectevery(1,-2)
dupD1 = dupD.selectevery(1,-1)
dupDmax = dupD.mt_logic(dupD1,"max").mt_logic(dupD2,"max").mt_logic(dupD3,"max")
\ .mt_logic(dupD4,"max").mt_logic(dupD5,"max")
themask = mt_lutxy(dupD,dupDmax,"x y - abs 2 < 255 0 ?").greyscale.pointresize(ox,oy)
bobbed = o.bob(0,0.5) #.showframenumber()
themask2 = interleave(themask,themask)
evn = bobbed.selecteven()
odd = bobbed.selectodd()
bw_vec_evn = evn.MVAnalyse(isb = true, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=1)
fw_vec_evn = evn.MVAnalyse(isb = false, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=1)
bw_vec_odd = odd.MVAnalyse(isb = true, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=2)
fw_vec_odd = odd.MVAnalyse(isb = false, truemotion=true, pel=2, sharp=2,blksize=16,overlap=8,idx=2)
evn_comp = evn.MVFlowFps(bw_vec_evn, fw_vec_evn, num=2997, den=50, ml=100, idx=1).selectodd()
odd_comp = odd.MVFlowFps(bw_vec_evn, fw_vec_evn, num=2997, den=50, ml=100, idx=2).selectodd()
comp = interleave(evn_comp,odd_comp)
mt_merge(bobbed,comp,themask2,luma=true,Y=3,U=3,V=3)
# reinterlace
assumebff().separatefields().selectevery(4,0,3).weave()
#restore original framerate
assumefps(in.framerate())
The above gives me 226 frames, and a total mess on movement.
Can you please try it on the sample you have?
I work on the same sample.
Whenever possible, post back your working script, as i am in total chaos at the moment. LOL
Didée
23rd September 2006, 01:05
No. The last script I posted is the complete script, except for loading the source. You can't just mix together scharfi's script and mine.
Take my last script, insert
mpeg2source("5.d2v")
assumebff()
on the very top, that's all.
kle500
23rd September 2006, 01:18
No. The last script I posted is the complete script, except for loading the source. You can't just mix together scharfi's script and mine.
Take my last script, insert
mpeg2source("5.d2v")
assumebff()
on the very top, that's all.
Now, i get a point.
Sorry for that.
Unfortunatelly, movement is not smooth.
It seems like there is no smoothness in between the jumply frames. I can't explain better.
So result looks allmost like simple Decimate(6)
Didée
23rd September 2006, 01:30
Ah, I was thinking short, and scharfis' analysis was complete.
Actually, the locations of the missing frames and of the inserted duplicates are independant. My script replaces the duplicates with interpolations, which is not adequate. Instead, it would require the jump-detector I once fiddled together ... and that one had a problem: the plain detection did work as intended, but the script also required a smart decimation in the process. Unfortunately, all decimators I tried somehow choked during the progress, after some hundred frames. (And I did NOT even use AS' conditional environment.) Made me pull my hair ... and in the end, luckily I managed to find out the two different patterns that were lying on top of each other, so I could finish with a rather simple SelectEvery/SelectRangeEvery combination...
Can't tell if in this case any regular patterns can be found. For that, the samples are much too short.
edit:
BTW, Decimate(6) isn't fully working out here, no? The real dup pattern is six-point-something, slighly longer than just 6 ... therefore decimate(6) should remove also some non-duplicates, every so often?
kle500
23rd September 2006, 01:47
Can't tell if in this case any regular patterns can be found. For that, the samples are much too short.
Damn.... i can put longer sample, but can't post the url here, cause of the content (adult).
I will send you by PM.
BTW, i can trim the video in as many semgents as i want (assume i can cut every 10minutes), so finally i can encode each clip individually (if that helps a little), and at the end Merge them all together for Authoring.
On the other hand, the only think i can think off, is to produce an automatic list of these lines in some program (i don't know if is possible):
insert2( 85)
insert2( 97)
insert2(109)
untill the end of each clip.
I think for each 10min clip there are 17.982 frames (if i am correct)
Don't know what else i can do.
Regards
scharfis_brain
23rd September 2006, 11:09
@kle500: regarding mvbob and all other things in general: it is always worth to RTFM! in the new version I renamed some functions to make my nomenclature more consistent. just find out, what I've changed. I don't write readmes, cause I have too much spare time!
@didee: a fully automated dupe-removal with inbuilt drop-interpolation could still be done, I think.
just look at these numbers.
bold = dupes
italics = drops
0: 0.000003
1: 85.691177
2: 49.820648
3: 37.678570
4: 0.035472
5: 47.582237
6: 44.667099
7: 81.275780
8: 47.266949
9: 50.533581
10: 0.036898
11: 53.715359
12: 51.274063
13: 92.643013
14: 53.633461
15: 46.215290
16: 0.033446
17: 48.130783
18: 49.786823
19: 51.594868
20: 24.176392
21: 18.214291
22: 0.034132
23: 26.019569
24: 33.175808
25: 47.786888
26: 18.450073
27: 44.698902
28: 0.036186
29: 54.513680
30: 62.384312
31: 97.947174
32: 65.001740
33: 54.669342
34: 0.031548
35: 56.498402
36: 50.687458
37: 80.032852
38: 41.101147
39: 39.517265
40: 0.031264
41: 39.730183
42: 40.515690
43: 81.645355
44: 51.249191
45: 47.824524
46: 0.030966
47: 59.900497
48: 61.766315
49: 85.367569
50: 40.438179
51: 42.258961
52: 0.041299
53: 27.766155
they are derived from this (pseudocode) construct:
in=mpeg2source("C:\forum\kle500\test.d2v")
momask=in.motionmask(thy1=0, thy2=10, thc1=0, thc2=10, thSD=255, u=3, v=3)
averageluma(momask)
it is obvious, that - with constant motion - there is one number between two near-zeros that is max. this number has to be considered a framedrop.
now, how can we drop the dupes and interpolate the drops?
1) determine the distance from the left zero to the max.
2) this distance is the number of frames to shift one frame backwards using some clever trims in the conditional environment
3) use a modified insert2 function, that - instead of inserting frames - overwrites a current frame with interpolated contens
Didée
23rd September 2006, 14:03
Yes, I had something similar in mind. Sort of a buffer hold in the background ... both dupes and motion jumps can be detected. While running through the clip, in cond.env. it is looked for dups and jumps. if a dup is detected, a flag is set. normal frames are put out if the flag is not set. If the flag is set, then an offsetted clip is put out. if a jump is detected, the compensation is put out, and the flag is cleared.
Are you already almost finished with the script, or shall I give it a go? :)
kle500
23rd September 2006, 14:16
I must thank everyone here that are investing time and effort for possible sollution to my problem.
I send "Didee" and "scharfis_brain" via PM, a larger file, that might be better sample for testing perpose!
Once again.
Thank's
scharfis_brain
23rd September 2006, 14:34
I havenät scripted anything yet.
You may give it a try. You've always been better taming the cond.env than me.
foxyshadis
23rd September 2006, 21:03
What do you know, the name has changed. I'd have left a SecureDeint->SecureBob wrapper, but it's your baby. You need a thread to post in when you release a new version, so we can all be on the latest version. ;)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.