Open est31 opened 7 years ago
Claxon implements the FLAC spec which describes bit by bit what the stream should look like, and the spec makes no mention of embedding. So any container format that embeds FLAC would have to specify how it does so. If it embeds the streaminfo and frames without modification, then adding support for reading those would not be very hard. Actually, the FrameReader
is already public (but some of its type parameters are not).
Do you have any references for container formats that embed FLAC? I was able to find the ogg mapping and it looks like that one indeed embeds frames directly.
The mp4 mapping should be described here: https://github.com/xiph/flac/blob/master/doc/isoflac.txt For mp4 there is the mp4parse crate which should support flac (I hope?): https://github.com/mozilla/mp4parse-rust
For the ogg mapping, my ogg crate should contain all relevant things: https://github.com/rustaudio/ogg If you need something, please write!
I don't know about embeddings in other formats. The mp4 mapping spec only has a link to the ogg mapping, not to other mappings.
I have added an example that shows how to read flac from an mp4 container using mp4parse
. All the building blocks were there, but I had to expose a few things to get it working.
Reading from ogg will be a little bit more involved, because the header packet has a few fields before the streaminfo. It is only 12 bytes, mostly constants. Does Vorbis have some kind of identifying mark in the first packet too? Perhaps this is something that the ogg
crate could recognize and parse, similar to how the mp4parse
crate is aware of flac metadata blocks?
Does Vorbis have some kind of identifying mark in the first packet too?
Yes, vorbis has an identifying mark, but its being recognized in lewton, not by the ogg crate.
Some containers transmit info about the kind of the stream within their own custom metatadata, other container formats like ogg don't do this. For ogg, everything is just opaque data.
All the building blocks were there, but I had to expose a few things to get it working.
Really cool!
I added an ogg example too now!
There are still a few rough edges in the Claxon API; I plan to implement a few more things to make reading from external container a bit nicer (the to dos in the examples). I’ll keep this issue open until then.
Flac doesn't have to be inside its own custom container, it can also be encapsulated inside ogg or inside the mp4 container. It would be cool if this crate supported those use cases, maybe through optional cargo features.
My lewton crate is organized in a very generic fashion: its main function only takes a byte slice and treats that as one packet, regardless of the actual container format. The entire crate knows nothing about the container format, except for the
inside_ogg
module. Having such a setup for the claxon crate would be really cool.