Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: ogg-vorbis bitstream question (Read 10908 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

ogg-vorbis bitstream question

hey, i am working on an ogg-vorbis support for my program, and i am curious if the firsth page is always 58 bytes long, and if its funcionality can be taken as a header (like mpc, flac, mp3 etc has). or do i have to seek for segment table and iterate through the lacing values/segments ?
[EDIT]
[...] values/segments to determine its (1th page) size ?
i am asking becouse i want to reach the vorbis comment.

ogg-vorbis bitstream question

Reply #1
for a long time i wasn't working on this (OGG) parts in my code so i dont even remember what's post above about, but i remember that sometimes after posting that, i realized that it (question) could be asked in an all wrong way. whatever, i am asking again and simplier:
is anyone able and willing to help me determining where the vorbis comment is ???
i need:
- offset from the begining of file
- size comment

hopefully waiting for an answer  , sn0wman

ogg-vorbis bitstream question

Reply #2
Quote
for a long time i wasn't working on this (OGG) parts in my code so i dont even remember what's post above about, but i remember that sometimes after posting that, i realized that it (question) could be asked in an all wrong way. whatever, i am asking again and simplier:
is anyone able and willing to help me determining where the vorbis comment is ???
i need:
- offset from the begining of file
- size comment

hopefully waiting for an answer   , sn0wman
[a href="index.php?act=findpost&pid=372122"][{POST_SNAPBACK}][/a]


The comment will always begin as the first packet in the second page of the vorbis stream. ie the second packet in the stream.

The size of the comment is variable not fixed.

The comment can span over multiple pages. Though in most cases it is fully contained in the second page. You can't rely on this though.

The only reliable way to get the comment, is to packetise the first 2 packets. ie use an ogg demuxer (ie libogg), or to use the lacing values to determine where the packet is, and if it spans over page breaks to merge the parts together.

ogg-vorbis bitstream question

Reply #3
oh cool, thanks illiminable, i have even found some code which i can learn on. but, do you know maybe, to be sure, if firsth page always count only one segment (which is identification header [0x01]) ? thats what implicates from what i see in that code, and, all my files i looked up, are build in that way.

ogg-vorbis bitstream question

Reply #4
another question, i need to be 100% sure, does vorbis comment field size can be span over more than 1 page (like field content can be), or its just impossible ?

ogg-vorbis bitstream question

Reply #5
another question, i need to be 100% sure, does vorbis comment field size can be span over more than 1 page (like field content can be), or its just impossible ?


The packet can span multiple pages and it can be split at any point.  So, yes, the field size could also be split.

Monty

ogg-vorbis bitstream question

Reply #6
I'd suggest you to have a look at mutagen python library

ogg-vorbis bitstream question

Reply #7
Hi ive read and reread the ogg and vorbis documents on Xiph.org but Im still unsure about a couple of terms.

When using Ogg Vorbis what exactly is a packet, is it eight bits (an octet), or are there three packets (the Identification packet, Vorbis Comment packet and Audio Packet).

I understand that Vorbis Comment can span multiple pages but how do you detect this. I thought I could look for where the Ogg Page header type flag was 1, and carry on reading pageheaders until the header type is zero, but oce I get one page with a header flag=1, they seem to continue with a flag=1 until the very last frame.

ogg-vorbis bitstream question

Reply #8
Hi ive read and reread the ogg and vorbis documents on Xiph.org but Im still unsure about a couple of terms.

When using Ogg Vorbis what exactly is a packet, is it eight bits (an octet), or are there three packets (the Identification packet, Vorbis Comment packet and Audio Packet).

I was also confused about this at first. A packet is a block of data of arbitrary length, padded to an integral number of bytes. To find the size, look at the segment table. Lets say it contains 12 entries (called lacing values), and the value of the first 4 entries are 255, 255, 255 and 135. That means the first packet on that page is 255 * 3 + 135 (i.e., 900) bytes.

Quote
I understand that Vorbis Comment can span multiple pages but how do you detect this. I thought I could look for where the Ogg Page header type flag was 1, and carry on reading pageheaders until the header type is zero, but oce I get one page with a header flag=1, they seem to continue with a flag=1 until the very last frame.

The continue bit indicates that a packet continues from the previous page, but it doesn't say anything about which packet...

Again, look at the segment table. The end of a packet is marked with an entry that is less than 255. If the table ends with a 255 value, it means the packet continues on the next page (and that page should have the continued flag set).

ogg-vorbis bitstream question

Reply #9
That means the first packet on that page is 255 * 3 + 135 (i.e., 900) bytes.

Thanks. If that signifies the end of the first packet on that page. How does is show a second packet on that page or do packets always start on a new page. In particular does the Ogg Vorbis Decode Header start on the same page as the end of the Vorbis Comment Header page or the next page ?

ogg-vorbis bitstream question

Reply #10
Keep looking in the segment table. In my example there were 12 entries in it and the first packet used the first 4. The remaining 8 are used for further packets.

ogg-vorbis bitstream question

Reply #11
Keep looking in the segment table. In my example there were 12 entries in it and the first packet used the first 4. The remaining 8 are used for further packets.

Thanks Ive got it now, just need to code it.

ogg-vorbis bitstream question

Reply #12
Ok, just a couple more questions.

Can I safetly assume that only the Identification Header is held on the first OggPage, or would it be valid to also start the VorbisComment Header on this page immediately afterwards.

The VorbisComment Header always seems to start on the 2nd page, with the Setup Header immediately after it.
But do the first Audio packets always start on their own new page (3rd page being the earliest) or could they start immediately after the Setup Header. I don't need to know this for reading VorbisComents but I do for writing VorbisComments.

thanks Paul

 

ogg-vorbis bitstream question

Reply #13
In the absense of any other info Im assuming this is correct, it works ok for my testdata