our core developer Jory 'jcsston' Stone was fiddling a lot with FLAC audio in matroska currently, but encountering a lot of problems due to the way FLAC is embedded into its own framing.
He wrote here :
QUOTE
In case anybody didn't already know, I did add FLAC muxing to VDubMOD via
libflac. But it was buggy and slow because the only way to extract the
frames with libflac was to feed the decoder one byte at a time, storing the
data start and length whenever a decompressed frame was produced.
On top of that the timecodes were not always correct, some files would play
too fast others too slow. Same encode settings, same channel, sample rate,
bit-depth.
So I started a flac parser from scratch and made good progress until I hit
the UTF encoded integers.
http://flac.sourceforge.net/format.html
I have the code in the coreflac CVS if anybody wants to look at it.
http://corecodec.org/projects/coreflac/
See Ya,
Jory
libflac. But it was buggy and slow because the only way to extract the
frames with libflac was to feed the decoder one byte at a time, storing the
data start and length whenever a decompressed frame was produced.
On top of that the timecodes were not always correct, some files would play
too fast others too slow. Same encode settings, same channel, sample rate,
bit-depth.
So I started a flac parser from scratch and made good progress until I hit
the UTF encoded integers.
http://flac.sourceforge.net/format.html
I have the code in the coreflac CVS if anybody wants to look at it.
http://corecodec.org/projects/coreflac/
See Ya,
Jory
Here my questions to you experts :
- Is there a more suitable lib than libflac if you dont want to decode a FLAC stream, but only plan to extract the data from its framing and mux into another container ?
- how was OggFLAC done ? Is there any specific lib for OggFLAC that is probably more suited for our purpose ?
- how about other lossless codecs like Wavpack or Optimfrog ? Do they have existing GPL libs that allow easy demuxing from their own framing ?
Thanks for you help anyhow ...
Christian
EDIT :
Shortly after having posted i realized that maybe our problem is not obvious for people who dont have a background in MKV :
Muxing any audio or video format into a MKV file, it is required by the specs to put exactly one frame of data into a single matroska block ( lacing or so-called 'timeslices' are exceptions to the rule, but following other strict rules instead ) and each block gets a timestamp, usually with a 1 ns precision ( scalable ).
So, to mux FLAC into MKV we need a parser who can read FLAC streams, finds out about the frame boundaries ( hopefully without having to decode the complete stream, to save CPU ) and then defines a complete matroska block with a timestamp that represents the playback starting time of this frame. It seems that libflac can not provide this type of information without having to decode the FLAC stream ( reminds us about Ogg somehow
Of course, this is no problem if we capture into MKV with a FLAC encoder filter, as then we can easily find out when a new frame starts, and put this into the MKV file together with the appropriate timestamp ( to come later).