marytts / java-flac-poc

0 stars 2 forks source link

Decode specific time spans #7

Open psibre opened 8 years ago

psibre commented 8 years ago

We need to be able to decode specific time spans, either by sample numbers or timestamps (in seconds or similar) from the FLAC.

Rootex commented 8 years ago

@psibre

I think sox slice differently from what i am currently doing, for instance i slice with sox say first 4 seconds, and with our current program. I get slight differences between the files, however when you play you clearly see they start at same point and have same duration as specifies

SOX slicing first 4 seconds: File Size: 264.6KB , Samples length: 132300 POC slicing first 4 seconds: File Size: 267.3KB, Samples length: 133632

This is just a visual comparison thus the test will never pass, however i don't know if my calculations are off (Looking into that).

2.

I have been trying to figure out this Stream Sync problem, i know that the exception is thrown from jflac library but why i am yet to figure out, however if you have any insight that might change my thinking or approach towards debugging this please let me know.

psibre commented 8 years ago

Let's do this:

  1. Create a test resource FLAC file of 1 s duration, 16 kHz, with one seekpoint at sample 5000, and another at sample 13000.
  2. Slice it up into three parts.
  3. Test that you can decode
  4. from SP1 to SP2,
  5. from the start to SP1, and
  6. from SP2 to the end, in that order.

This may be a feasible solution.

Rootex commented 8 years ago

Seekpoint

The method to decode by passing sample number will not work because, we don't know the Streamoffset, or which frames our seekpoints overlap into. However, after creating the seekpoints, we know that the ordering and thus get the seekpoint based on index number in the seektable.

Once that is gotten, we can thus get the samplenumber, streamoffset and framesamples to create the seekpoints to and from thus decoding only those segments.

The tests for this slices is not per-say the best, because i couldnt find a tool that can slice the flac file based on number of samples, so i instead test against if the file is readable or corrupted. But i also manually analysed the sliced files to make sure they are not just corrupted files.