View Full Version : Resize/Upscale DVD, need guidance
trumpet205
16th June 2014, 04:38
I need some help on resize/upscale video ripped from DVD using Avisynth. Now I own large number of Blu-ray and DVD. Digitizing my Blu-ray collection is easy, but since DVD uses anamorphic to store video (and I don't want anamorphic), it is more complicated.
My goal is to,
* Decomb/De-interlace the video first
* Resize the video from 720x480 to either 720x540/960x720 (4:3) or 848x480/1280x720 (16:9).
I don't know where to start with Avisynth scripting. Any help is appreciated.
ndjamena
16th June 2014, 06:33
mpeg2source("Video.d2v")
TFM().TDecimate for NTSC or QTGMC() + srestore for PAL of it's not already progressive
NNEDI3_Resize16 for upsizing
That's a START. It all needs to be tailored to your specific video though and that's where things get complicated, we can't prepare you for that.
-Edit- And make sure you crop within NNEDI3_Resize16 so that you can crop to mod1.
trumpet205
16th June 2014, 06:40
If the frame rate is 29.97 does TFM still works? Basically one DVD that is meant to be played at 29.97 fps, NOT 29.97 to 23.976 fps.
foxyshadis
16th June 2014, 10:39
If it's interlaced, then yeah, either keep it interlaced (and don't vertically resize) or even better, deinterlace. TDeint, Yadif, QTGMC... lots of quality deinterlacers to choose from.
wonkey_monkey
16th June 2014, 15:40
If it's interlaced, then yeah, either keep it interlaced (and don't vertically resize) or even better, deinterlace.
If you're planning to display on something that will deinterlace automatically (a TV) I'd say keeping it interlaced is better. That's just my opinion though :)
trumpet205
16th June 2014, 16:19
I want to get rid of anamorphic, and that means resizing. So either way I need to deinterlace it.
Couple more info on DVDs I'm dealing with,
* Resolution is 720x480. Intended aspect ratio is 4:3
* It is not telecined. It is shot and meant to be displayed at 29.97 fps.
* I may need to crop out couple lines on left and right to trim off noise/black borders.
So for the sequence I'm looking at: deinterlace > crop > resize.
I'm thinking of using Jinc36Resize for 3 taps Jinc resizing (what madvr is using). What should I use for deinterlace?
creaothceann
16th June 2014, 17:09
QTGMC (http://avisynth.nl/index.php/External_filters#Deinterlacing)
Xaser
16th June 2014, 18:14
+1 for QTGMC. I tested a bunch of deinterlacers for my current projects (mostly SmoothDeinterlace and FieldDeinterlace) and although QTGMC takes substantially longer to process, the results are visibly better and the encoded files are smaller as well. Here are some stats:
x264.exe "input" --output "output.mkv" --crf 18 --sar 1:1 --preset slow --tune animation
Field Deinterlace Blended
- Encode Time: 36,1486m
- fps: 16.45
- File Size: 370.175KB
Field Deinterlace Interpolate
- Encode Time: 35,9378m
- fps: 16.56
- File Size: 420.601KB
Smooth Deinterlace Blended
- Encode Time: 37,3303m
- fps: 15.95
- Datarate: 2068.63kb/s
- File Size: 360.990KB
Smooth Deinterlace Interpolate
- Encode Time: 44,6517m
- fps: 13.33
- Datarate: 2289.04kb/s
- File Size: 399.427KB
QTGMC (QTGMC(Preset="Slower", EdiThreads=2, TR2=3,FPSDivisor=2))
- Encode Time: 60,2082m
- fps: 9.89
- Datarate: 1823.19kb/s
- File Size: 318.188KB
The Deinterlacers were used on YV12 PAL material (some weird NTSC convert interlace). Unless otherwise noted, standard settings were used with MT.
wonkey_monkey
16th June 2014, 22:07
I want to get rid of anamorphic, and that means resizing. So either way I need to deinterlace it.
Not if you only resize it horizontally. That way you have the benefit of your display resize working with the original resolution - in one direction, anyway.
As for cropping left/right to get rid of the borders, the "correct" thing to do should be to crop to 704x480, then resize that to the correct aspect ratio - although that does depend on the DVDs having been mastered in the "correct" way to begin with.
Obviously if the source is 4:3 instead of 16:9, then you'd have to resize down to 640x480, which obviously isn't ideal, but if the source isn't great to begin with, it might not matter too much.
Got a sample?
LemMotlow
16th June 2014, 23:24
I want to get rid of anamorphic, and that means resizing. So either way I need to deinterlace it.For PC-only display. Or Utube?
Couple more info on DVDs I'm dealing with,
* Resolution is 720x480. Intended aspect ratio is 4:3
* It is not telecined. It is shot and meant to be displayed at 29.97 fps.
* I may need to crop out couple lines on left and right to trim off noise/black borders.
So for the sequence I'm looking at: deinterlace > crop > resize.The final displayed image will never be 4:3 again.
Up to you, though.
trumpet205
17th June 2014, 00:18
This is purely for PC only. I'm aware that any cropping will distort the aspect ratio. Cropping is really not a big deal to me (getting rid of anamorphic is).
I cut out a 15 seconds test clip (no audio),
https://www.dropbox.com/s/evo5ytpo4p3i170/clip.mkv
LemMotlow
17th June 2014, 03:45
This is purely for PC only. I'm aware that any cropping will distort the aspect ratio. Cropping is really not a big deal to me (getting rid of anamorphic is).
I cut out a 15 seconds test clip (no audio),
https://www.dropbox.com/s/evo5ytpo4p3i170/clip.mkvHm, It seems this thread is confusing me. I thought you were talking about DVD's. Your sample isn't DVD. It's an mkv with a 10:11 pixel aspect ratio and 4:3 DAR -- the same image and playback ratios as DVD. Something has happened to fine detail and textures, there's some aliasing, it looks seriously over filtered, and the colorspace has gone really red. Maybe I missed something, so I'll just hang back and try to keep up. Not really sure what you're doing, though.
Guest
17th June 2014, 03:49
@trumpet205
Please tell us where you got your source stream. Thank you.
trumpet205
17th June 2014, 03:50
Hm, It seems this thread is confusing me. I thought you were talking about DVD's. Your sample isn't DVD. It's an mkv with a 10:11 pixel aspect ratio and 4:3 DAR -- the same image and playback ratios as DVD. Something has happened to fine detail and textures, there's some aliasing, it looks seriously over filtered, and the colorspace has gone really red. Maybe I missed something, so I'll just hang back and try to keep up. Not really sure what you're doing, though.
I don't know what to tell you. My sample is indeed a DVD, ripped from MakeMKV. I then use mkvtoolnix to cut a 15 seconds clip from it.
My source is an official DVD for a Taiwanese TV drama, imported from Taiwan Pchome website.
Guest
17th June 2014, 03:54
Well, it's deinterlaced and hard-subbed, which raises red flags. Please tell us the link where you got the DVD. If you can do that we'll let it stand. Thank you for your understanding.
trumpet205
17th June 2014, 03:57
Well, it's deinterlaced and hard-subbed, which raises red flags. Please tell us the link where you got the DVD. Thank you.
Hardsubbed is actually common for Taiwanese TV drama (even the TV broadcast is hardsubbed)
Link (in Chinese): http://global.pchome.com.tw/prod/DNAA1P-A41888748?q=/S/DNAA1P
Guest
17th June 2014, 04:00
Thank you. All is OK to proceed.
But I am confused now too. You said it is anamorphic and needs deinterlacing. But neither of those are true. What exactly do you want to do with this clip and why?
LemMotlow
17th June 2014, 04:02
I don't know what to tell you. My sample is indeed a DVD, ripped from MakeMKV. I then use mkvtoolnix to cut a 15 seconds clip from it.
My source is an official DVD for a Taiwanese TV drama, imported from Taiwan Pchome website.I don't know what to tell you either. However, I do know that what you submitted is not an unprocessed sample of your original source.
Guest
17th June 2014, 04:06
@trumpet205
Did you give us the unprocessed source or did you do some filtering/re-encoding?
trumpet205
17th June 2014, 04:08
I'm confused here too. Mediainfo indicates the video has a pixel resolution of 720x480, so that is not 4:3 by default. Plus it also indicates the video is interlaced.
No re-encoding done at all. The clip I gave you is indeed from unprocessed source.
Reel.Deel
17th June 2014, 04:13
@trumpet205
For badly deinterlaced footage try daa with nnedi3:
Function daa(clip c) {
nn = c.nnedi3(field=-2)
dbl = mt_average(selecteven(nn),selectodd(nn),U=3,V=3)
dblD = mt_makediff(c,dbl,U=3,V=3)
shrpD = mt_makediff(dbl,dbl.removegrain((width(c)>1100) ? 20 : 11),U=3,V=3)
DD = shrpD.repair(dblD,13)
return dbl.mt_adddiff(DD,U=3,V=3)
}
daa performs rather well with this type of (badly deinterlaced) footage. The only downside is that the subtitles were added after deinterlacing so daa blurs fine lines in the subtitles were anti aliasing is not needed. Would be neat to mask the subtitles and only process the rest. Unfortunately I'm not quite there yet. :)
Guest
17th June 2014, 04:19
The encoding is interlaced, but the *content* is (badly) deinterlaced. Try Reel.Deel's suggestion if your goal is to fix the aliasing.
For upscaling or aspect ratio conversion, just use any resize filter you like.
What are you actually trying to accomplish?
trumpet205
17th June 2014, 04:33
Ultimately, I want to resize it into a 4:3 resolution, so closest would be 720x540 or 640x480.
Basically I'm working out an Avisynth script, then use it with x264 to re-encode into H.264. I will look into daa.
Guest
17th June 2014, 04:52
You're trying to make a PAR of 1:1? Looks like you want to resize to 654x480. Use any resize filter that you like.
(10 / 11) * 720 = ~654
For example:
lanczosresize(654,480)
652 may be better as it is divisible by 4.
colours
17th June 2014, 09:56
The bottom field is significantly blurrier than the top field so the correct way to fix this is to keep the top field and reinterpolate the bottom field (what nnedi3(field=1) does), then do something to make sure the subtitles/logo don't get too badly munged.
FFVideoSource("O:\clip.mkv")
orig = last
assumetff().separatefields()
top = selecteven()
bot = selectodd()
bot2 = top.mt_convolution("1", "0 1 1", u=3, v=3)
diff = interleave(blankclip(top, color_yuv=$808080), mt_makediff(bot, bot2, u=3, v=3)).assumetff().weave()
fixed = mt_adddiff(orig.nnedi3(field=1), diff, u=3, v=3)
fixed
crop(4, 0, -4, 0)
spline36resize(648, 480, 1, 0, -1, 0)
It's a bit of a hack, but it works kinda okay.
Edit: This produces less ringing on the subtitles. Replace clense() with clense(reduceflicker=false) if you're not using RgTools (https://github.com/tp7/RgTools).
FFVideoSource("O:\clip.mkv")
orig = last
assumetff().separatefields()
top = selecteven()
bot = selectodd()
bota = top.mt_convolution("1", "0 1 1", u=3, v=3)
botb = orig.nnedi3(field=1).assumetff().separatefields().selectodd()
botc = raveragew(bot, 1, bota, -1, botb, 1)
botfixed = interleave(bot, botb, botc).clense().selectevery(3, 1)
fixed = interleave(top, botfixed).assumetff().weave()
fixed
crop(4, 0, -4, 0)
spline36resize(648, 480, 1, 0, -1, 0)
It still doesn't properly handle subtitle combing (e.g. frame 52), but it shouldn't be hard to make a mask for that.
foxyshadis
17th June 2014, 10:00
I can't read traditional very well, but it looks silly. :p
For future reference, just cutting off some of the VOB, audio and all, or demuxing the m2v in dgindex, is the preferred way to get samples. Remuxing in mkv can slightly change the bitstream (although that's not important in this case), but mostly just because lots of people have uploaded completely re-encoded samples in the past.
Edit: colours already gave a better idea, forget mine.
LemMotlow
17th June 2014, 17:21
I played with the mkv sample while another project is running. Other than the neat idea posted earlier by colours (I didn't have time to try it), I used Sangnom and resizing to help with the jaggies. It didn't clear up the shimmer and twitter of edges in motion, of course. The mkv's color is pretty awful -- it's YUY2 (How did that happen? DVD is YV12). Colors, levels, etc., modded with Avisynth and VirtualDub. Many brights in the original are clipped. We really don't know what the DVD original looks like, so this exercise is academic at best.
Top image: frame 15 of the mkv. Lower image: cleaned up a bit and resized to 640x480.
http://forum.doom9.org/attachment.php?attachmentid=14243&stc=1&d=1403021542
http://forum.doom9.org/attachment.php?attachmentid=14244&stc=1&d=1403021578
Comparing the original edge jaggies (upper image) with the new version (lower). 200% blowup.
http://forum.doom9.org/attachment.php?attachmentid=14245&stc=1&d=1403021607
Reel.Deel
17th June 2014, 17:34
it's YUY2 (How did that happen? DVD is YV12)
No it's not, the sample he uploaded is indeed YV12.
LemMotlow
17th June 2014, 17:43
Whatever. Avisynth info() gave me YUY2 and wouldn't run YV12 plugins. No problem setting it to YV12, though. Maybe DirectShowSource and other source openers had a problem with it, but TMPGEnc Mastering Works decoded it to lossless YV12 correctly.
And since I went thru the trouble of getting a video out of it, here's a link. Far from perfect, but viewable. Sure wish we had a piece of the source, though. mp4 progressive, ~7 MB.
(new link) https://www.mediafire.com/?r4tjy4gc6k83tum
Guest
17th June 2014, 17:45
resized to 640x480 That's too much. You can see from the logo that it is squished horizontally at 640x480.
LemMotlow
17th June 2014, 18:02
And it looks cropped -- i.e, a little "close" to the camera. But it was a quickie and was already on hand. I can only imagine what the original looks like.
According to my calculator, though, 640 / 480 = 1.33333333, but 648 / 480 = 1.35. So how should 1.33333:1 be sized as square pixel from non-square 720x480? I saw 648x480 posted earlier, but I think I missed the calculation. Would be handy to have the correct formula.
Guest
17th June 2014, 18:08
I gave it to you already. Re-read my post.
In the absence of any definitive proof, I ask you to stop making accusations against the OP. He has done all we require to show legitimacy. Follow up to PM if needed. Thank you.
Guest
17th June 2014, 18:13
Whatever. Avisynth info() gave me YUY2 and wouldn't run YV12 plugins. No way. Info() shows YV12 serving with a DGDecNV project. Anyway, DGDecNV won't open it if it is not YV12! You must have used DirectShow or something that converts the color space.
wonkey_monkey
17th June 2014, 18:15
The correct method - dependent on the DVD having been mastered correctly, which this one appears to have been - is to crop to 704x480 and then resize to a 4:3 image (640x480 or 704x528 - though before that you could try the things others have suggested to clean up the aliasing).
You crop because of those blurry black edges to the picture - those parts aren't meant to be considered part of the picture for display.
http://en.wikipedia.org/wiki/Nominal_analogue_blanking
Guest
17th June 2014, 18:18
The correct method It's the correct way only if you *require* a width of 640 or 704. Resizing directly to ~652x480 also gives a 1:1 PAR.
LemMotlow
17th June 2014, 18:24
Nope, not trying to hit on the O.P. on that, just reporting the problem I encountered. How TVMW5 got it right is...???, but I had no probs with the Lagarith AVI it created.
Thanks for the formula. I just didn't scroll back far enough. Will keep it around.
Deleted the old link. New link (652x480): https://www.mediafire.com/?r4tjy4gc6k83tum .
And thanks to David for more notes. Will look up my original script later. Did something wrong somewhere. Nothing new there.
:thanks:
wonkey_monkey
17th June 2014, 18:30
It's the correct way only if you *require* a width of 640 or 704. Resizing directly to ~652x480 also gives a 1:1 PAR.
Yes, that does give you the right PAR, but not a 4:3 DAR. Playback on a 4:3 screen (if anyone still has one) for example, could be compromised slightly by this, and you might end up with borders top and bottom. The 8 pixels either side aren't "supposed" to be viewed. Ever. By anyone!
Makes me wonder what we're not supposed to be seeing... :cool:
osgZach
18th June 2014, 05:35
Yes, that does give you the right PAR, but not a 4:3 DAR. Playback on a 4:3 screen (if anyone still has one) for example, could be compromised slightly by this, and you might end up with borders top and bottom. The 8 pixels either side aren't "supposed" to be viewed. Ever. By anyone!
Makes me wonder what we're not supposed to be seeing... :cool:
If the intended display device is a 4:3 TV I'd just leave the thing at 720x480 and flag its DAR properly. As long as the playback hardware is respecting it, should be fine no?
Even for PC playback (OP on Page 1) I would think this should be fine with any decent player as long as the file is properly flagged.
LemMotlow
18th June 2014, 17:36
Yep, sticking with the standards is the best way, and the least destructive. It will ensure correct playback with almost all devices. PC media players like VLC Player and MPC-BE have controls for aspect ratio if things look weird but they usually figure things out correctly. Something like Windows Media Player is a toss-up, and some versions of WMP don't respect DAR flags.
Guest
18th June 2014, 17:40
Point taken, but OP was talking about upscaling too.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.