VideoHelp.com Forum
+ Reply to Thread
Results 1 to 15 of 15
Thread
  1. Member
    Join Date: Aug 2006
    Location: Switzerland
    Hi,
    I'm trying to develop a basic MPEG-2 Transport Stream decoder in order to extract metadatas about PSI packets. I have a bunch of books and documents (but not the standard itself) describing the stream layout; I also have some consistent TS files for testing and a TS analyser software (Manzanita's MP2TSA) to validate my assertions. The documents I use sometimes disagree, but I was able to filter the correct information up to this point. Now I have the following problem while trying to decode a PAT section: there's an extra byte in the PAT header, undocumented in all documents I've used so far. Below is the beginning of a TS Packet containing a PAT section (the remaining bytes of the packet have a value of FF):

    Code:
    47 40 00 10 00 00 B0 0D 00 01 C1 00 00 00 02 E1 E0 2F 39 8D 8D  .....
    |TS Header |   PAT Header                 | ? |  Program   |  CRC32      | Stuffing bytes
    According to all the docs I have, the PAT header's length should be equal to 8; but it ended with a mismatch when comparing my results to the ones given by MP2TSA (which is an accurate tool). Adjusting the header's length value to 9 "solves" the problem... but I don't like to use intuitive reasoning! The question is:

    Does someone know the exact layout of a PAT header?

    Another problem, leading to the same question:

    I'm confused about the section_number and last_section_number field values of the PAT header (respectively 0xC1 and 0x00 in the sample above). I found the following description of these fields in the book "Video Demystified, A Handbook for the Digital Engineer", 4th edition (Keith Jack, Newnes, 2005, p.675):

    Section_number
    [...] The section_number of the first section in the PAT must be 0x00. It is incremented by 1 with each additional section in the PAT.
    Last_section_number
    This 8-bit binary number specifies the number of the last section (that is, the section with the highest section_number) of the complete PAT.
    This is obviously wrong, but I can't figure out why... any ideas?

    Thanks for reading

    Jerome
    Quote Quote  

  2. Member
    Join Date: Aug 2006
    Location: Switzerland
    The problem is solved...

    According to the ITU H.222.0 (05/06) Recommendation (http://www.itu.int/rec/T-REC-H.222.0-200605-I/en), section 2.4.4.2:

    [...] When at least one section begins in a given Transport Stream packet, then the payload_unit_start_indicator (refer to 2.4.3.2) shall be set to '1' and the first byte of the payload of that Transport Stream packet shall contain the pointer. When no section begins in a given Transport Stream packet, then the payload_unit_start_indicator shall be set to '0' and no pointer shall be sent in the payload of that packet.
    The content of the PAT packet is correctly interpreted this way:

    Code:
    47 40 00 10 00 00 B0 0D 00 01 C1 00 00 00 02 E1 E0 2F 39 8D 8D  .....
    |TS Header | * | PAT Header                   |  Program   |  CRC32      | Stuffing bytes
    * = pointer_field
    The payload_unit_start is effectively set to 1, so the first byte of the payload data refers to a pointer_field which indicates the number of bytes until the first byte of the section. This makes perfect sense now.

    Thanks to myself
    :-)
    Quote Quote  

  3. Member racer-x's Avatar
    Join Date: Mar 2003
    Location: 3rd Rock from the Sun
    Congratulations! Well done........

    I know nothing about programing, but I'm interested in what you're doing to retrieve metadata from TS files. Maybe you can write a program that can correctly retrieve the metadata (shutter speed, aperture, and gain) from m2t files recorded by HDV cameras. They are after all Transport Stream Mpeg-2..........
    There is no such thing as "Idiot-Proof".........a good Idiot will get around that every time.
    Quote Quote  

  4. Member
    Join Date: Jun 2010
    Location: Germany
    Thanks a lot man. I was facing the same problem. good for me that you figured it out. i had missed that in the specifications... actually initially i didnt need to go into the pat packets; just get pid and some other stuff and so i skipped the bits in between...
    Quote Quote  

  5. Member
    Join Date: Jun 2010
    Location: Germany
    If there is just one PAT section in the TS, then should the section number and last section number both contain "00"?
    Quote Quote  

  6. Member
    Join Date: Jun 2010
    Location: Germany
    i got the answer. yes they should
    Quote Quote  

  7. Member
    Join Date: May 2011
    Location: morocco
    hi Every body,

    when we demultiplex a flux MPEG2-TS we flow this method : After acquiring the TS stream, you must filter packets whose PID is 0x0000. These TS packets containing the PAT.
    From the table PAT, the PID is determined and the numbers of programs. We will now find the PID of each program, the TS packets that have this PID contain sections corresponding to the PMT table for this program. In this PMT table is found for each program: elementary streams, their types and their PID. Also in the tables PMT we find the PID_PCR, which is usually the PID of one elementary stream, specifically the flow PID video.

    My problem is how we put all this in header specially that the section of PID(in header) is just 13bits !!!!!?????

    So please please please i want to know how we put all this in the header
    Quote Quote  

  8. Member
    Join Date: Jun 2010
    Location: Germany
    All this information is not in the header. the header is only 4 bytes. The PID field (13 bits) only contains the PID number which gives information about the type of packet u are currently looking at. the other information about PAT etc. is after the header. please see the MPEG-2 TS specifications. i dont have access to it right now otherwise i would have pointed out where to look.
    Quote Quote  

  9. Member
    Join Date: May 2011
    Location: morocco
    thank a lot man,


    can you post any documents that specifies the location of the SI / PSI tables on the TS packets
    Quote Quote  

  10. Member
    Join Date: Jun 2010
    Location: Germany
    welcome. all the information is in the MPEG-2 TS specifications. i know its not easy to understand by reading just once. u will have to read it closely and then u will understand how u can access all the information. i dont have the specifications any more and i dont know if they are available for free or not...
    Quote Quote  

  11. Member
    Join Date: May 2011
    Location: morocco
    ok i see , i just found some documentations in ETSI (that defined the standard DVB-T) http://broadcasting.ru/pdf-standard-...tocol/a079.pdf so that what you are talking about .

    I'm just starting my project on extracting information from an MPEG2-TS and implements a program (VHDL) on FPGA, so I try to understand the digital structure of the TS to manipulate and extract each program
    Quote Quote  

  12. Member
    Join Date: Jun 2010
    Location: Germany
    No this isnt it. I am talking about the official standard. It is the MPEG-2 Systems standard:

    ISO/IEC standard (13818-1)

    I think it might not be available free...
    Quote Quote  

  13. Member
    Join Date: Jun 2010
    Location: Germany
    yes exactly. good u found it! have fun on the weekend
    Quote Quote  

  14. Member
    Join Date: May 2011
    Location: morocco
    thank you so much and check your PM ^^
    Quote Quote  




Similar Threads

  1. Directshow filter for decoding MPEG-2 TS
    By roflwaffle in forum Video Conversion
    Replies: 5
    Last Post: 17th Aug 2010, 07:55
  2. covert avi header to mpeg header
    By nidhi in forum Video Conversion
    Replies: 6
    Last Post: 29th Jul 2010, 19:40
  3. Replies: 0
    Last Post: 10th May 2010, 11:49
  4. MPEG-2 Decoding Error
    By shorto in forum Newbie / General discussions
    Replies: 7
    Last Post: 21st Aug 2007, 15:41
Search   Contact us   About   Advertise   Forum   RSS Feeds   Statistics   Tools