One way of handling binary data is described in this Mozilla Developer article. Trying this method out works in Firefox and I can download and read the data in the Ogg file.
I put up a rough quick demo of loading the first 100Kb of a video and displaying information from each Ogg packet. This probably works in Firefox only due to the workaround needed to read binary data. Click on the ‘Go’ button in the demo page. This will load transformers320.ogg and display the contents of the first Ogg physical page.
I decode the header packets for Theora and Vorbis. So the first page shown will show it is for a Theora stream with a given size and framerate. Clicking ‘Next’ will move on to the Next page. This is a Vorbis header with the rate and channel information. Clicking ‘Next’ again gets the comment header for the Theora stream. The demo reads the comments and displays them. The same for the Vorbis comment records. As you ‘Next’ through the file it displays the meaning of the granulepos for each page. It shows whether the Theora data is for a keyframe, what time position it is, etc.
- Handling binary data using XMLHttpRequest in a cross browser manner
- Processing the file in chunks so the entire file does not need to be kept in memory
- Files need to be hosted on the same domain as the page. tinyvid.tv adds the W3C Access Control headers so they can be accessed cross domain but it also hosts some files on Amazon S3 where these headers can’t be added. As a result even tinyvid itself can’t use XMLHttpRequest to read these files.