[flac-dev] How to get FLAC frame length

Martijn van Beurden mvanb1 at gmail.com
Mon Feb 1 01:44:58 PST 2016


Op 31-1-2016 om 8:48 schreef Dongfu He:
> So from above infomation, we'll know this frame has 4096 samples, and 
> sample size is 16 bits per sample. That means this frame length is at 
> least(ignore subframe header and frame footer,etc.) 4096 * 16 / 8 = 
> 8192 bytes. But if I check the FLAC file manually, the offset gap of 
> first and second frame is only 2976 bytes, this means the frame length 
> of first frame is only 2976 bytes. Is there anything wrong for my 
> calculation?
>
> My purpose is get frame offset and frame length of every frame, is 
> there any good way? I know there is sync code 0xFF F8, but it's very 
> low efficiency. Thanks in advance!
>

The frame length you calculated (8192 bytes) is that of the decoded 
frame, not of the FLAC frame. As it is compressed, it should be indeed 
smaller than 8192 bytes.

There is no direct way to find the frame length except finding where the 
next frame starts.


More information about the flac-dev mailing list