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 3rd August 2010, 05:30   #1  |  Link
Buck746
Registered User
 
Join Date: Jul 2003
Posts: 20
Help with Babylon 5 scaling

I'm trying to get the best picture I can out of the dvd's for babylon 5. On any shots with cgi in them they have been poorly scaled from the original 4:3 broadcast masters. Seeing how I don't have the Laserdiscs for the show i'm trying to correct the problem with avisynth. I found a website here: http://www.modeemi.fi/~leopold/Babyl...ml#030421proof that demonstrates a form of correcting the problem. I have tried to figure out a way to do this in avisynth and have come up short handed so far.

I have tried searching the forums here with no luck. Maybe I just haven't used the right search terms. Thanks in advance for any help anyone can provide.
Buck746 is offline   Reply With Quote
Old 3rd August 2010, 13:12   #2  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Post a link to an unprocessed sample showing the problem.
Guest is offline   Reply With Quote
Old 3rd August 2010, 13:17   #3  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Well, really fixing this isn't possible. What he did is a pretty simple linear filter of some kind, which corrects about half of the problem.

In avisynth it probably looks something like this:
Code:
In = assumeframebased()
odd = In.separatefields().selectodd.spline36resize(width, 360).pointresize(width, 180)
even = In.separatefields.selecteven.spline36resize(width, 360).pointresize(width, 180)
out = interleave(odd, even).weave().spline36resize(width, 480)
out
Though he probably did it with FIR's, which in avisynth would probably be slower.

You still have to figure out how to apply this to the correct parts of a frame. Or the correct frames, depending on how the compositing was done.

Also, linear filters cannot adequately correct for previous linear filters, to really fix this problem completely you would need a specialty strong nonlinear filter of some kind. Not that your going to get any more detail from this, but to kill the remaining artifacts without removing detail would require some sort of pseudo deconvolution.
*.mp4 guy is offline   Reply With Quote
Old 3rd August 2010, 13:29   #4  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Is it really that complicated? Isn't it a rather simple case of misaligned fields, due to field separated resizing without correction?

Since I own the German R2 version, I can't reproduce the problem. The bad thing about R2 is that the CGI sections are ... fieldblended!
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 3rd August 2010, 14:35   #5  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Quote:
Originally Posted by Didée View Post
Is it really that complicated?
The complication is that if you have an improperly sampled signal (such as interlacing) linear filters do very poorly. A lot of the ugliness is from the signal leakage of the aliasing into other parts of the signal. If you look at the example he linked to, you can see some residual problems, and this is most likely the cause.

Quote:
Originally Posted by Didée View Post
Isn't it a rather simple case of misaligned fields, due to field separated resizing without correction?
It probably is, but I didn't find the correct offsets when I took a few minutes to check. Offsets didn't appear to work aswell as pointresizing, so it could be a bit more complicated. Though its quite possible I just made a mistake looking for the offsets.
*.mp4 guy is offline   Reply With Quote
Old 4th August 2010, 00:27   #6  |  Link
Buck746
Registered User
 
Join Date: Jul 2003
Posts: 20
To be honest i'm not shure how to post a sample video clip on here. On the R1 Dvd's every shot that had a visual effect suffers from the same problem. Even tho it means taking apart every episode to find all of these shots I don't mind the work, I just want the best I can get from the source material I have. I have been using TemporalDegrain to filter the film sections. The intent is to calm down the grain a bit, not remove it all together.
Buck746 is offline   Reply With Quote
Old 4th August 2010, 00:34   #7  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
You want a complex solution to fix this issue, but you can't figure out how to post a sample.

That's rich.
Guest is offline   Reply With Quote
Old 4th August 2010, 01:11   #8  |  Link
Buck746
Registered User
 
