Hydrogenaudio Forums

Lossless Audio Compression => FLAC => Topic started by: CyberTootie on 08 October, 2017, 01:38:54 PM

Title: FLAC reported length
Post by: CyberTootie on 08 October, 2017, 01:38:54 PM
Any ideas on how to change the reported length (time) of a FLAC file? Basically, I want to hide content at the end of the file.
Title: Re: FLAC reported length
Post by: saratoga on 08 October, 2017, 02:09:26 PM
I think you could edit the samples field in the METADATA_BLOCK_STREAMINFO block:

https://xiph.org/flac/format.html

Some software may still be able to seek to the hidden audio though.
Title: Re: FLAC reported length
Post by: CyberTootie on 09 October, 2017, 08:15:32 PM
Thanks. That does look like what I'm looking for. But after looking around for tools and trying to open a FLAC in a HEX editor, it's evident that this is currently over my head. Any way I can be pointed in the right direction on how to figure out how to do that?
Title: Re: FLAC reported length
Post by: saratoga on 09 October, 2017, 09:25:42 PM
Right direction meaning an existing tool to do this?  I don't know why that would exist.  I think you'll have to work it out from the spec or the flac source code.
Title: Re: FLAC reported length
Post by: CyberTootie on 27 October, 2017, 03:33:55 AM
Thanks again. I figured it out. For reference, the reported length in samples should be the 2nd half of HEX block 15 through 19 (in total 36 bits) in any standard FLAC file.

Unfortunately, what I hoped would be the case, where the player would continue to play beyond the reported length, appears to not be standard player behavior. Oddly, the file integrity scanner does find a reported length mismatch, but appears to ignore all blocks beyond the reported length, finding only a fraction of a second difference despite an actual difference of a few minutes. Also, the displayed bitrate takes into account the entire file and not just the reported length.
Title: Re: FLAC reported length
Post by: Porcus on 27 October, 2017, 04:41:21 AM
Does it have to be at the "rear end"? ;)  I wonder if you can hide it in a padding block?
It would be easily lost though.

Edit: METADATA_BLOCK_APPLICATION, maybe?  There was an apparently short-lived utility that would attach anything in that block: https://directory.fsf.org/wiki/FlacFile ... and others too, I see.
Title: Re: FLAC reported length
Post by: CyberTootie on 27 October, 2017, 10:44:21 AM
I was aiming for a kind of "hidden track"-type functionality where the player would report a length but would continue to play beyond said length.