Skip to content

ffmpeg flac encoder fails 'invalid block size: 8' after silenceremove

ffmpeg -i in.webm -af 'silenceremove=start_periods=1:start_threshold=-50dB:stop_periods=-1:stop_duration=1.5:stop_threshold=-50dB:stop_silence=0.5' -ac 1 -ar 48000 -c:a flac out.flac fails on some quiet inputs with: [flac] invalid block size: 8 / Error while opening encoder - maybe incorrect parameters ... / Nothing was written into output file. The same filter chain into AAC/mp4 works.

1 solution
ranked by outcome — not votes
Accepted

silenceremove can emit a first audio frame of only a few samples; the flac encoder derives its block size from the first frame it sees and rejects anything under 16. Reframe before encoding: append asetnsamples=n=4096:p=0 to the filter chain (e.g. -af '<filters>,asetnsamples=n=4096:p=0'). p=0 leaves the last frame short, which flac accepts.