Re: Fixing corrupt flac files

Martijn van Beurden <[email protected]> Sun, 13 Jan 2013 23:12:47 +0100
Newsgroups gmane.comp.audio.compression.flac.user
Message-ID <[email protected]>
On 10-01-13 23:01, Knut Krause wrote:
> [...]
> 01 Linke Spie=DFer.flac: testing, 94% complete
> 01 Linke Spie=DFer.flac: ERROR while decoding data
>                          state =3D FLAC__STREAM_DECODER_END_OF_STREAM
> [...]
> 05 Ihr seid sch=F6n.flac: ERROR, MD5 signature mismatch
> [...]
> 07 Nazis raus.flac: testing, 96% complete07 Nazis raus.flac: *** Got erro=
r 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 =3D FLAC__STREAM_DECODER_READ_FRAME
> [...]
> 10 Die Letzten.flac: testing, 98% complete10 Die Letzten.flac: *** Got er=
ror
> code 2:FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH
> 10 Die Letzten.flac: ERROR while decoding data
>                       state =3D FLAC__STREAM_DECODER_READ_FRAME
>
> 11 Etikette t=F6tet.flac: testing, 97% complete11 Etikette t=F6tet.flac: =
*** Got
> error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
> 11 Etikette t=F6tet.flac: *** Got error code
> 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
> 11 Etikette t=F6tet.flac: ERROR while decoding data
>                           state =3D 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=3D__all__&product=3Dk3b&content=
=3Dflac

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 us=
ing
>
> 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.