1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why is my resized 352x240 AVI being encoded to 352x256 by Quenc?

Discussion in 'MPEG-1 and MPEG-2 encoding (AVI to DVD)' started by waltersbg, Mar 1, 2005.

  1. waltersbg

    waltersbg Member

    Joined:
    Feb 7, 2005
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    11

    I'm sorry if this question has been answered already. There is so much information out there in these forums and other forums that finding the right keywords to find your answer is sometimes a very difficult task. I have tried, however, before posting here.

    I'm pretty sure my head will explode soon with all the facts and opinions related to VHS to DVD capture, encode, and author. Aspet ratios, cropping, borders, resizing, encoding options, etc. There is a tremendous amount of information out there and it is hard to decypher it all.

    My current problem is relatively straight-forward, although it may turn out that I'm trying to do something that is unecessary or ill-advised.

    I am "capturing" DV-AVI via firewire. The incoming AVI is 720x480 29.97 fps.

    Since VHS has a much lower resolution than 720x480, I (perhaps mistakenly) assumed that resizing to 352x240 before encoding would result in a better looking mpeg for a given bitrate.

    I used avisynth to load the avi and used LanczosResize(352x240) to resize it. When I load the resulting .avs file into Quenc and use the "i" button to check the stats of the incoming file, it shows that it is 352x240.

    After encoding with Quenc (which, as far as I can tell doesn't have any re-sizing options built in), the resulting mpeg is not playable in WinDVD or WMP. Both of those programs play the audio but the video is just a black screen. When I open the file with Nero Showtime I get both audio and video and the detailed onscreen display shows that the mpeg is 352x256.

    So, my two issues are:

    -- Why is the resulting mpeg not playable in WinDVD or WMP? Quenc outputs that I don't resize play fine in these programs.

    -- Perhaps related to issue #1, why is the output of Quenc 352x256 instead of 352x240?

    Thanks,
    Mike
     
  2. rebootjim

    rebootjim Active member

    Joined:
    May 13, 2004
    Messages:
    2,630
    Likes Received:
    0
    Trophy Points:
    66
    Totally mistaken.
    Encode as-is, at the framesize you captured in.
    Deinterlace in avisynth.
    I have NO idea why quenc would screw up the video like that, unless there's something else in your script doing it.
     
  3. waltersbg

    waltersbg Member

    Joined:
    Feb 7, 2005
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    11

    jim:

    If this stuff was intuitively obvious to me, it'd be a lot easier. :)

    I was assuming that the artifacts that are visible in an mpeg compression come about because of the compression ratio. Thus, if I encoded my DV .avi into an mpeg with a 25000 kpbs bitrate, I'd see no compression and I'd see little, if any, artifacts.

    I'd like to use a compression ratio of about 10:1 when encoding the mpegs in order to fit about 4 hours on a DVD. This means I'll be using an average bitrate of about 2500 kbps. I will obviously see some artifacts in the result.

    In trying to figure out how to have the MINIMUM artifacts, my logic (apparently flawed) went like this:

    -- Since 720x480 is so much more resolution than the original VHS tape and since a normal TV can not dispaly this resoultion, why not resize the avi first?

    -- If I resize to 352x240, I shouldn't notice much, if any, difference on my TV. But, I will now have a file that is about 1/4 the size of the original 720x480 file.

    -- Given that I'm starting with a file that is 1/4 the size of the original, getting one hour to fit into about 1.1GB will require less compression than would be required to compress an hour of the original DV .avi to 1.1GB.

    -- Since I will be using less compression, there will be fewer artifacts. The fact that I compressed a lower resolution file will be OK, since my display (a TV) can't display the higher resolution anyway.

    Where is my reasoning faulty? Like I said, this would be a lot easier if it was intuitive for me.

    As far as Quenc encoding the the "wrong" size, I'll continue experimenting with that. Literally, the only things in my avisynth script are the loading of the DV-avi, a color space conversion to YV12 (to make Quenc happy), and a LanczosResize(352,240). And, like I said, when I click on the "i" button in Quenc, it reports the incoming .avi to be 352x240. It doesn't really matter what is going wrong, since you're telling me not to resize before encoding, but I'd like to understand what's going on.

    Thanks,
    Mike
     
  4. rebootjim

    rebootjim Active member

    Joined:
    May 13, 2004
    Messages:
    2,630
    Likes Received:
    0
    Trophy Points:
    66
    Bitrate = quality.
    Any time you lower bitrate, you lose quality.
    That said, avi bitrate is NOT directly connected to mpeg-2 bitrate.
    You can have a great avi, at 1500kbps, and make a good mpeg from it at 6000kbps.
    For DV sources, you should encode at the same aspect as you captured. The less resizing, the better. Resizing will drop quality, as much as cutting bitrate in half.
    VHS "resolution" is an interlaced source. You need to capture in at LEAST 640x480 to get full advantage of both fields. This isn't dvd spec, so capturing at 720x480 works better.
    No, it's NOT much more than VHS, and YES a TV does display 720x480 nicely (DVD spec is 720x480 @ 29.97), so if a DVD looks good on the TV, then obviously a high bitrate capture would do the same.
    Wrong. Aspect ratio has NOTHING to do with filesize. Bitrate, bitrate, bitrate. You're losing quality by resizing, and then having to resize again to dvd spec.
    Again, Captured DV avi bitrate has almost nothing to do with encoded mpeg-2 bitrate. You cannot compare, because of compression techniques.
    Your DV capture has far more compression than the equivalent running time of the same aspect ratio mpeg-2.

    If your source is extremely good quality, you can get away with an encoding bitrate as low as ~2500kbps and still get SVCD (or slightly better) mpeg-2 quality.
    This will give you about 3 hours and 40 minutes per dvdr.
    If you want to experiment, get tmpgenc, the Half D1 KDVD template, and get up to 16 hours on one dvdr at about SVCD quality.
     
  5. waltersbg

    waltersbg Member

    Joined:
    Feb 7, 2005
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    11

    jim:

    I'm willing to accept (mostly on faith at this point) that there is no benefit to resizing before encoding. I've seen a couple of DV-to-DVD guides which do recommend resizing, but I'm not sure of their reasoning or the expected tradeoffs. It'll be easy enough for me to try some things and see what looks the best.

    I'm also willing to accept that it was silly of me to compare "bitrate" of the original Dv-avi file to the bitrate of the encoded mpeg.

    That leaves me with just two things that I don't quite understand from your latest reply. You say:

    I understand that apsect ratio doesn't affect file size, but the example I was talking about was taking a 720x480 avi file and resizing it to 352x240. Certainly, the resulting file .avi size would be much smaller.

    Another thing that confused me a bit was when you said:

    I don't doubt that this is true, but I'm curious as to what things would make it possible to have a great AVI at 1500kbps. In order to have a great looking AVI at that low bitrate, wouldn't it require that something be "sacrificed" as compared to the DV standard of 720x480, 29.97 fps?


    I realize that this has all diverged a bit from my original question and I'm sorry for the number of iterations it takes for you to make me fully understand your points. As long as you have the time to answer, it seems like I learn a little more each time.

    Thanks,
    Mike

     
  6. rebootjim

    rebootjim Active member

    Joined:
    May 13, 2004
    Messages:
    2,630
    Likes Received:
    0
    Trophy Points:
    66
    I don't mind a bit, and hopefully some of this will make the odd light bulb a bit brighter ;)

    Nope. Doesn't matter if you're talking about avi or mpeg. Frame size has no bearing on file size. Bitrate is the only thing.
    Caveat: If you capture a smaller framesize (352x240) at the same bitrate, it's quality will be better (initially) because you are using the same amount of bitrate to encode the same amount of information, into half the viewing size. OK, the smaller framesize looks REALLY good! It is. Now encode to full D1 DVD, and it's now been resized to 720x480 (double the original), but still containing the same amount of information. You just lost about 50% of your quality.

    The avi at 1500kbps thing, is a compression issue. Use the right codec, with the right filtering, and the avi can be spectacular, without using a lot of bitrate. The same does NOT hold true for mpeg-2.
    eg. I capture an avi from DV Cam. I use virtualdub. I add the sharpen, deinterlace, levels, and HSV adjust filters, and the Picvideo mjpeg codec.
    I can get a pretty good looking avi at 1500kbps.
    I cap the same thing, in vdub, with no filters, using the DivX mpeg-4 low motion codec at 1500kbps and it will barely be watchable, with serious artifacts, and definitely not worth encoding to mpeg-2. In fact, I can do the same, with the same codec at 6000kbps, and it will still suck.
    Codec and compression combine to make either a good cap, or a poor one.
    Throw in a couple of resizes, and it all goes to crap.
    Try it.
     
  7. vurbal

    vurbal Administrator Staff Member

    Joined:
    Nov 30, 2002
    Messages:
    2,573
    Likes Received:
    1
    Trophy Points:
    66
    VHS definitely doesn't have information equivalent to full D1 resolution but being an analog format you can't really think in terms of resolution anyway. In general terms 352x240 may give you better quality at the same bitrate, but since it will be displayed on your TV I wouldn't go any lower than 352x480.
    Since I haven't ever used QuEnc I have no idea what it might be doing to your resolution but if you post your AviSynth script I'll take a look and see if I have any suggestions. Just a couple of things that come to mind for quality from DV are the codec used and whether you separate the fields before resizing.

    As far as codecs go they all have flaws. The MainConcept codec is the worst because it does a lot of sharpening. The Panasonic/Sony/MS codec doesn't sharpen as much but it is noticeable. The Canopus codec doesn't sharpen but it does have a bug that messes up the chroma pixels (which can be fixed in AviSynth) and also requires that you change the FourCC code from DVSD to CDVC (can be done with FourCC Changer which is freeware). When loading a file with the Canopus codec you need to use a line like this:
    For resizing you should do something like this:
    Since each field is only half the height of the whole frame you need to make y equal to half the intended vertical resolution. If you want a resolution of 352x480 it would look like this:
    I also used BilinearResize in the example instead of LanczosResize because it smooths the picture a little (making it easier to compress) while LanczosResize sharpens making it harder to compress.
     
  8. vurbal

    vurbal Administrator Staff Member

    Joined:
    Nov 30, 2002
    Messages:
    2,573
    Likes Received:
    1
    Trophy Points:
    66
    This is true but if you resize to 352x480 you wouldn't make a full D1 resolution DVD from it. You'd make a SIF DVD from it which wouldn't require changing the resolution. There would still be upsampling involved but that's because an NTSC TV has 480 scanlines which can have 720 different color changes per line. If you were to go with half D1 resolution (352x480) the quality would be much improved because the human eye is more sensitive to vertical resolution than horizontal. Additionally while the size isn't a product of resolution, reducing the resolution means more bits per pixel which will give you higher quality at low bitrates.

    There are also other important factors when it comes to encoding DV video. For one thing it has a lower chroma (color) resolution than most other formats. Compared to DVD or Divx it only has 1/4 as many pixels with chroma (color) information. It's also interlaced which requires a higher bitrate than a similar progressive stream would to achieve the same quality. Finally, if we're talking about a VHS source there's typically some extra movement added due to the nature of the mechanism in both the player and the tape which requires a higher bitrate.
     
  9. waltersbg

    waltersbg Member

    Joined:
    Feb 7, 2005
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    11
    vurbal:

    Thank you for your reply. It has taken me a couple of days to find the time to sit down and answer your questions fully.

    I've been figuring that out as I learn more about interlacing and TV resolution.

    I tried two different avisynth scripts that included the Lanczos resize to 352x240. One script was as simple as it could be. The other had field separations and convolutions. In both cases, however, I did the resize on the interlaced frames (not on each field separately) and I didn't set interlaced=true in the resize filter. What's odd about the whole thing, though, is that Quenc knew that I was feeding it a 352x240 avi and yet it produced a 352x256 mpeg. At any rate, here's the simple avisynth script:

    AVISource("Y:\DVD Projects\DV Captures\OSUvsCal.001.avi")
    ConvertToYV12 ()
    LanczosResize(352,240)

    The "ConvertToYV12" step is because Quenc will only accept input in YV12 format.

    In this example, I was using the Panasonic DV codec. I have no idea how I would know that if I had multiple DVSD-capable codecs installed on my system. As it is, I know that I could not use "AVISource" to open a DV-avi file until I installed the Panasonic codec and I have not knowingly installed any other DVSD codecs. Therefore, I'm assuming that I must be using the Panasonic codec when loading the avi into avisynth.

    Prior to installing the Panasonic codec, I had to use DirectShowSource to open the DV captures, in which case I assume that I was using the MS codec. I still have to use this method when trying to use DV captures that were done with NeroVision Epxress because of the issue that I discuss here:

    http://www.cdrinfo.com/Forum/tm.asp?m=100996

    Thanks,
    Mike
     
    Last edited: Mar 5, 2005
  10. shiroh

    shiroh Guest

    you can ask, Nic, the author, or the other regular user here.
    http://forum.doom9.org/showthread.php?s=efc1123b0498d7e842514f97d2d36fb8&threadid=84857

    i'm not sure what your problem is.
    the only problem i have with QuEnc is dancing blocks,in low detail areas, i need to add noise.

    you could try to encode it with other encoders, like HCenc or tmpg. if it still comes out 352x256, then it may not be quenc fault at all.
    use
    trim(0,250)
    and a 1pass encode.
     
  11. vurbal

    vurbal Administrator Staff Member

    Joined:
    Nov 30, 2002
    Messages:
    2,573
    Likes Received:
    1
    Trophy Points:
    66
    I just ran a quick test encoding using QuEnc 0.59 beta 2 downloaded from Afterdawn and encoded some DV using the Panasonic decoder and your script and got 352x240 output. I'd recommend opening up the AVS file directly with a VirtualDub and checking the File Information (from the File menu) to make sure it has the correct resolution before encoding. I can't imagine why it wouldn't, but that would be the next logical step.

    What version of QuEnc are you using and did you change any of the advanced options?
     
  12. waltersbg

    waltersbg Member

    Joined:
    Feb 7, 2005
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    11
    vurbal and shiroh:

    Thank you both for your feedback and sharing your experiences.

    I've finally figured out what was going on, thanks to your proddings and suggestions. It turns out that my original subject line, which "accused" Quenc of encoding to 352x256 was wrong. I feel so ashamed! :)

    As I said in my original post, the avi being passed to Quenc was 352x240. I took your advice, vurbal, and verified that by opening the .avs file in virtualdub.

    I then went on to say that the resulting mpeg from Quenc would not play in WMP or WinDVD. This is true.

    I then went on to say that one program that I tried that would play the file (Nero Showtime) reported the file was 352x256. This was also true.

    HOWEVER, it turns out that Nero Showtime was incorrect! The resulting mpeg is indeed 352x240. I was able to see this when I opened the mpeg in virtualdub (I didn't have virtualdub installed when I started this test) and when I finally figured out how to ask WMP what the resolution of the file was.

    So, this left two mysteries still:

    1) Why was Nero Showtime (and, as it turns out, mplayer2) reporting the output mpeg as 352x256?

    and

    2) Why wouldn't the output mpeg play in WMP or WinDVD.


    The answer to both questions (sort of) was found when I contemplated vurbal's question of whether or not I have changed any of the advanced options in Quenc.

    Why, yes, of course. I set my aspect ratio to 4:3, set my audio encoding to AC3, selected "Interlaced Encoding"...

    HOLD ON A MINUTE THERE!

    I selected "Interlaced Encoding" for all of my tests, INCLUDING the ones where I resized the video to 352x240 before passing it to Quenc.

    This seemed like it could be a problem. I'm not exactly sure what the behavior should be, but I figured that resizing in avisynth in a way that likely removes interlacing and resizing all the way down to 240 vertical and then selecting "Interlaced Encoding" in Quenc just might be a bad thing.

    Sure enough. Once I turned off "Interlaced Encoding", the resulting mpeg was playable in WMP, WinDVD, mplayer2, Nero Showtime, etc. Also, all of the programs now report it as 352x240. Why Nero and mplayer2 reported it as 352x256 before, I'm not completely sure.

    So, thanks for your time and brain cells. I'm going to stay away from 352x240 and I'm going to be more careful about what I'm doing to interlacing in my scripts. Then, I'll make sure that what I'm asking Quenc to do makes sense given my filters.

    I was going to ask this same question of nic over on doom9, but I hadn't been registered and there is a 5-day "cooling off" period in which new registrants can't post. Thanks to you guys, I won't have to go over there and have nic and the others point out my silly error.

    Thanks,
    Mike
     
    Last edited: Mar 6, 2005
  13. vurbal

    vurbal Administrator Staff Member

    Joined:
    Nov 30, 2002
    Messages:
    2,573
    Likes Received:
    1
    Trophy Points:
    66
    Glad to see you're making some progress figuring out what setting is causing the problem but your interlaced setting should have been fine. I just looked at my settings and it doesn't look like I had interlaced set either. I'll try it again today with it set correctly and see what happens.
     

Share This Page