VideoHelp Forum




+ Reply to Thread
Results 1 to 13 of 13
  1. Member
    Join Date
    Jan 2007
    Location
    United Kingdom
    Search Comp PM
    hello everyone

    I have a question regarding cropping and encoding interlaced video. I am capturing interlaced signal from a Hi8 camcorder and obviously there's some junk on all sides. I crop it and optionally resize (for fullscreen, since MPEG2 supports only a few pre-defined resolutions). the question is, how does it affect interlace (1) and MPEG encoder (2). AFAU, there are several scenarios. lets outline a couple:

    1. the image is cropped and then upscaled to full DVD resolution. this is simple for horisontal scale, but non-obvious for vertical, since several lines have to be added. I don't understand how vertical upscale works with interlaced video. either pairs of fields are duplicated every now and then, which is not the best upscale algorithm, or the image is deinterlaced, upscaled, and then interlaced again, which is completely crazy and unbelievable. what does TmpgEnc or other encoder do when I choose crop+fullscreen ?
    2. back bands are created around the image. encoder will waste bandwidth encoding them and there will be artefacts near the edges. this is the scenario for crop+center AFAIU.

    It would be extemely helpful if someone answers these two questions and possibly recommends what interlace/crop/scale options of TmpgEnc I should use to make DVDs out of my Hi8 recordings. I guess black borders are the the least evil when compared to duplicated lines, but any advice from gurus will be appreciated.

    thanks very much in advance.
    Quote Quote  
  2. Always Watching guns1inger's Avatar
    Join Date
    Apr 2004
    Location
    Miskatonic U
    Search Comp PM
    Working backwards, less bandwidth is used encoding black borders than encoding video if you crop and resize back to full-D1. Depending on how much you intend to crop (and it should be minimal), the borders will be in the overscan area on most TVs, and won't be seen. Ergo, any video you put there will also be hidden from view. The question then becomes : is there any point to resizing back to Full_d1 if it is going to affect the image quality through the resize and the extra bitrate required, or is it better to crop and border with balck that no-one will see ?

    Manono is the man to speak to about cropping interlaced material, however from my perspective, I would not use tmpgenc to do it. Avisynth is faster and, should you choose to resize, will do a much better job.
    Read my blog here.
    Quote Quote  
  3. Hi-

    ...or the image is deinterlaced, upscaled, and then interlaced again

    Bingo.

    ...which is completely crazy and unbelievable

    Not if you want to do it right, it's not. Using AviSynth (in my opinion, not just one way to do it, not just the best way to do it, but the only way to do it):

    LoadPlugin("C:\Path\To\DGDecode.dll")
    LoadPlugin("C:\Path\To\LeakKernelDeint.dll")
    MPEG2Source("C:\Path\To\Video.d2v") #or AVISource if an AVI
    AssumeTFF()#if TFF, Assume BFF() if BFF
    LeakKernelBob(Order=1)#if TFF, Order=0 if BFF
    #Crop, Resize, AddBorders, or other filtering here
    AssumeTFF()# if TFF, Assume BFF() if BFF
    SeparateFields()
    SelectEvery(4,0,3)#if TFF, SelectEvery(4,1,2) if BFF
    Weave()
    ConvertToRGB24(Interlaced=True)#for TMPGEnc

    and encode for Top Field First. If it's BFF originally, and you want to encode as BFF, then that last SelectEvery line is SelectEvery(4,0,3)
    Quote Quote  
  4. Member
    Join Date
    Jan 2007
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by guns1inger
    The question then becomes : is there any point to resizing back to Full_d1 if it is going to affect the image quality through the resize and the extra bitrate required, or is it better to crop and border with balck that no-one will see ?
    I see your point. for TVs you are obviously correct, but I wanted to have an DVD that would look nice on PCs as well. I know, it's just black borders, but I really hate those artefacts that appear on the edge. I'd rather use some bandwidth to encode several more lines.

    Originally Posted by guns1inger
    Manono is the man to speak to about cropping interlaced material, however from my perspective, I would not use TMPGEnc to do it.
    and the reason being ? AFAICS, it is just a matter of throwing several lines away, how can this be done wrong by any software ? please explain.
    Quote Quote  
  5. Always Watching guns1inger's Avatar
    Join Date
    Apr 2004
    Location
    Miskatonic U
    Search Comp PM
    and the reason being ? AFAICS, it is just a matter of throwing several lines away, how can this be done wrong by any software ? please explain.
    See Manono's post (above). There is certainly nothing stopping you from cropping and resizing in tmpgenc. Just as there is nothing stopping you walking blind-folded across a busy road. It may not be the best way to do things though.

    My understanding is that cropping is not a major issue, however resizing interlaced material is a problem as the interlacing can become fritzed, leading to shimmering and other artifacts. Again, Manono can probably give you much better technical reasons than I can. I do know that tmpgenc's resizing is limited to very basic algorythms (bicubic and bilinear, if that), whereas Avisynth also has Lanczos andLancsoz4, which for upscaling, producing much crisper results.
    Read my blog here.
    Quote Quote  
  6. Member
    Join Date
    Jan 2007
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by guns1inger
    and the reason being ? AFAICS, it is just a matter of throwing several lines away, how can this be done wrong by any software ? please explain.
    See Manono's post (above). There is certainly nothing stopping you from cropping and resizing in TMPGEnc. Just as there is nothing stopping you walking blind-folded across a busy road. It may not be the best way to do things though.
    sorry for not making myself clear, but in previous post I mean just cropping in TMPGEnc, no resizing at all, for whatever reason.

    yes, I saw Manono's post. I am thinking about it. 8)
    Quote Quote  
  7. AFAICS, it is just a matter of throwing several lines away, how can this be done wrong by any software ? please explain.
    In order to preserve the data structure of the different colorspaces, the following mods should be used (when cropping). You will not get an error message if they are not obeyed, but it may create strange artifacts.

    In RGB:
    width no restriction
    height no restriction if video is progressive
    height mod-2 if video is interlaced

    In YUY2:
    width mod-2
    height no restriction if video is progressive
    height mod-2 if video is interlaced

    In YV12:
    width mod-2
    height mod-2 if video is progressive
    height mod-4 if video is interlaced
    http://www.avisynth.org.ru/docs/english/corefilters/crop.htm

    Do you know the rules regarding interlaced cropping for the various colorspaces? Do you know what colorspaces are? Believe me, it's very easy to screw up the cropping unless you're aware of these things. And you're not just cropping, but resizing, and things get even more tricky unless you're very careful. That's why it's best to not do these things to the interlaced frame, not even to the separated fields, but do them to a SmartBobbed (Deinterlaced) frame, before reinterlacing. TMPGEnc is incapable of doing these things.
    Quote Quote  
  8. Member
    Join Date
    Jan 2007
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by manono
    Do you know the rules regarding interlaced cropping for the various colorspaces? Do you know what colorspaces are?
    yes sir, indeed I know ! 8)
    and if I store my raw video in YUY2 and keep crop values mod 2, I can't see what can go wrong with it. can you ? 8)

    another reply later.
    Quote Quote  
  9. No, if you are in YUY2, and crop Mod2, then nothing can go wrong. However, TMPGEnc uses RGB24, and will convert to RGB24 itself, if you haven't done it already, like in an AviSynth script. To be honest, I don't know the quality of the TMPGEnc colorspace conversion, and haven't read anything about it, either for or against. If all you do is add black after the crop, to fill out the 720x480 frame, then nothing can go wrong. But if you decide to resize, then all hell breaks loose (maybe).
    Quote Quote  
  10. Member
    Join Date
    Jan 2007
    Location
    United Kingdom
    Search Comp PM
    this is what I was talking about, I intentionally made two separate bullet points in my initial post. that's why I expressed doubt about crop+rescale. I am still thinking about it and will reply later.

    you are saying that you don't know about the quality of colorspace conversion in TMPGEnc, but are there any other decent free MPEG2 encoders ? I encoded a couple of short clips on medium quality setting ans was quite pleased. I am completely ignorant on the SW available. I guess I could try mencoder, but I never used its MPEG2 encoder.

    I could obviously try to do all the intermediate processing in RGB and then feed this to TMPGEnc, to prevent colorspace conversion.
    Quote Quote  
  11. Always Watching guns1inger's Avatar
    Join Date
    Apr 2004
    Location
    Miskatonic U
    Search Comp PM
    HCenc is faster than tmpgenc (although that isn't saying much - most mpeg2 encoders are) and produces very good quality output. It is also very good at lower bitrates, which may or may not be of interest. It does require avisynth to load the video files. John "FulciLives" Coleman wrote a pretty succinct guide to using it here -> https://forum.videohelp.com/viewtopic.php?p=1622800#1622800
    Read my blog here.
    Quote Quote  
  12. Hi-

    you are saying that you don't know about the quality of colorspace conversion in TMPGEnc,

    That's right, I don't know. I don't use it, so I never bothered to find out.

    If you go the HCEnc route, then it accepts YV12 input, so your interlaced height cropping should be Mod4 and you'll ConvertToYV12(Interlaced=True) instead. And if this is going to become a steady hobby of yours, then it's in your best interests to learn at least some AviSynth. To get started, try this page:

    http://www.neuron2.net/dgmpgdec/QuickStart.html

    For more about it, and the included filters you'll be using (Crop, AddBorders, Resize, etc.), then here:

    http://www.avisynth.org.ru/docs/english/syntax.htm

    For 3rd party add-on filters, such as when you need to IVTC, need the deinterlacer I used in the earlier script (LeakKernelDeint), or perhaps need to do some denoising/cleaning of one sort or another:

    http://avisynth.org/warpenterprises/

    Test your scripts in VDubMod before sending them to your encoder, to make sure they open, to make sure they do what you want them to do, and to report any errors with good error messages. And I second guns1inger's suggestion about HCEnc. It's an excellent MPEG-2 encoder.
    Quote Quote  
  13. Member
    Join Date
    Jan 2007
    Location
    United Kingdom
    Search Comp PM
    manono,

    thanks a lot for your script and other sugestions. I thought about the problem today and the only sane way of doing it, I think, is as follows:

    1. take interlaced frame (two fields);
    2. separate the fields. you get two images with half the vertical resolution;
    3. resize each field individually using good scale algorithm;
    4. combine the fields, interleaved to get the interlace back;
    5. you got the full-sized frame

    as long as you keep the vertical difference mod2, this should give the best quality result.

    afaics, deinterlace -> resize -> interlace cannot give such quality for the simple reason that once you combined the fields while deinterlacing, you loose some data and it is not possible to get it back. if you add A to B to get C, once you have just C, you can't get A and B back. this is oversimplified, of course, since good deinterlace algorithms are much more complex than addition. but still, until you double the framerate, the data is lost.

    so, what do you think, and what does your script do step by step ?
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!