DrKLO/Telegram · error · FlacDecoderException
Initialization data must be of length 1
Error message
Initialization data must be of length 1
What it means
FlacDecoder's constructor throws FlacDecoderException('Initialization data must be of length 1') unless the initializationData list contains exactly one entry — that entry being the FLAC file/stream header used to bootstrap the native decoder. Any other length means the decoder cannot locate the stream header.
Source
Thrown at TMessagesProj/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java:60
* Creates a Flac decoder.
*
* @param numInputBuffers The number of input buffers.
* @param numOutputBuffers The number of output buffers.
* @param maxInputBufferSize The maximum required input buffer size if known, or {@link
* Format#NO_VALUE} otherwise.
* @param initializationData Codec-specific initialization data. It should contain only one entry
* which is the flac file header.
* @throws FlacDecoderException Thrown if an exception occurs when initializing the decoder.
*/
public FlacDecoder(
int numInputBuffers,
int numOutputBuffers,
int maxInputBufferSize,
List<byte[]> initializationData)
throws FlacDecoderException {
super(new DecoderInputBuffer[numInputBuffers], new SimpleDecoderOutputBuffer[numOutputBuffers]);
if (initializationData.size() != 1) {
throw new FlacDecoderException("Initialization data must be of length 1");
}
decoderJni = new FlacDecoderJni();
decoderJni.setData(ByteBuffer.wrap(initializationData.get(0)));
try {
streamMetadata = decoderJni.decodeStreamMetadata();
} catch (ParserException e) {
throw new FlacDecoderException("Failed to decode StreamInfo", e);
} catch (IOException e) {
// Never happens.
throw new IllegalStateException(e);
}
int initialInputBufferSize =
maxInputBufferSize != Format.NO_VALUE ? maxInputBufferSize : streamMetadata.maxFrameSize;
setInitialInputBufferSize(initialInputBufferSize);
}
@OverrideView on GitHub (pinned to 45ab8f4308)
Solutions
- Ensure the FLAC extractor supplies exactly one initialization entry containing the full FLAC stream header.
- Validate initializationData.size()==1 before instantiating FlacDecoder.
- Use the platform FLAC decoder or re-extract the stream if the header cannot be supplied as a single entry.
Example fix
// before new FlacDecoder(nIn, nOut, maxIn, /* size 0 or 2 */ init); // after checkArgument(init.size() == 1, "FLAC init must be a single header entry"); new FlacDecoder(nIn, nOut, maxIn, init);
Defensive patterns
Strategy: validation
Validate before calling
// enforce the single-entry invariant before constructing
checkArgument(initializationData.size() == 1,
"FLAC init must contain exactly one header entry");
new FlacDecoder(nIn, nOut, maxIn, initializationData); Try / catch
try { new FlacDecoder(nIn, nOut, maxIn, init); }
catch (FlacDecoderException e) { /* fall back to platform FLAC decoder */ } Prevention
- Use the FLAC extractor to produce exactly one header entry.
- Validate init size before instantiation.
- Never synthesize multiple init entries for FLAC.
When it happens
Trigger: Constructing FlacDecoder with an initializationData list whose size() != 1 (zero entries, or more than one entry, e.g. because multiple headers were collected).
Common situations: A FLAC extractor or source providing zero or multiple initialization entries; a malformed FLAC stream whose header was split or absent; feeding non-FLAC initialization data.
Related errors
- Failed to decode StreamInfo
- Failed to load decoder native libraries.
- Failed to initialize decoder
- Cannot decode FLAC frame
- Cannot read frame at position {lastDecodePosition}
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/8b1a0dd396c0206f.
Report an issue: GitHub.