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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th May 2012, 00:34   #1  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,389
Conversion deblending/chroma deblending using reference source - unstable test filter

Hi all,

I've written a filter to restore video with blended fields/frames using a reference source - in my case, I have an SD source at native 25p and an HD source of the same video which was converted to 60i.

srestore did a near-perfect job; however, I wasn't happy that srestore doesn't give consistent results when seeking, nor that I still had residual chroma blends.

So I wrote a couple of very quick filters, one to pick out the unblended frames from the (bobbed) HD video to match the SD video, and another (possibly the more useful) to undo any residual chroma blending.

Here's the download: specials.zip (caution: potentially highly unstable!)

And here's a very rough overview:

Code:
blended=... # a blended HD source, in my case a Blu-ray rip
reference=... # an SD source of the same video, in my case a DVD rip

# now prepare two matching progressive clips from the above
# (I cropped because the DVD rip had black bars at left and right but the Blu-ray didn't;
# I also had to shift one picture a little, and blurring both may help get saner matches.
# You may also have to do some trimming)

blended_compare=blended.bob.bicubicresize(720,576).crop(16,0,-16,0).blur(1.58)
reference_compare=reference.crop(16,0,-16,0).blur(1.58)

# now use the filter planetmatch to restore the unblended frames

unblended=planetmatch(blended, blended_compare, reference_compare)

#########################
# if there is still blended chroma:
#########################

unblended_compare=unblended.bicubicresize(720,576).crop(16,0,-16,0)
# ^ to match reference_compare from above

chromafix(unblended, unblended_compare, reference_compare)
Please note: the filters should be used with caution - they do absolutely no sanity checking, and have only been tested with YV12 clips. If there is interest I will tidy them up, but I want to gauge that first as it seems an unlikely scenario.

Sorry if my terminology is a little confused - different kinds of blends being discussed with the same terms, etc - and for the cryptic filter name

Edit: chromafix in action: (image)

David

Last edited by wonkey_monkey; 26th May 2012 at 00:38.
wonkey_monkey is offline   Reply With Quote
Old 26th May 2012, 13:08   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,266
Quote:
but I want to gauge that first as it seems an unlikely scenario
Dont think at all unlikely, I'm sure a number of people would be interested in your ideas in this respect
and would love to have a gander at the source (even if you did not tidy it up).

I had an idea of doing a plugin version of recent MatchFrames script to do a single scan storing eg aveluma,
minluma, maxluma, in arrays (for the hires c clip) and only doing compares with lores f clip frames where
the stored luma values were a close approximation to that of the f clip find frames. Dont think I'll bother doing
this but it could speed up detection somewhat.
EDIT: But probably not much use to you in PlanetMatch.
__________________
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; 26th May 2012 at 14:04.
StainlessS is offline   Reply With Quote
Old 29th May 2012, 21:16   #3  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,389
Here's the untidy source: http://horman.net/specials-src.zip. There's an unintentional pun on "special sauce" in there somewhere...

planetmatch uses the length of both comparison clips to work out the approximate position of each unblended frame, then checks a couple of frames either side and returns the best luma match (it also, possibly redundantly, checks chroma either side of the best luma match in case there is a better match there - I think this would now be taken care of by chromafix anyway).

chromafix is run on the result from planetmatch (i.e. it should match the reference clip in luma at least), and compares the chroma from the previous, current and next frames against the reference source frame, and if the current frame is the best match it then calculates and finds the best match among some "unblends" - current*1.x-previous*x and current*1.x-next*x, where x ranges from 0 to 0.5.

(FYI, palrestore is a filter for restoring a different, specific case of 60i to 25p)

David
wonkey_monkey is offline   Reply With Quote
Old 4th June 2012, 14:22   #4  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 262
Quote:
I've written a filter to restore video with blended fields/frames using a reference source
...and you published it on my birthday!

I shall look forward to examining your code soon, if I can find enough free time.
pbristow is offline   Reply With Quote
Old 4th June 2012, 18:37   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,266
Thankyou for the source.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 4th May 2015, 12:05   #6  |  Link
resonator79
Registered User
 
Join Date: Apr 2011
Posts: 12
< Off Topic >
I'm attempting to fix my DW-Specials BD, and I ran across this thread, as well as another one with some script examples.
David, I was able to use your experimental plugin successfully on The Next Doctor and The Waters of Mars so far, INCREDIBLE work on your parts, worked like a charm. I was able to fix the remaining interlaced parts nicely, and I fixed the credits, differently though, since the DVDs I got are terribly blocky, so I used AE Pixel remapping from a (bobbed) 60p.
< / Off Topic>

So first of all, thanks!

Now, I'm trying to use planetmatch as well, however, I can't quite figure it out.

I used:

Code:
blended=AVISource("dw_straight_bd.avi").ConvertToYV12() 
reference=AVISource("dw_straight_dvd_synced2bd.avi").ConvertToYV12()


blended_compare=blended.bob().bicubicresize(720,576).blur(1.58)
reference_compare=reference.blur(1.58)

unblended=planetmatch(blended, blended_compare, reference_compare)

unblended_compare=unblended.bicubicresize(720,576)

chromafix(unblended, unblended_compare, reference_compare)
I've synced up the DVD temp-decode AVI to be frame-accurate (as much as that's possible with 29,97i and 25p sources) in advance, just to make sure that they are and stay in sync.
I removed the cropping, because the DVD version I have didn't have any borders.

Yet, the output is clearly interlaced and has chroma-shifting going on as well...

Am I missing something? Could it be an issue with certain other plugins, a wrong version or something?
resonator79 is offline   Reply With Quote
Old 4th May 2015, 17:14   #7  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,389
I got your PM, but have currently mislaid my scripts. But from what you've now posted, I think I can see what you've missed - blended needs to be bobbed, not just blended_compare. I used QTGMC by itself to write a losslessly-compressed bobbed version, then used that as my input for the matching stage.

You should also ensure that your two compares line up as closely as possible, spatially (as well as temporally), otherwise you'll end up getting the wrong frames on slow pans. Use a frame from the start of a shot and modify bicubicresize parameters to shift.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 4th May 2015, 17:40   #8  |  Link
resonator79
Registered User
 
Join Date: Apr 2011
Posts: 12
Will try that ASAP. Thank you!
resonator79 is offline   Reply With Quote
Old 10th May 2015, 18:36   #9  |  Link
resonator79
Registered User
 
Join Date: Apr 2011
Posts: 12
Unfortunatly, after having spent a few hours trying, I gave up, couldn't get it to work.
However, like you said in the other thread, srestore works pretty well, it's just scene changes that are a gamble.
I used Torchwood HD-DVD for this example, but Planet Special is pretty much the same:



Now, with the Planet of the Dead special, I could go through in Premiere Pro and substitute the frames with the clean frames from the bobbed file, but that's a lot of work, and I'd really like to fix my Torchwood HD-DVDs as well, so...

I've been thinking about modifying srestore to use an override file, but I don't know how. Do you have any ideas how to fix this?
resonator79 is offline   Reply With Quote
Reply

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 00:34.


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