Re: ogg vorbis comment (tag)
Posted: Tue Jul 30, 2019 3:18 pm
Hi Wilbert I can try
The first vorbis header is probably easiest.
It is allways 30bytes in length.
In the ogg it is like this.
4F 67 67 53 00 02 00 00 00 00 00 00 00 00 EC 0A 00 00 00 00 00 00 96 78 16 9D 01 1E 01 76 6F 72 62 69 73 00 00 00 00 02 44 AC 00 00 00 00 00 00 00 EE 02 00 00 00 00 00 B8
The bytes I have highlighted are tthe number of segments and the length 1E (30). The actual vorbis header is:
01 76 6F 72 62 69 73 00 00 00 00 02 44 AC 00 00 00 00 00 00 00 EE 02 00 00 00 00 00 B8 01
The first byte highlighted is the packet type (1) is the identity header. You can see this from your programme I think.
The second header is the comments header it begins :-
03 76 6F 72 62 69 73
The first byte being the header type 03 means comments header. In the file I posted this first ogg page has all the segments set to $FF so the comments header is quite long and spans two ogg pages. I think your programme actually does retrieve this over the two pages, being an amateur I am not sure.
The third vorbis header begins:-
05 76 6F 72 62 69 73
05 being the header type which I think is the instructions for the codec?
So if these three could be read into their own buffers is what I am looking for.
The fourth section of a vorbis stream is the audio data this starts on the ogg page after the end of the third vorbis header. It seems to be split into lots of sections and reading a little about packing a vorbis stream into ogg each of the sections is a vorbis packet for use by the vorbis codec about which I do not have a clue.
Just those first three sections I need. Would be nice if the file offset for the first audio page could be kept as well.
I can see that writing vorbis comments, especially if someone wants to insert an image (not using the COVERART tag anymore) can force the comments header to cover more than one ogg page which I will have to deal with, this will mean reading in every ogg page after the comments header rewriting the page sequence number tand checksum and writing it back to a file.
The audio data, if we can extract it, could be one step towards solving the PlaySound() Bug viewtopic.php?f=4&t=73243
So three buffers each holding one vorbis header and then offset to first ogg page with audio would mean christmas has come early.
kind Regards
CD
The first vorbis header is probably easiest.
It is allways 30bytes in length.
In the ogg it is like this.
4F 67 67 53 00 02 00 00 00 00 00 00 00 00 EC 0A 00 00 00 00 00 00 96 78 16 9D 01 1E 01 76 6F 72 62 69 73 00 00 00 00 02 44 AC 00 00 00 00 00 00 00 EE 02 00 00 00 00 00 B8
The bytes I have highlighted are tthe number of segments and the length 1E (30). The actual vorbis header is:
01 76 6F 72 62 69 73 00 00 00 00 02 44 AC 00 00 00 00 00 00 00 EE 02 00 00 00 00 00 B8 01
The first byte highlighted is the packet type (1) is the identity header. You can see this from your programme I think.
Code: Select all
Structure VorbisIdentification
PacketType.a
Identifier.a[6]
VorbisVersion.l
AudioChannnels.a
AudioSampleRate.l
BitrateMaximum.l
BitrateNominal.l
BitrateMinimum.l
BlockSize01.a
FramingFlag.a
EndStructure
03 76 6F 72 62 69 73
The first byte being the header type 03 means comments header. In the file I posted this first ogg page has all the segments set to $FF so the comments header is quite long and spans two ogg pages. I think your programme actually does retrieve this over the two pages, being an amateur I am not sure.
The third vorbis header begins:-
05 76 6F 72 62 69 73
05 being the header type which I think is the instructions for the codec?
So if these three could be read into their own buffers is what I am looking for.
The fourth section of a vorbis stream is the audio data this starts on the ogg page after the end of the third vorbis header. It seems to be split into lots of sections and reading a little about packing a vorbis stream into ogg each of the sections is a vorbis packet for use by the vorbis codec about which I do not have a clue.
Just those first three sections I need. Would be nice if the file offset for the first audio page could be kept as well.
I can see that writing vorbis comments, especially if someone wants to insert an image (not using the COVERART tag anymore) can force the comments header to cover more than one ogg page which I will have to deal with, this will mean reading in every ogg page after the comments header rewriting the page sequence number tand checksum and writing it back to a file.
The audio data, if we can extract it, could be one step towards solving the PlaySound() Bug viewtopic.php?f=4&t=73243
So three buffers each holding one vorbis header and then offset to first ogg page with audio would mean christmas has come early.
kind Regards
CD