Join Date: Jul 2003
Posts: 20
I'm just not sure what file hosting sites are out there. It's not something I do.
Buck746 is offline   Reply With Quote
Old 4th August 2010, 01:20   #9  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,345
Quote:
Originally Posted by Buck746 View Post
I'm just not sure what file hosting sites are out there. It's not something I do.
free hosting sites
eg. mediafire.com , sendspace.com

you could cut a sample with dgindex, for example
poisondeathray is offline   Reply With Quote
Old 4th August 2010, 01:29   #10  |  Link
Buck746
Registered User
 
Join Date: Jul 2003
Posts: 20
Assuming file hosting works correctly a sample should be at this address http://www.mediafire.com/?tcau3c8fgsouch4

I just haven't done a post like this before. Been using avisynth for years. I remember dvd ripping when it was done by running a program to take a screenshot from powerdvd for every frame, it was always a pain to get the audio to sync exactly. I realise some of the posters on here are a lot smarter with scripting than I am, that's why i'm asking for help. I don't post becuase every problem I have wanted a solution for has already been discussed here before. This is the first time I have come across something worth asking about.

I've tried finding a way to align the image correctly in photoshop but can't find a way of making it work as well as on the website I mentioned in the original post. Processing time isn't a big problem. Besides on a show like B5 there are a bunch of stock shots that get used so it's really just editing them into several episodes as they were in the original version.

Last edited by Buck746; 4th August 2010 at 01:37.
Buck746 is offline   Reply With Quote
Old 4th August 2010, 02:59   #11  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
You posted to ask about restoring the CGI portions:

"On any shots with cgi in them they have been poorly scaled from the original 4:3 broadcast masters."

So why, instead of posting such a CGI section, did you post a sample with no CGI and which appears to be simple, unproblematic hard telecine?

And does that disk really only have one audio track? Or did you get the source from somewhere other than the original disk?
Guest is offline   Reply With Quote
Old 4th August 2010, 03:24   #12  |  Link
Buck746
Registered User
 
Join Date: Jul 2003
Posts: 20
It was from the original R1 Disc. The scaling problem is present in every shot that had a digital matte and the pure cgi shots. I think it's becuase they scaled those shots from the 4:3 master tapes to 1080 to match the Telecine that Sci-Fi funded when they started airing the episodes so they could show them in widescreen. The 1080 masters that got made were then downscaled to NTSC and PAL for the dvd releases.

When the show was being made it was always assumed that re-rendering the effects would be easy when hdtv got hammered down in spec. Over time tho all the elements got lost so the only options were to scale the 4:3 material up and use new film scans of everything without some kind of composite or cgi work. The other option of course would be to do what paramount did with Star Trek and generate new effects to replace the old ones. Seeing how B5 is the red headed stepchild of warner brothers they went with the former option.

Here's a file with pure cgi http://www.mediafire.com/?iqx9fzk7bln8pgj
And a file of pure film http://www.mediafire.com/?rpm2rgpnr6q5n9t

The 3:2 pulldown is hard coded into the file. Mainly due to some of the computer graphics sequences are a mix of 24 and 30fps with the occasional 60 fields content thrown in. I figured that it made sense to just clip the raw vob files down for a sample rather than a avi with deinterlacing already done.
Buck746 is offline   Reply With Quote
Old 4th August 2010, 12:40   #13  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
I couldn't unpick the broken resizing, so I cheated...

PHP Code:
mpeg2source("B5_clip2.d2v")

a=last

last
o
.NNEDI2(field=-2)
dbl   Merge(SelectEven(),SelectOdd())
dblD  mt_MakeDiff(o,dbl,U=3,V=3)
shrpD mt_MakeDiff(dbl,dbl.RemoveGrain(11),U=3,V=3)
DD    shrpD.Repair(dblD,13)

dbl.mt_AddDiff(DD,U=3,V=3)

limitedsharpenfaster()

