View Full Version : Vertical upscaling of pure interlaced footage
Avisynth_challenged
14th December 2008, 10:19
Hi,
I have a problem that I'm not sure how to solve.
I recorded a program that is 704x480, pure interlaced, NTSC. The video is letterboxed 4:3, and with the letterbox bars removed, a 16:9 image remains.
I'm hoping to be able to somehow crop the letterbox bars, and then resize back to 480, so that I can encode in 16:9 MPEG2. My goal is to put the program onto DVD.
So my workflow would go something like this:
1. Crop: 704x480 -> 704x364
2. Resize: 704x364 -> 704x480
3. Pad: 704x480 -> 720x480
But I'm not sure how to implement Step 2, as the material is pure interlaced.
I did find this thread (http://forum.doom9.org/showthread.php?t=139102) on downscaling 1080i HD to 480i for DVD, but it talks about how to optimally "throw away" image detail for the HD to SD conversion. My problem is how to interpolate 116 lines of information to go from 4:3 SD to 16:9 SD.
So if anyone has any ideas, comments, or thread links, please pass them along. Thanks everybody :thanks:
*.mp4 guy
14th December 2008, 11:15
Quick note on the aspect ratio issue, you can only upsize it to 704*432, the rest has to be filled with black, in order to maintain proper aspect ratio on a dvd.
IanB
14th December 2008, 14:13
@Avisynth_challenged,
A. SmartBob to 60p, then use NNEDI to double the height to 728, then use a normal sharp resizer to scale back 480, finally reinterlace back to 60i.
B. For faster processing but with less quality, separate fields, NNEDI to double the height of the fields to 364, Interlaced resize the fields to 240 (you will need to adjust the correction factor to compensate for the NNEDI), weave.
And are you really sure your source is true 60i and not 3:2 of 24p.
C. If it's 24p then IVTC to recover the 24p, then use NNEDI to double the height to 728, then use a normal sharp resizer to scale back 480. Encode as 24p MPEG2 with soft 3:2 pulldown.
@*.mp4 guy,
432 is 16:9 letterbox of PAL
Avisynth_challenged
14th December 2008, 18:32
Thanks for the responses IanB and *.mp4 guy.
@Avisynth_challenged,
A. SmartBob to 60p, then use NNEDI to double the height to 728, then use a normal sharp resizer to scale back 480, finally reinterlace back to 60i.
Highest quality is desired, so I'd like to explore this option. By "SmartBob" were you referring specifically to Donald Graft's SmartBob filter for VirtualDub, or did you mean I should do smart bobbing first? I know there are several quality smart bob filters for Avisynth (i.e. mvbob) so maybe some recommendations for smart bobbing filters can be suggested. Thanks.
And are you really sure your source is true 60i and not 3:2 of 24p.
Yes, it is definitely true interlaced. The program was a taped concert performance.
C. If it's 24p then IVTC to recover the 24p, then use NNEDI to double the height to 728, then use a normal sharp resizer to scale back 480. Encode as 24p MPEG2 with soft 3:2 pulldown.
I'm going to try this out on another project which was successfully IVTC'd to 23.976fps. I'm hoping to upscale it from 300 pixels high to 380 pixels high without introducing too much aliasing. Thanks!
Thanks again for your help.
IanB
14th December 2008, 21:51
Highest quality is desired, so I'd like to explore this option. By "SmartBob" were you referring specifically to Donald Graft's SmartBob filter for VirtualDub, or did you mean I should do smart bobbing first? I know there are several quality smart bob filters for Avisynth (i.e. mvbob) so maybe some recommendations for smart bobbing filters can be suggested.You want one of the smart bob filters. Seeing you want to use NNEDI to double the height of the result do NOT use a bobber that uses any of the *edi family. And as you are going to reinterlace again you probably only need one from the very reasonable class, .i.e. yadif, tdeint, kerneldeint, etc
An alternative approach that will give slightly less sharp results but will avoid problems with interfield twitter, would be to use a NNEDI based bobber and then used an interlaced resizing related technique to directly produce new fields and finally Weave.
The decision depends a lot on the original source material and your own tastes.
Avisynth_challenged
14th December 2008, 21:55
Did lots of reading on the forum about resizing interlaced sources, and came upon *this* (http://forum.doom9.org/showthread.php?t=140442), which lead me to *this* (http://forum.doom9.org/showthread.php?p=1055263#post1055263).
Based on the above, I came up with the following script:
### BEGIN SCRIPT ###
LoadPlugin("C:\program files\avisynth 2.5\plugins\DGDecode.dll")
LoadPlugin("C:\program files\avisynth 2.5\plugins\decomb.dll")
Import("C:\program files\avisynth 2.5\plugins\mcbob_v0.3u.avs")
############
# This line loads the MPEG source
MPEG2Source("Path\source.d2v")
############
# Should already be yv12, but just to make sure...
converttoyv12(interlaced=true).AssumeTFF() #or AssumeBFF if necessary
# crop off borders:
crop(0,58,-0,-58)
#Bob-deinterlace to 50p/60p
mcbob()
#Edge-directed interpolation to double height
NNEDI(field=0, dh=true)
#Make it fit
Spline36resize(704,470).addborders(8,5,8,5)
#Reinterlace
assumetff().SeparateFields().SelectEvery(4,0,3).Weave().converttoyuy2()
### END SCRIPT ###
And here are some before and after screengrabs:
Source: (http://i252.photobucket.com/albums/hh18/FoolsTalk/concert_source.png)
Output: (http://i252.photobucket.com/albums/hh18/FoolsTalk/concert_output.png)
Comments, criticism, etc. welcome. Thanks, all :thanks:
Avisynth_challenged
14th December 2008, 22:14
You want one of the smart bob filters. Seeing you want to use NNEDI to double the height of the result do NOT use a bobber that uses any of the *edi family. And as you are going to reinterlace again you probably only need one from the very reasonable class, .i.e. yadif, tdeint, kerneldeint, etc
An alternative approach that will give slightly less sharp results but will avoid problems with interfield twitter, would be to use a NNEDI based bobber and then used an interlaced resizing related technique to directly produce new fields and finally Weave.
The decision depends a lot on the original source material and your own tastes.
I didn't see this before I wrote my previous post. I will look into the other smart bobbers you suggested, yadif, tdeint, kerneldeint. Would you care to comment on my screengrabs showing the source and the result with mcbob? I'm such a novice, as I'm sure you've surmised :(
I truly appreciate this forum and the assistance that its experienced users offers to us newbies.
2Bdecided
14th December 2008, 22:15
This is a waste of time:Spline36resize(704,470).addborders(8,5,8,5)
Just do this:
Spline36resize(704,480)That's fine for DVD.
If you're really anal about aspect ratios, you could use crop(0,60,0,-60) in place of your existing crop - but I reckon the aspect ratio is already wrong by that much, and wouldn't worry about it.
Cheers,
David.
Avisynth_challenged
14th December 2008, 22:28
This is a waste of time:Spline36resize(704,470).addborders(8,5,8,5)
Just do this:
Spline36resize(704,480)That's fine for DVD.
If you're really anal about aspect ratios, you could use crop(0,60,0,-60) in place of your existing crop - but I reckon the aspect ratio is already wrong by that much, and wouldn't worry about it.
Cheers,
David.
Thanks for the tip. But isn't there a side-benefit for padding to 720 pixels wide in that you can expose a few pixels which would otherwise be lost to overscan? I dunno, it doesn't make much difference either way, but if you can have it, why not?
thetoof
14th December 2008, 22:39
Instead of bobbing and reinterlacing, wouldn't it be simpler to:
-crop the black bars
-separatefields()
-upscale to half vertical resolution
-weave()
Also, when upscaling with nnedi, don't forget to correct the registration error caused by edi upscaling. A bit of info here (http://forum.doom9.org/showthread.php?p=1166238#post1166238) and at around post #71 + around here (http://forum.doom9.org/showthread.php?p=1224005#post1224005).
dest_x=
dest_y= # half final vertical resolution
nnedi(1,true).spline36resize(dest_x,dest_y,0,-0.5,2*a.width+.001,2*a.height+.001)
IanB
14th December 2008, 22:57
Okay Guitar strings :( they will twitter every time the strings are near horizontal.
Script should go something like this :-...
MPEG2Source("Path\source.d2v")
crop(0,58,-0,-58) # crop off borders:
#Bob-deinterlace to 50p/60p
???bob() # pick one
ConvertToYUY2() # Do this while progressive!
AssumeTFF()
Factor=0.5 # Need to derive the correct value for this!
E=SelectEven().Spline36resize(712, 240, 0, Factor, 0, 0).AddBorders(4,0,4,0)
O=SelectOdd( ).Spline36resize(712, 240, 0, -Factor, 0, 0).AddBorders(4,0,4,0)
Interleave(E, O)
Weave()I have adjusted your pixel aspect based on 4:3 letterbox of 16:9 material normally having 60 pixel borders and you have 58 pixel borders.
I don't have time to derive Factor, maybe one of the other members can do it. It will be the output uncrop scaled to the input size but with no input crop from my Interlaced Resize code.
Avisynth_challenged
15th December 2008, 00:40
Okay Guitar strings :( they will twitter every time the strings are near horizontal.
Script should go something like this :-...
MPEG2Source("Path\source.d2v")
crop(0,58,-0,-58) # crop off borders:
#Bob-deinterlace to 50p/60p
???bob() # pick one
ConvertToYUY2() # Do this while progressive!
AssumeTFF()
Factor=0.5 # Need to derive the correct value for this!
E=SelectEven().Spline36resize(712, 240, 0, Factor, 0, 0).AddBorders(4,0,4,0)
O=SelectOdd( ).Spline36resize(712, 240, 0, -Factor, 0, 0).AddBorders(4,0,4,0)
Interleave(E, O)
Weave()I have adjusted your pixel aspect based on 4:3 letterbox of 16:9 material normally having 60 pixel borders and you have 58 pixel borders.
I don't have time to derive Factor, maybe one of the other members can do it. It will be the output uncrop scaled to the input size but with no input crop from my Interlaced Resize code.
Thanks IanB. To calculate "FACTOR", should I use the formula you gave for "SHIFT" in this post (http://forum.doom9.org/showthread.php?p=594339#post594339)? Thanks!
Gavino
15th December 2008, 00:41
I don't have time to derive Factor, maybe one of the other members can do it. It will be the output uncrop scaled to the input size but with no input crop from my Interlaced Resize code.
I reckon it is -0.5*(364.0/480.0).
Sanity check: want negative crop for top field, and it reduces to -0.5 if output size = input size (when it becomes Bob in reverse).
Are you sure the last 0 in the resizes is right? I would expect this to be omitted (ie defaulted to Height()).
IanB
15th December 2008, 02:05
I think Gavino has it right, and yes the last 2 zeros in the resize should be gone.
And no, FACTOR and SHIFT, are not the same, here we start with a fully progressive stream so there is no input correction required, there it is a field separated stream so there needs to be an alternating input correction. On output both need the alternating "uncrop". The geometry involved is somewhat tricky. :devil:
As I said the decision depends a lot on the original source material and your own tastes. If the guitar is seldom horizontal then twitter may not be an issue and the original A method may be preferred. Experiment some! Remember to view the results an an proper interlaced display device, PC screens are crap for working with interlaced streams.
ajp_anton
15th December 2008, 04:33
Did I miss something? Why not just encode the source as it is (720x480 set to 4:3)?
Sagekilla
15th December 2008, 07:00
@ajp_anton: The source video isn't supposed to be 4:3. It has a frame size of 704x480, but with 116 pixels of bordering.
IanB
15th December 2008, 07:08
@ajp_anton,
Yes, the source is 4:3 hard letterboxed and Avisynth_challenged wants to repair it to be proper 16:9 with the best available vertical rescaling. And I can sympathise with him, typically DVD players into 16:9 televisions play this garbage letterboxed+pillarboxed, my player offers a 1.5x zoom which helps slightly (really want a 1.333x zoom).
2Bdecided
15th December 2008, 12:26
Thanks for the tip. But isn't there a side-benefit for padding to 720 pixels wide in that you can expose a few pixels which would otherwise be lost to overscan? I dunno, it doesn't make much difference either way, but if you can have it, why not?In a stand-alone player, it makes precisely no difference - you're just wasting time encoding 8 black pixels either side that will be cropped anyway. Watching on a PC you're adding a black border - equally pointless.
I'm confused why you're now looking at separate field resizing. It would be interesting to see a comparison, but my assumption would be that a good bob (e.g. mcbob, or TempGaussMC_alpha3) would give dramatically better results.
Cheers,
David.
P.S. - the show might be available in HD, which would make a much better source for an anamorphic 16x9 DVD.
thetoof
15th December 2008, 13:32
TempGaussMC_alpha3
beta1 has been available for quite a while now...
You could also use TempGaussMC_beta1mod() (http://www.mediafire.com/download.php?jzemm2znjnz) with an additionnal parameter:
mt=true #use multithreaded branch by josey_wells (1.9.7.7)
mt=false #use MVTools2 (currently 2.3.0) (default)
chroma correction has been disabled for MVTools2 since it has been corrected in MVTools 1.10.2.1
2Bdecided
15th December 2008, 15:12
beta1 has been available for quite a while now...You say that as if I didn't know ;)
http://forum.doom9.org/showthread.php?p=1159579#post1159579
If I had a CPU capable of MT, I'd look again at beta1 to get "nearly as good" quality in a fraction of the time. TBH I (and, I think, WorBry, with very different content) felt that the default settings for beta1 were so obviously worse than alpha3 that there'd be a beta2 along soon to fix it.
Cheers,
David.
ajp_anton
15th December 2008, 15:17
The source video isn't supposed to be 4:3. It has a frame size of 704x480, but with 116 pixels of bordering.Yes, a 16:9 image in a 4:3 frame has 60+60 pixels of black bars (704x360, he has 4 extra pixels of height).Yes, the source is 4:3 hard letterboxed and Avisynth_challenged wants to repair it to be proper 16:9 with the best available vertical rescaling. And I can sympathise with him, typically DVD players into 16:9 televisions play this garbage letterboxed+pillarboxed, my player offers a 1.5x zoom which helps slightly (really want a 1.333x zoom).Of course 704x480 sar 40:33 is optimal and what 16:9 images should be, but if he can get around the problem with black bars on each side during playback, the best solution is to not touch the source.
2Bdecided
15th December 2008, 17:30
Of course 704x480 sar 40:33 is optimal and what 16:9 images should be, but if he can get around the problem with black bars on each side during playback, the best solution is to not touch the source.Well, that depends. If the TV has a lousy deinterlacer, or is a 16x9 CRT which makes the scan lines very visible when expanding a letterbox to full 16x9, then the processed version could look much better.
Otherwise, yes, the process might introduce deinterlacing and interpolation errors where previously there were none. It just saves messing with the TV's menus because 16x9 is flagged properly (if that helps your particular TV).
Cheers,
David.
Avisynth_challenged
15th December 2008, 21:37
In a stand-alone player, it makes precisely no difference - you're just wasting time encoding 8 black pixels either side that will be cropped anyway. Watching on a PC you're adding a black border - equally pointless.
I'm confused why you're now looking at separate field resizing. It would be interesting to see a comparison, but my assumption would be that a good bob (e.g. mcbob, or TempGaussMC_alpha3) would give dramatically better results.
Cheers,
David.
P.S. - the show might be available in HD, which would make a much better source for an anamorphic 16x9 DVD.
I'm sticking to the 720x480 option since this is required for anamorphic 16:9 MPEG2 encodes. (Source here, under "Other Requirements" (http://en.wikipedia.org/wiki/DVD-Video))
I don't think this program is available in HD for me, as it is a PBS show. At least, the high-definition PBS station in my area doesn't broadcast this program at all, unfortunately.
I've also gone back to MCBob + NNEDI, as it looked better than separate field resizing for my particular source. Thanks to everyone who's participated here. The information has helped tremendously. I only have one question at this point: What exactly is "interlaced twitter"?
Thanks again :thanks:
2Bdecided
16th December 2008, 00:40
I'm sticking to the 720x480 option since this is required for anamorphic 16:9 MPEG2 encodes. (Source here, under "Other Requirements" (http://en.wikipedia.org/wiki/DVD-Video))Well, if it says it on wikipedia, it must be true. ;)
It would be interesting to know whether that's a correct bit of copying from the DVD spec, or someone missing the more likely point that the full resolution modes (i.e. 720 and 704) allow anamorphic content, while the half resolution modes (i.e. 352) do not.
I believe all players support 704 anamorphic, but this doesn't prove it's in the official spec: some players support 540x576 anamorphic with a long GOP, which is well outside the official spec!
Interlaced twitter is where fine detail appears to twitter at 25 or 30fps due to parts of it being present on one field, but absent on the other. It's bad to include such fine details in an interlaced video signal, but it often happens.
Cheers,
David.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.