ogg encapsulates audio

  • ogg is a multimedia container that can contain many audio and video formats.

  • Ogg organizes and links the logical flow in units of pages, and each page has pageheader and pagedata. The page header has the following definitions:
    1. Page ID: ASCII characters, 0x4f 'O' 0x67 'g' 0x67 'g' 0x53 'S', 4 bytes in size, it marks the beginning of a page.
    2. Version id: Generally, the current version defaults to 0, 1 byte.
    3. Type identification: identify the type of the current page, 1 byte.
    0x01: The media encoding data of this page and the previous page belong to the same packet of the same logical flow. If this bit is not set, it means that this page starts with a new packet; 0x02: It means that this page is the first packet of the logical flow
    . Page, bos flag, if this bit is not set, it means it is not the first page;
    0x04: means the last page of the logical flow of the page, eos flag, if this bit is not set, it means this page is not the last page.
    4. Granule_position: Parameter information related to media encoding, 8 bytes. For audio streams, it stores the number of sampling codes in the PCM output of the logic stream up to this page, and can be used to calculate the timestamp. For video streams, it stores the number of video frames encoded so far. If the value is -1, it means that as of this page, the packet of the logical flow has not ended. (Little endian)
    5.serial_number: The id of the stream in the current page, 4 bytes, it is the serial number to distinguish the logical stream to which this page belongs from other logical streams, we can use this value to divide the stream. (Little endian)
    6.page_seguence_number: The serial number of this page in the logical stream, 4 bytes.
    7.CRC_cbecksum: Cyclic redundancy check code check, 4 bytes, used to check the validity of each page.
    8.number_page_segments: Given the number of segments that appear in the segment_table domain of this page, 1 byte.
    9. segment_table: Literally, it is a table, indicating the length of each segment, and the value range is 0~255.
    The value of the packet can be obtained from the segment (1 segment is 1 byte). The size of each packet ends with the last segment not equal to 255. The length of each packet can be obtained from the segment_table in the page header. For example
    : If a set of segments is sequentially FF 45 FF FF FF 40 FF 05 FF FF FF 66 (a total of 4 packets, including 12 segments, the length of each packet is: FF 45 [324]; FF FF FF 40 [829] ; FF 05 [260]; FF FF FF 66 [847]), then the length of the first packet is 255+69 = 324, and the size of the second packet is 829, similarly.
    The page header is basically composed of the above parameters, so we can get the length of the page header and the length of the entire page:
    header_size = 27+number_page_segments ; (byet)
    page_size = header_size + the size of each segment in the segment_table;

Ogg rfc3533 ogg format analysis

Guess you like

Origin blog.csdn.net/shuangmu9768/article/details/125146450