stackhorizontal(last,a
That's Didée's trick, but it's not really meant for this problem - unpicking it properly would be better.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 4th August 2010, 13:20   #14  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
I'll have a look, too, but it may take a little. (BTW, the B5 saga is my all-time favorite.)

From which episode are these samples? I'd like to compare with my R2 DVDs.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 4th August 2010, 18:03   #15  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
the creators of the 16x9 anamorphic masters basically b0rked all CGI scenes.
they simply cropped the 4x3 fullscreen (480 lines) cgi scenes
to 16x9 letterboxed (360lines) and
then applied a linear fieldbased upscale to 16x9 anamorphic (480 lines again).

The result is image artifact seen in the sample video.
You can basically undo it with this code:

PHP Code:
mpeg2source("B5_clip2.d2v")
bob(0,1#do a dumb bob (don't scale with bob, it doesn't look the same as bicubicresize does)
bicubicresize(width,360#downscale the image
assumetff().separatefields().selectevery(4,0,3).weave() #re-interlace the image
bicubicresize(width,480#do a proper progressive upscale 
This code simply reverts the fieldbased upscale by doing a fieldbased downscale.
The problem is, that this code only will make the center of the image look better. The top and bottom parts of the image are still very blurred,
because the scaling offsets do NOT match.
You have to try and error of the amount of scaling (360 +/- 2 pixels) as well as for the vertical offset.

I really haven't got the time to do so.
Maybe Didée or someone else has a quick shot for it.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 4th August 2010, 23:19   #16  |  Link
Buck746
Registered User
 
Join Date: Jul 2003
Posts: 20
I just got home from work so i'll have a bit of time to run thru and try the suggested scripts. Didée the clips were taken from a S2 disc, the episode would be either (The Coming of Shadows) or (GROPOS). I ripped just the first chapter from the episodes because I wanted to take the opening credits and average them all together from all the different dvd's. When I started doing stuff with tv shows I usually captured the original airing and as many repeats as I could so I could get the cleanest image possible.
Buck746 is offline   Reply With Quote
Old 5th August 2010, 03:15   #17  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
Well I figured out why offsets don't work, there isn't a universal offset for the entire frame (duh). Luckily, since the ratio between the two sizes can be simplified to 3:4 (if the information on the source is correct) the offsets repeat every 16 interlaced frame lines (or every 8 field progressive lines). Which is still a massive PITA. I haven't coded any of this up yet, but it might be a while before I have the time, so I figured I should post what I figured out so far. Hopefully I'm wrong and someone else will figure out how to do this much more easily, but I doubt it .
*.mp4 guy is offline   Reply With Quote
Old 5th August 2010, 07:46   #18  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
I think, I've got it:

PHP Code:
mpeg2source("B5_clip2.d2v"#source filter
bob(0,1#bob the source
#scale down the video to its original resolution with the correct offsets 
bicubicresize(width,360,0,1,0,-1,0,482#(might benefit from some further finetuning)
assumetff().separatefields().selectevery(4,0,3).weave() #reinterlace
nnedi2(dh=true,field=0).bicubicresize(width,480,0,1)  #upscale using nnedi2 to supress stairstepping
subtract(last,subtract(deen("a2d",3,7,0),last)) #enhance texture details a bit 
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain is offline   Reply With Quote
Old 5th August 2010, 15:43   #19  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
scharfis_brain - Magic!

I think there must be a correct set of offsets (possibly different for top field vs bottom field) to use without doing a bob first. This might be sharper (might not be!). Not sure about correct chroma processing in that case (might be fine as-is, might be some other nastiness to fix).

Cheers,
David.
2Bdecided is offline   Reply With Quote
Old 5th August 2010, 17:43   #20  |  Link
scharfis_brain
brainless
 
scharfis_brain's Avatar
 
Join Date: Mar 2003
Location: Germany
Posts: 3,653
you might try reverse scalingg without using bob().
but I don't see any real benefit doing so except of getting to hassle with scripting.
__________________
Don't forget the 'c'!

Don't PM me for technical support, please.
scharfis_brain 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 11:20.


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