Technical info on 16:9 MPEG-2 files

Discussion in 'Archived Threads 2001-2004' started by John_Berger, Jul 10, 2002.

  1. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
    Here's a poser for the very MPEG-technically astute.

    To create a 16:9 Enhanced DVD using non-commercial (aka less than $1,000) software like Sonic's DVDit and pre-generated MPEG-2 files, those files need to be "flagged" within the datastream as 16:9 files, even though a file of the same resolution can be used in a 4:3 project.

    I've been trying to convert non-16:9 files to 16:9 with TMPGenc, but I've not had a lot of luck.

    This whole concept that an MPEG-2 file must be "flagged" really bothers me because, whether it's flagged or not, the MPEG-2 file still uses the same resolution of 720x480. So, the concept that one 720x480 MPEG-2 is not flagged and is therefore unacceptable yet somehow a flagged 720x480 MPEG-2 *is* acceptable for 16:9 Enhanced projects really is more than a little strange to me.

    When all other things are equal (resolution, video bit rate, audio bit rate, etc), I cannot understand how a simple flag can so drastically change an MPEG-2 file as to allow it to be a part of a 16:9 project or conversely deny its ability to be in a 16:9 project.

    How exactly do 16:9 MPEG-2 files differentiate themselves from non-16:9 MPEG-2 files and why is it such a big deal?

    Anyone? Anyone? Beuller?
     
  2. MichaelG

    MichaelG Second Unit

    Joined:
    Jul 10, 2000
    Messages:
    322
    Likes Received:
    0
    John, I believe the reason that flag is needed is only for the DVD player and use of a standard 4:3 TV set.

    If the display type is set as 4:3 and the DVD player reads a 16:9 flag then it will process the video differently to output the correct aspect ratio. If the DVD player's display type is set to 16:9 then it should just output the video as it is on the disc. I would just go ahead and continue ti create your project without worrying about the flag. If you have a 16:9 TV then just use the TV display mode for watching an anamorphic souce.

    Unless I am sorely mistaken, the 16:9 flag doesn't matter if your DVD player display type is 16:9, and you are using a 16:9 TV.

    Hope this helps
     
  3. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  4. Jeff Kleist

    Jeff Kleist Executive Producer

    Joined:
    Dec 4, 1999
    Messages:
    11,267
    Likes Received:
    0
    No, it's not far more complicated than it need be. If you have a picture designed for 16:9 TVs that is not flagged then it will display as-is without downconversion on 4:3 screens. So to prevent that, the authoring software will only accept flagged titles for intended 16:9 output.

    You can't hex edit it unless you have a lot of time on your hands, probably more than to re-render it. the flag is a reoccuring one. MPEG works like this. Every X frames you have a single uncompressed frame, Between frames X and Y, there are instructions that say things like "Pixel 147 red for 5 frames" and so-on. That's how MPEG compression works. Every time you have your uncompressed frame, you need to have your flags in place with it. This is why titles like Sixth Sense and T2:UE have trouble on the Apex, because it incorrectly reads the flags at certain points
     
  5. Ken Chan

    Ken Chan Producer

    Joined:
    Apr 11, 1999
    Messages:
    3,301
    Likes Received:
    0
     
  6. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  7. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  8. Jeff Kleist

    Jeff Kleist Executive Producer

    Joined:
    Dec 4, 1999
    Messages:
    11,267
    Likes Received:
    0
    Because a set-top DVD player totally relies on the flags in the file to tell it to downconvert. I know of no player that will allow you to instruct it to downconvert manually
     
  9. Wayne Bundrick

    Wayne Bundrick Cinematographer

    Joined:
    May 17, 1999
    Messages:
    2,358
    Likes Received:
    0
    It's been a month or two since I burned a DVD but I think the DVD standard requires every GOP to have a sequence header. And I think the sequence header has a 16:9 flag. That's why the flag is recurring. There may also be other data structures in the MPEG2 stream that also have a 16:9 flag. It's possible that TMPGenc isn't quite doing everything properly for 16:9 and DVDit is rejecting it. But I think DVDit is just way too inflexible about bringing in MPEG2 video encoded elsewhere. Sonic Solutions won't put a lot of effort into making it work more painlessly because they also sell mid-level ($2000+) and high-end ($10,000+) DVD authoring systems.
     
  10. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
    This is where Ulead needs to jump in and take over. DVD Workshop already has a huge number of features (16:9 not being one of them unfortunately) that make it outshine DVDit. The only two things that make DVDit better are the Dolby Digital 2.0 and the 16:9 capabilities. Otherwise, DVD Workshop kicks its a$$ and costs about 1/4 the price to boot.
     
  11. Jeff Kleist

    Jeff Kleist Executive Producer

    Joined:
    Dec 4, 1999
    Messages:
    11,267
    Likes Received:
    0
     
  12. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  13. Marty Christion

    Marty Christion Stunt Coordinator

    Joined:
    Oct 3, 2001
    Messages:
    229
    Likes Received:
    0
    I think you need to stop using the term "anamorphic" right now. Stop. Never use it again when talking about DVD.

    DVD's are not "anamorphic". The video image can be 16x9 or 4x3. These are two different shapes (it's actually shapes of pixels, but same difference). You seem to expect the technology to act more like anamorphic film, where the filmframe is the same shape and size, but one has a special lens to project a wider image from the same frame. DVD doesn't do this. They haven't "squeezed" a 16x9 image into a 4x3 area, and the player/TV isn't "unsqueezing" a horizontally compressed image. Once video got converted into bits and pixels, all the rules changed and we had to start looking at moving pictures in a different way.

    Try this: look at a 16x9 TV, and a 4x3 TV. Imagine every pixel on every TV has a number, starting with "1" in the upper left hand corner, and "1000" in the lower right hand corner. Assume it's a CRT that scans the pixels in order. Also assume the same number of pixels, with different shapes (obviously).

    Now take an image that has a 16x9 shape, also 1000 pixels, with the first pixel being in the corresponding upper left hand corner, and the 1000th pixel being in the lower right hand corner. Paste this image, pixel for pixel, onto the 16x9 display, and it will look perfect. No problem.

    Now take that same 1000pixel, 16x9 image, and paste it pixel for pixel onto the 4x3 monitor. What does it look like? It looks like someone has horizontally squeezed it (much like a frame of film looks after it has been through an anamporphic filter, thus the common misunderstanding). But has anything changed in the picture? No. It is the same number of pixels, in a 16x9 format, only now it's displayed with a 4x3 shape. It hasn't been "squeezed", it hasn't been filtered or processed. It hasn't been nipped or tucked. It is only being displayed in the wrong shape.

    The reverse would be true if you display a 4x3 image on a 16x9 monitor; it would look horizonatlly stretched.

    As stated before, this isn't anamporphisism, it only looks that way. And people call it that. And it's no problem, until you are actually creating video and need to solve problems related to the issue. If you don't understand the basic issues involved, you won't be able to solve the problems. So the second you start working with digital video and aspect ratios, you need to stop thinking of anamorphic film and squeezing and unsqueezing using lenses. It stops being a semantic/ theoretical issue and starts being a very real one.

    So now you know how the MPEG2 flag, the player aspect ratio setting, and the shape of the TV all work together to display the image correctly. Assuming the MGPEG2 flag, the player, and the TV are all set correctly, the thought process goes like this:

    "I'm a DVD player. My owner has told me that I am connected to a monitor with a 4x3 shape (and he prefers letterboxing). The video I am playing has a shape of 16x9. I need to display pixel 1 of the image where I would usually display pixel 232, and pixel 1000 where I would usually display 745. The area I am not displaying pixels in will be colored black. I also need to use my built in algorithm to skip lines of pixels, so the video will still look like it should."

    "Now I am playing a video with an aspect ratio of 4x3. Now I should display pixel 1 in the top left hand corner, where it should be, and pixel 1000 in the bottom right hand corner, where it should be. But why is my pathetic owner watching a pan and scanned video? Why couldn't I have been bought by a member of the HTF? What? This is the Friends Season 1 set? And I'm an Oritron player, without an S-Video output? I guess that answers both questions."

    If you have a true 16x9 image, you back and encode it as such.
     
  14. Ken Chan

    Ken Chan Producer

    Joined:
    Apr 11, 1999
    Messages:
    3,301
    Likes Received:
    0
     
  15. Jeff Kleist

    Jeff Kleist Executive Producer

    Joined:
    Dec 4, 1999
    Messages:
    11,267
    Likes Received:
    0
    I wasn't talking about chapter points. I'm talking about typing a timecode (1:23:42 for example) into your remote and it going to that time. Without the flags every X frames, it wouldn't work
     
  16. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  17. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  18. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  19. John_Berger

    John_Berger Cinematographer

    Joined:
    Nov 1, 2001
    Messages:
    2,489
    Likes Received:
    0
     
  20. Wayne Bundrick

    Wayne Bundrick Cinematographer

    Joined:
    May 17, 1999
    Messages:
    2,358
    Likes Received:
    0
    I've been looking up some information about MPEG2 video. You're absolutely right, John. The idea of repeating sequence headers is to make random access easy. Jump to any point in the file, scan for the very next sequence header, then start decoding from there.

    And my guess about sequence headers was correct, the sequence header does indeed contain aspect ratio information along with just about everything else describing the characteristics of the video. A video sequence needs only one sequence header, at the beginning, but it's okay to repeat the sequence header, which as we've already realized is a good idea for random access.

    Earlier you and Jeff talked about using a hex editor to go through the file and change all the flags to 16:9. But hell, if you know enough about the structure of an MPEG2 file to be able to recognize the sequence headers and the aspect ratio flag in each header, then that same knowledge can be used to write a short and simple program to change the whole file in one fell swoop. When I say short and simple I mean really short and really simple.

    Here's what I've learned:

    Sequence headers always begin with the start code hex 01 B3. The next 12 bits are the horizontal resolution and the next 12 bits after that are the vertical resolution, three bytes total. For 720 x 480 video that's 2D0h x 1E0h so the three bytes are 2D 01 E0.

    The next four bits are the aspect ratio. Possible values are:
    1 = 1:1 square pixels
    2 = 4:3
    3 = 16:9
    4 = 2.21:1 (not valid for DVD)

    The next four bits are the frame rate. Possible values are:
    1 = 23.976
    2 = 24
    3 = 25
    4 = 29.97
    5 = 30
    6 = 50
    7 = 59.94
    8 = 60

    So I think that all you have to do is search the file for "01 B3 2D 01 E0 2X" (where X is the frame rate, probably either 1 or 4) and replace the 2X with 3X.

    I tried it on a short 10 second clip and it worked.
     

Share This Page