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

How to Encode Anamorphic.

Discussion in 'Other video questions' started by AXT, Jul 22, 2008.

  1. AXT

    AXT Guest

    Hopefully somebody more familiar with MeGui/VirtualDub and Avisynth can help me to achieve my goal. My goal is to resize an encode to 853x480 resolution, which is the playback resolution of an MPEG-2 video 16:9 DVD. Ideally I would like to achieve this by using Avisynth or MEGui if possible. Unfortunately I can resize only in mod2, mod4, mod8, and mod16 resolutions, none of which can achieve 853. I tried converting the video to RGB32, but to no avail since avisynth supports only YV12 color format. In other words, how can I achieve 853x480 playback. I have a couple of videos that if you play them in VLC media player, right click=>miscellaneous=>Media info=>advanced information, information shows that they are at a resolution of 704x480. However when you play them, they take on a resolution of 853x480, in other words, full playback resolution. (BTW, these videos are encoded using x264 and are in a matroska container) There has to be a way of doing this.

    any help,hints, or clues would be greatly appreciated.
     
  2. davexnet

    davexnet Active member

    Joined:
    Jul 7, 2003
    Messages:
    1,856
    Likes Received:
    0
    Trophy Points:
    66
    NTSC dvd, either 704*480, or 720*480, is the standard resolution.
    If you encode the mpeg 2 as anamorphic (for 16*9 TV) you will get this
    effect at playback time.

    What us your intended output format ?
     
  3. AXT

    AXT Guest

    I usually encode movies at a resolution of 768x432 for widescreen (mod16)using x264 after which i mux the audio and video in mkvmerge to get a .mkv file.
     
  4. AXT

    AXT Guest

    Last edited by a moderator: Jul 22, 2008
  5. davexnet

    davexnet Active member

    Joined:
    Jul 7, 2003
    Messages:
    1,856
    Likes Received:
    0
    Trophy Points:
    66
    I also have avisynth/MeGUI/MKVmerge GUI installed.

    I created the d2v/avs for a 16/9. All I did in the avs was to open the
    d2v. No resizing. Create the x264/mp4 file. It will have the same
    dimensions as the DVD. So far so good.

    Open MKVmerge GUI and setup the video and audio. Hilight the video
    and down below, select "format specific options" select 16/9.
    Mux the MKV.

    Now at playback time, in MPC it's 852*480 - Perfect.
     
  6. AXT

    AXT Guest

    Ok so I did more digging around on the subject and here is the lowdown. As you said NTSC DVD comes in two flavors: 704x480 or 720x480. On playback the video plays at a resolution of 853x480. Whenever you want to resize to 853x480 in avisynth you can't. Avisynth can only handle resolution of mod2, mod4, mod8, and mod16. 853 does not fall under any of these categories. Naturally, in order to achieve this resolution you resize to either 852(mod4)x480(mod16) or 854(mod2)x480(mod16) and call it close enough. This approach is not good enough since it does not give the exact picture size of 853x480. However, we have a tool that goes by the name of x264. This tool has a custom command line(-- sar). By using this you can easily achieve the correct picture size of 853x480. How do you use this? You might ask. Well its simple, you just have to know the frame size of you source. I will take 300 for example. After you run it through DGIndex you should get a .d2v file. Open this file with notepad. And see where it says Picture_Size. For 300 it is 720x480. OK. So now you know the resolution of you source material.

    Now for the encoding stage:
    So, you want to encode anamorphic? EASY.
    Part 1- I Don't Crop
    If you do not crop then it will save you an extra step or two when it comes to producing the avisynth script. Just apply your filters and DO NOT RESIZE. You will be encoding at a resolution of 720x480.

    Part 2a- I Crop
    Lets say that you don't like black bars at the top and bottom of you video, what do you do? Crop of course. In my case I have:
    Crop(0,58,0,-62) NOTE, YOU HAVE TO USE EVEN NUMBER WHEN CROPPING.
    OK, i managed to remove 58 pixels off the top of the frame, 62 pixels from the bottom, 0 from the left, and 0 from the right. My new resolution is now 720x360 (58+60=120)[480-120=360]. This means that in my final encode i will not have black bars at the top and bottom of my movie. DO NOT RESIZE. You will be encoding at a resolution of 720*360

    Part 2b- What if I need to crop the sides too? If you crop the sides you might want to resize unless you like doing algebra (Even then you probably don't have the software or hardware necessary do derive an exact number). For example if my script says: Crop(4,58,-8,-62) This means I took off 58 pixels off the top of the frame, 62 pixels from the bottom, 4 from the left, and 8 from the right. My new resolution will be: 708x360. What you want to do now is resize back to a resolution of 720x360. Just choose your favorite resizer.

    A note of caution, when you crop the black bars off, DO NOT resize back to 720x480 or you will get a messed up aspect ratio. Keep the vertial pixel count as it is. Also do not resize to something other than 720(or 704) or else the aspect ratio will become messed up.

    How to Configure x264-now its time to configure x264 encoder. As I said earlier there is a custom command line (--sar) that you will need to input. By default (as i understand it ) the sar is set to 1:1, this means that whatever resolution avisynth inputs will come out the other end. So if you chose not to resize your video file to a proper anamorphic resolution you will get, in my case a video that has a resolution of 720x480 (or if I cropped 708x360 or 720x360). I usually just resize to 768x432, this will give me a proper aspect ratio. However, the point of this is that you want a a resolution of 853x480, not 852x480 or 854x480. In all three cases you input a source at a resolution of 720x(SOME NUMBER HERE DEPENDING WHETHER YOU CROPPED OR NOT).

    For a 720x480 (16:9) NTSC DVD the correct ratio is 32:27
    For a 704x480 (16:9) NTSC DVD the correct ratio is 40:33

    In my case for a frame size of 720x480 I will add this to x264(--sar 32:27) After I finish encoding a video i will get video with correct aspect ratio and DVD resolution of 853x480. (How do you derive 853 you ask well 720*32=23040| 23040/27=853.333333333333[technically this is the true DVD horizontal pixel count])

    If I cropped the black bars off i will get a video of resolution 853x360, same thing if you cropped black bars and sides.

    For more information refer to these two links. These guys probably know a lot more on the subject than I.

    http://translate.google.com/transla...&hl=de&ie=UTF-8&oe=UTF-8&prev=/language_tools

    http://forum.doom9.org/showthread.php?p=1058927#post1058927

    Try encoding a sample clip and see if it works. This same procedure should theoretically work for HD encodes as well.
     
    Last edited by a moderator: Jul 22, 2008
  7. davexnet

    davexnet Active member

    Joined:
    Jul 7, 2003
    Messages:
    1,856
    Likes Received:
    0
    Trophy Points:
    66
    Interesting. I was looking for a way to specify a custom SAR through
    MeGUI but I didn't find it. That's why I encoded it as is, and let
    the MKV set the DAR. 852*480 is good enough for me,
    but each to his own.

     

Share This Page