map200uk Posted May 16, 2007 Share Posted May 16, 2007 hi, i think ive finally understood the spec and after looking at a number of files in a hex editor-have possibly worked out a way i can read the data in, even tho the comments are varying in size: could someone have a brief look over this, and see if it makes sense (I think it does) just about to try and code it! address 109 specifies length of vendor field => 1.0 === Xiph.Org libVorbis I 20020717 1) address 142 says how many comments to expec=>6 2 ) 146 specifies length of 1st comment 15 btes => TITLE 3) 165 specifies bytes for length of artist comment => 15 4) 184 specifies album length==13 5) 201 track commnt length=13 6) 218 specifies date lengh=9 7) 231 specifies genre length (13) the actual length of a comment frame varies, depending obviously on the fileb) i.e. Artist for 'Aqua' is goig to require less bytes (4) than say Prince would (5) same applies to all the comment fields so need to address 109 is static in all files 109 specifies the length of vendor field and address 142 is also static - the number of user comments to expect 146 -> the location specifying the length of first comment is also static so, need to read 1 byte in at location 109: a) read in the vendor field b) read in 1 byte at address 142, telling us the number of comments to expect c) read 146 to get the length of the first comment -> value of size of next comment proceeeds directly after end of a comment, so if we read 6 as the value for comment, we know we need to read 6 bytes in then read x+1 to get the length of the next comment each fram also has a 3 byte seperator between it (char 0) NULL so we read 1 byte location 109, then read in the value this holds + 3 (3 bytes for the 3 NULL spacers between comments) we then read the next 1 byte in 142) telling us number of comments to expect read 146 (always same) to get the length of first comment -> then read value held at 146+3 (3byte spacer) so if 146 holds 30, we read the next 33 bytes in we then read 1 byte again-directly after each comment the value of the next comment is held proceeded by the 3 spacers thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/51698-reading-in-a-file-ogg-think-ive-got-it/ Share on other sites More sharing options...
map200uk Posted May 16, 2007 Author Share Posted May 16, 2007 or at least i thought i had, but im having trouble reading the length values say for address 109 the value in hex ed is chr 29 echoing out after fread shows a [] :| Quote Link to comment https://forums.phpfreaks.com/topic/51698-reading-in-a-file-ogg-think-ive-got-it/#findComment-254711 Share on other sites More sharing options...
map200uk Posted May 16, 2007 Author Share Posted May 16, 2007 ord does wonders:> Quote Link to comment https://forums.phpfreaks.com/topic/51698-reading-in-a-file-ogg-think-ive-got-it/#findComment-254724 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.