[Flac] Fixing corrupt flac files

Martijn van Beurden mvanb1 at gmail.com
Sun Jan 13 14:12:47 PST 2013


On 10-01-13 23:01, Knut Krause wrote:
> [...]
> 01 Linke Spießer.flac: testing, 94% complete
> 01 Linke Spießer.flac: ERROR while decoding data
>                          state = FLAC__STREAM_DECODER_END_OF_STREAM
> [...]
> 05 Ihr seid schön.flac: ERROR, MD5 signature mismatch
> [...]
> 07 Nazis raus.flac: testing, 96% complete07 Nazis raus.flac: *** Got error code
> 1:FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER
> 07 Nazis raus.flac: *** Got error code
> 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
> 07 Nazis raus.flac: ERROR while decoding data
>                      state = FLAC__STREAM_DECODER_READ_FRAME
> [...]
> 10 Die Letzten.flac: testing, 98% complete10 Die Letzten.flac: *** Got error
> code 2:FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH
> 10 Die Letzten.flac: ERROR while decoding data
>                       state = FLAC__STREAM_DECODER_READ_FRAME
>
> 11 Etikette tötet.flac: testing, 97% complete11 Etikette tötet.flac: *** Got
> error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
> 11 Etikette tötet.flac: *** Got error code
> 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
> 11 Etikette tötet.flac: ERROR while decoding data
>                           state = FLAC__STREAM_DECODER_READ_FRAME

This is really weird: all kinds of different errors, but indeed all in 
the last few percent. The small part you send looks fine: there's 
probably a corruption somewhere, but it's not obvious. The strange thing 
is that the frame it happened is actually the frame of the fade-out: all 
previous frames contain audio, the frames that follow it are all zero.

There is no (feasible) way to fix this, unfortunately. If tried to find 
the cause of the problem, but I can't be conclusive. First: in the 
changelog for FLAC 1.1.3 there is this entry:

> Fixed a bug where sync error at end-of-stream of truncated files was 
> not being caught

It might be that your ripper produced not properly terminated files 
which 'silently chrashed' FLAC. It might be k3b (if you indeed used that 
program as for ripping) as it has had some issues with FLAC encoding and 
decoding in the past (I've had some of those problems myself) see here: 
https://bugs.kde.org/buglist.cgi?bug_status=__all__&product=k3b&content=flac

I think this is the only possible explanation: this can't be failing 
storage media or file transfer methods, it's just too regular, so this 
problem has to have occurred at encoding them.

> I wrote a little script checking my whole collection for corrupt files using
>
> flac -wst "$1" 2>/dev/null || printf '%3d %s\n' "$?" "$1"
>
> in a little find/bash script. I can run batch checks and provide output as
> needed :-)

Did you find more corrupt files?

Anyway, I'll send this case to the developers, they might find a cause, 
but I think your files can't be fixed, you'll have to re-rip them or 
re-encode them without the last tenths of a second of the file.


More information about the Flac mailing list