View Full Version : Three questions about scaling and deinterlacing.
Vilx-
1st June 2011, 10:58
Hi all! :) I've just made my first steps into the arcane world of DVD ripping, so, naturally, I've got some questions.
Lyrical intro:
For some time now my infant daughter has taken interest in my Peanuts DVD's, so they're being watched rather often. Lately I noticed that they are showing considerable wear, and some even have tiny cracks in the middle. Not extending to the data areas yet, but such things tend to spread.
Since those DVDs are quite precious to me and my wife (and cost us money that we don't have right now if they break), I decided to rip those movies to H.264 and put the original discs away.
Now, there are plenty of one-click ripping solutions, but being of a geeky background I decided that I want to do things the proper way and squeeze every (reasonable) bit of quality possible in these rips. After consulting with a slightly more experienced person at a local forum, and spending some time with Google, I arrived at the toolchain DVD Decrypter -> AviSynth -> MeGUI.
Fast forward a few days and I had two rips on my hands. After looking at them with slight confusion and then showing them to my wife who confirmed my suspicions, I found out that DVDs have non-square pixels. Joy. Also the videos were interlaced, so I had to deinterlace them. The default Yadif deinterlacer still gave noticeable artifacts, so I googled more and found a solution with nnedi3+yadif (http://forum.videohelp.com/threads/313797-Best-deinterlace-method). This produced flawless effects (as far as I could see), but there were still some oddities. Hence I dug forward and learned about Telecine (http://mod16.org/hurfdurf/?p=12). More joy. And so we arrive to
The questions:
The DVDs are in PAL. Hence they are in the 720x576 resolution. The DAR is 4:3. Now I have two choices - I can upscale them to 768x576 or I can downscale them to 720x540. Which one should I choose? Arguments that I can think for each: Downscaling would be less CPU intensive (both when downscaling and when encoding to H.264) and would keep the crispiness of the image; Upscaling would make the image slightly blurrier, but when I watch the videos (on PC only) they are upscaled anyway, so this might provide a better final quality (since my player would need to do less upscaling with its fast-but-less-perfect upscaling algorithm)Is there some widely accepted best practice here? Are there any other considerations that put one choice above the other? Or is this purely a matter of taste? Which up/down-scaling algorithm to choose? I've researched this before (http://stackoverflow.com/questions/384991/what-is-the-best-image-downscaling-algorithm-quality-wise/6171860#6171860), and Lanczos is probably the way to go, but just in case I've missed something - is there anything better or more suited to animation? I'm putting more emphasis on quality than encoding time - I have time. The interlacing on the videos is... peculiar. It's like only every second frame is interlaced. At least that's the preview I get in MeGUI for the raw stream (obtained from AviSynth with DGMPGDec). I'm not sure if providing screenshots would violate copyright so I'll stay on the safe side. After deinterlacing with the above mentioned nnedi3+yadif the effect in scenes with high motion is that like in every even frame the character moves, and in every odd frame the background moves (while the character stays still). Now, this smells like Telecine, but what pattern? And how do I properly inverse-Telecine it? Or should I ignore it, since when playing the movie this is unnoticeable anyway?
Motenai Yoda
1st June 2011, 15:42
1 - pratically all screens / TVs have different resolutions (ie 1024x768, 1280 × 800, 1440 × 900, etc.), so is nonsense choose a res to avoid scaling on playing. Generally make an anamorphic video (the source video should be only cropped, noway scaled) or a downscale should be the best choice. According to the target size and the video's compressibility.
2 - Blackman is the best for downscaling film, while Spline16 or Spline36 are the most appropriate for anime content (spline36 seems to be slightly sharper and squeezable than Blackman/Lanczos), for upsampling nnedi3 with abs. Also, to increase comprimibility on film a qmlf can be used.
3 - do proper deinterlacing or IVTC is required. try tfm/telecide w tdecimate for ivtc.
Temuthril
1st June 2011, 16:14
The DVDs are in PAL. Hence they are in the 720x576 resolution. The DAR is 4:3. Now I have two choices - I can upscale them to 768x576 or I can downscale them to 720x540. Which one should I choose? You could encode with the resolution the DVD is in (720x576, to avoid needless resizing), and set the aspect ratio in the container when muxing.
Check the following links:
http://ps-auxw.de/cgi-bin/ar-calc.pl
http://tinyurl.com/48mkye3
http://www.doom9.org/index.html?/aspectratios.htm
Vilx-
1st June 2011, 19:32
1 - pratically all screens / TVs have different resolutions (ie 1024x768, 1280 × 800, 1440 × 900, etc.), so is nonsense choose a res to avoid scaling on playing. Generally make an anamorphic video (the source video should be only cropped, noway scaled) or a downscale should be the best choice. According to the target size and the video's compressibility.
You could encode with the resolution the DVD is in (720x576, to avoid needless resizing), and set the aspect ratio in the container when muxing.
Well... that's an idea... I didn't know you could do this, but OK. Kinda makes sense - scaling only happens once. I had thought that pre-scaling with a much better (and slower) algorithm would produce better final result.... but does it?
2 - Blackman is the best for downscaling film, while Spline16 or Spline36 are the most appropriate for anime content (spline36 seems to be slightly sharper and squeezable than Blackman/Lanczos), for upsampling nnedi3 with abs. Also, to increase comprimibility on film a qmlf can be used.
3 - do proper deinterlacing or IVTC is required. try tfm/telecide w tdecimate for ivtc.
OK, will check those out.
manono
2nd June 2011, 11:00
Small samples are OK under fair use laws. Since, from your description, the interlace pattern seems peculiar, a short 10 second sample, one with steady movement, might be helpful. As it's PAL, the fact that there's any interlacing at all makes me suspicious. It's most likely poorly converted from NTSC is my guess. If correct, just deinterlacing it isn't the optimal solution. An IVTC almost certainly isn't called for. But only a sample can tell us what you have and how best to treat it.
Cut using DGIndex (the [ and ] buttons followed by File->Save Project and Demux Video). Upload the resulting M2V to MediaFire or Sendspace and give us the link.
Vilx-
2nd June 2011, 11:20
Argh! Read some more, and now I'm totally confused. So PAL actually only uses the center 704px from all the 720px? And then the 704x576 picture should be shown as a 4:3 image? Or is it the 720x576 that has the 4:3?
To put it in other words, how do I need to scale my 720x576px 4:3 PAL source video in order to get a video with square pixels? (Mind you, the pixels on the sides aren't black or noise, they are image info too. There's only a 4px black bar on the left. So I'd like to keep them)
Working on a preview now, will post soon.
Vilx-
2nd June 2011, 11:40
Is it OK if I upload to my own server? Here's the link (http://valts.21.lv/problem/SnoopySample.m2v) (9.8MB).
I stumbled upon some even more weirdness. Some frames were like partially interlaced or something. Check it out:
In the beginning, where the car moves, it's like the whole scene is interlaced. So far so good. This also keeps up a bit when the view shifts to indoors. But at the end, where the buttler gives you the book, it's like only every other frame was interlaced. And in between there are frames where the background is interlaced in every frame, while the hand on the foreground is interlaced only for every other frame.
Temuthril
2nd June 2011, 12:52
To put it in other words, how do I need to scale my 720x576px 4:3 PAL source video in order to get a video with square pixels? (Mind you, the pixels on the sides aren't black or noise, they are image info too. There's only a 4px black bar on the left. So I'd like to keep them)Use the aspect ratio calculator in the first link. If you crop the 4 pixels wide black from the left, it'll be like this:
http://tinyurl.com/3usqscf
Motenai Yoda
2nd June 2011, 13:23
or http://www.mediafire.com/?airxmp5qrtcbw2j
try tdeint(tryweave=true)
Vilx-
2nd June 2011, 13:43
Hmm... The explanation page (http://lipas.uwasa.fi/~f76998/video/conversion/) makes lots of sense. I'll try figuring out the calculator later at home, when I can trace the numbers along as I do the maths myself. Anyways, if 702x576 is the actual active frame size, which should be displayed as 4:3, then it's easy even without the calculator. And I think I will resample it to get square pixels too, just to keep things simple with these videos afterwards.
The question of "upscale vs downscale" is still active however (I'm leaning towards upscale), as is the peculiar interlacing. Anyone seen that before?
manono
2nd June 2011, 13:47
It's screwy, as I thought, but not the way I thought. It's not interlaced but only field-shifted. The fields are out of alignment. A simple:
TFM()
realigns them (aka field-matches them, the 'FM' in 'TFM') without damaging it the way a deinterlacer, no matter how good, might do. TFM is part of TIVTC which can be found here, among other places:
http://avisynth.org/warpenterprises/
Vilx-
2nd June 2011, 14:23
Wow, looks real nice! Kudos to you, manono! :)
Btw - I gather the places where the motion is only in every other frame are intentional, right?
Oh, and another thing - how did you arrive at this conclusion? I'd like to get some knowledge about such problems, so that I don't have to bother you with every interlaced video I come across.
manono
2nd June 2011, 15:51
Btw - I gather the places where the motion is only in every other frame are intentional, right?
Yes, intentional. Animations are rarely drawn at 24fps all the way through. More often they're 16, 12, or even 8fps. At 8fps each frame is shown 3 times. I'm speaking of the film sources. Ordinarily for PAL it's just speeded up so the frame count remains the same.
Oh, and another thing - how did you arrive at this conclusion?
As soon as I saw it I was pretty sure what was going on. But just to be sure I bobbed it (using Yadif in bob mode) and saw that each field was shown twice. That opening part of the sample with the car where every frame is interlaced, bob it and you'll easily see what I mean. Separating the fields or bobbing the video is often good practice when something's not exactly right. Doing that can make it easier to tell what's going on.
Vilx-
8th June 2011, 14:03
Not to make a new thread - so far I've successfully ripped 3 DVDs and 4th is encoding as I write this. For deinterlacing I've had constant success with a simple TFM() call in all cases. Does this mean that all of those movies had been mangled the same way? Or could it be that TFM() always returns a seemingly-deinterlaced movie, which might actually not be correct?
manono
8th June 2011, 18:04
If it's not interlaced, don't deinterlace it (although using TFM won't damage anything usually, but only slows the encoding). Use your eyes to tell what you have and not some app that can only tell you how it was encoded, a different thing entirely.
Vilx-
8th June 2011, 23:56
Of course, that goes without saying. I mean, for the 3 (of 6 total, so far) movies that were interlaced, I used TFM() and the result looked good, even when I checked it frame-by-frame for a couple of frames with high action. Does this mean that I've successfully unmangled them the right way? (Note: I avoid calling it deinterlacing or IVTC on purpose, because this is neither, as I understand it)
manono
9th June 2011, 00:56
Does this mean that I've successfully unmangled them the right way?
Without samples from the untouched source, I wouldn't know.
smok3
9th June 2011, 08:03
looking at your sample, about cropping only: there seems to be some black on the left and some chroma problems on the right, so i would crop 8px on the left and 8px on the right and encode with sar x264 --sar 547:500.
http://resizecalc.sourceforge.net/index.php?ssmw=720&sar=1.094&sar2=&ssmh=576&CT=&CL=8&CR=8&CB=&mplayCrop=&trw=704&dar=1.094&dar2=&modw=&modh=&padw=&padh=&css=&doit=true
p.s. also, when basic yadif fails misserably, then you know its not really interlacing/deinterlacing problem.
SilaSurfer
11th June 2011, 17:38
Blackman is the best for downscaling film, while Spline16 or Spline36 are the most appropriate for anime content (spline36 seems to be slightly sharper and squeezable than Blackman/Lanczos)
@Montenai Yoda
How many taps do you use with Blackman when downscaling. I'm testing diffrent resizers right now and I'm interested in Blackman.
Vilx-
30th June 2011, 10:03
I'm afraid I have to ask for help once more. :( Here's the sample (http://valts.21.lv/problem/SnoopySample2.m2v). This already smells like a proper telecine to me, because most frames are interlaced, but every now and then there's an uninterlaced frame too (even in high motion). TFM() resulted in a jerky movement (IMHO).
Ghitulescu
30th June 2011, 10:38
The series were originally NTSC. If you insist in deinterlacing them, then consider reading about NTSC->PAL conversions, too. There are extremely scarce infos about its original format, so I assume it was first telecined then converted to PAL.
If the DVDs were so important (costly) to you, why don't you do first a 1:1 copy? This way you'll be on the safe side, you can always reconstruct it, you know, in the case of God forbid!
Your infant daughter is really a genius if she could recognize a 6% PAR distorsion on cartoons (which by default distort the reality). Before doing however any rescaling, make sure whether the player supports or not other PAR/DAR than 1:1 (quadratic pixels). If the player supports it then you don't have to do any scaling, leave the frame size as it is (720x576) and set the PAR/DAR in the container (I assume MKV).
Vilx-
30th June 2011, 11:08
I already said that I want to play them on a PC with VLC, so there are virtually no player limitations of any kind.
Yes, I could do a 1:1 copy, but then I'd be stuck with a set of disks that I have to swap in and out all the time, which is annoying me. I also don't have the HDD space to store 8 DVD's. Unfortunately. Plus, this is a chance to learn something new. :)
I might still end up doing a 1:1 copy of them all, but for everyday viewing this is the more comfortable format. The deinterlacing can also be done much better at this stage (where I can customize the process) than at playback with VLC's generic algorithms. On the scaling side you might be right, the visual differences between doing it now and doing it with VLC at playbacktime are probably imperceptible. However I hate the abominable idea of non-square pixels. :D
Ghitulescu
30th June 2011, 13:31
I already said that I want to play them on a PC with VLC, so there are virtually no player limitations of any kind.
Oh, yes, make sure at least to set the refresh rate of the monitor (and implicit of the graphic card) to a multiple of the fps. Or consider the use of MPC-HC with madvr or any other solutions that enable you to avoid fps change during playback (for instance, your PAL source has 25fps but the monitor uses 72Hz, guess what happens :)).
The deinterlacing can also be done much better at this stage (where I can customize the process) than at playback with VLC's generic algorithms. On the scaling side you might be right, the visual differences between doing it now and doing it with VLC at playbacktime are probably imperceptible. However I hate the abominable idea of non-square pixels. :D
As I said, try first to reverse the NTSC->PAL conversion using a method that suits best your material.
And you should avoid inkjet printers as well, they also have non-square pixels. :)
Vilx-
30th June 2011, 14:45
I do avoid inkjet printers. But mostly because I have nothing to print. :D OK, so maybe the resizing is pointless, but you can't say that deinterlacing/detelecining/de-whatever-ing the movie is also pointless!
Anyways, what's this about NTSC->PAL? Isn't the only difference (for digital videos) in resolution and fps? I already said that I don't care about the resolution conforming to some kind of standards, but would rather have as many pixels as are available. And the FPS in this case pretty much depends on the deinterlacing process. If it yields a 24-fps deinterlaced material from a 25fps interlaced material - I'm fine with that. As long as the actual length (time-wise) of the movie stays the same and the sound still syncs to the picture. But in the end - I don't care what FPS my movie has. It plays smoothly in any case.
Ghitulescu
30th June 2011, 15:25
I do avoid inkjet printers. But mostly because I have nothing to print. :D OK, so maybe the resizing is pointless, but you can't say that deinterlacing/detelecining/de-whatever-ing the movie is also pointless!
I haven't say any of these.
I've said that resising is counterproductive if the player can obey the DAR/PAR flags.
And I've said try first to restore the video back to NTSC, not perform a deinterlacing.
Anyways, what's this about NTSC->PAL? Isn't the only difference (for digital videos) in resolution and fps? I already said that I don't care about the resolution conforming to some kind of standards, but would rather have as many pixels as are available. And the FPS in this case pretty much depends on the deinterlacing process. If it yields a 24-fps deinterlaced material from a 25fps interlaced material - I'm fine with that. As long as the actual length (time-wise) of the movie stays the same and the sound still syncs to the picture. But in the end - I don't care what FPS my movie has. It plays smoothly in any case.
Deinterlacing a bad NTSC->PAL transfer could make the things worse.
I think there are people here that know better than me how to convert back to NTSC. They could help you further.
BTW, deinterlacing should not change the fps. If something changes your fps than it's not deinterlacing but another method -> http://www.doom9.org/ivtc-tut.htm.
Vilx-
30th June 2011, 21:55
I don't quite follow you about the NTSC. Why would I bother resizing the picture back to NTSC? And why should I do it before de-interlacing/-telecining/-whatever?
P.S. Since we're on the next page, for those who missed it, I'm asking for help with deinterlacing this video (http://valts.21.lv/problem/SnoopySample2.m2v).
poisondeathray
1st July 2011, 00:52
P.S. Since we're on the next page, for those who missed it, I'm asking for help with deinterlacing this video (http://valts.21.lv/problem/SnoopySample2.m2v).
This doesn't need to be deinterlaced, it's progressive content, just field shifted
MPEG2Source()
AssumeTFF()
TFM()
Vilx-
1st July 2011, 08:42
Hmm... well, if you say so. Somehow it didn't look good to me yesterday... but today I can't find what the problem was. :P OK, will encode like this. :)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.