Results 1 to 2 of 2

Thread: Schaufenugget

  1. #1
    Join Date
    Jul 2009
    Posts
    166
    Mentioned
    5 Post(s)
    Quoted
    69 Post(s)

    Default Schaufenugget

    Hey guys.
    I have been messing with audio ogg vorbis files, with hex editor.
    Those Vorbis files have huge header where is all codec info is stored and then there is smaller chunks.
    So I have been trying to cut from one file audio chunks to add to another vorbis file. Doesn't work.
    After looking info about headers, graphs are all about main header.
    But I need some info how small chunks are chained.
    Untitled.png

    About that wtf what is it and how is it calculated?

  2. #2
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    The header start (the OggS ascii char sequence) consists only of the 4 bytes you highlighted, correct.

    The following byte (0x00) is the bitstream format, reserved for expansion but currently mandated to be 0x00. The next byte (0x00 again) specifies the header type, in this case as a continuation stream (remember this, we come back to it later).

    The pattern you circled and asked 'wtf' is the first 2 bytes of an 8 byte section. The full section is actually (C0 02 00 00 00 00 00 00). This contains time information, but its exact value can differ depending on the codec used. It will be something like the number of frames, number of samples, etc. It is a time value for the container that is slightly abstract and defined by the used codec.

    The next 4 bytes (63 63 00 00) are a serial identifier for the stream, so that separate bitstreams (such as audio/video) can be processed and identified properly.

    4 bytes after that (02 00 00 00) is a counter that increases for every logical bitstream, in this case you have 3 pages of bitstreams.

    Where you wrote hash, its actually a CRC, in this case CRC32 but thats a small nitpick. You're correct on block size.

    Now the meat of your question (as I see it at least) lies in the segment table you have circled. For starters, the first byte is the number of segments in the page. In this case, 0x9F or 159 segments. Should note that the vorbis container limits page segments to 255 due to the fact you only have 1 byte to store the number of segments (again, we come back to this).

    The rest of the table you can see as an array of 1 byte values (sized to the first byte we just covered). Each indicates the length of its segment. This data is used to construct packets of sort. Each value less than 0xFF (255) indicates the start of a new data packet, and every 0xFF (255) indicates that page index as being included in the same packet.

    So, your first data packet is (A0 FF FF), your second is (40 FF FF), third is (50 FF FF), fourth is (3E) etc.

    Since we established earlier that the header type is a continuation stream, this specific array is intended to be concatenated to the end of the previous one. This is a continued list, for when segments are longer than 255 in length. The final value in the end of a segment list should be 0x0 (0). If its 0xFF (255) then that means the data is continued elsewhere in a continuation header such as this.


    I hope this answers your question.

    EDIT:
    Further reading; https://xiph.org/vorbis/doc/Vorbis_I_spec.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •