Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternative containers #5

Open
est31 opened this issue Jun 8, 2017 · 5 comments
Open

Support alternative containers #5

est31 opened this issue Jun 8, 2017 · 5 comments

Comments

@est31
Copy link

est31 commented Jun 8, 2017

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.

@ruuda
Copy link
Owner

ruuda commented Jun 9, 2017

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.

@est31
Copy link
Author

est31 commented Jun 9, 2017

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.

@ruuda
Copy link
Owner

ruuda commented Jun 11, 2017

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?

@est31
Copy link
Author

est31 commented Jun 12, 2017

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!

@ruuda
Copy link
Owner

ruuda commented Jun 21, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants