Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Flac Decoding Errors (Read 3515 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Flac Decoding Errors

I have a .flac file which refuses to decode.

This happened after I fiddled with metaflac trying to add vorbis-comments, not sure about the error it gave me, but it was something of that below (FLAC__METADATA_CHAIN_STATUS_BAD_METADATA).

flac -d file.flac

Code: [Select]
file.flac: ERROR while decoding data
          state = 4:FLAC__STREAM_DECODER_END_OF_STREAM


flac -d --decode-through-errors file.flac
Code: [Select]
file.flac: ERROR while decoding data
          state = 4:FLAC__STREAM_DECODER_END_OF_STREAM


metaflac --list file.flac
Code: [Select]
file.flac: ERROR: reading metadata, status = "FLAC__METADATA_CHAIN_STATUS_BAD_METADATA"


If I play the file in Winamp it first pops out:
Code: [Select]
ERROR: invalid/missing FLAC metadata

then
Code: [Select]
ERROR processing metadata
FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR


Looking at the file in a hex-editor it seems fine... The id "fLaC" is there, a seeking block and a padding-block then comes the audio data...

Is there anyway to restore my file? It was perfectly fine before I used metaflac, at least it played fine in winamp. But the file could have corrupt metadata-headers and because of that metaflac trashed the flac-header?

Using flac & metaflac 1.0.4 but the file was encoded with an older version.

Edit:

Did some more testing, did a basic flac-metadata-reader according to the specs

Code: [Select]
Block nr 0
Offset: 4
BLOCK_TYPE: 0 (STREAMINFO)
Size: 34
-------------
Block nr 1
Offset: 42
BLOCK_TYPE: 3 (SEEKTABLE)
Size: 236
-------------
Block nr 2
Offset: 282
BLOCK_TYPE: 0 (STREAMINFO)
Size: 27
-------------
Block nr 3
Offset: 313
BLOCK_TYPE: 5
Size: 1179648


Because there can only be one STREAMINFO block, and BLOCK_TYPE 5 is undefined, and no block has "Last-metadata-block flag" set, I know what's wrong here. Hmm let's see if I can hex-edit those blocks out or something...

Edit2:

Noticed that the size of the SEEKTABLE-block was always 1800 bytes, so when I changed it in file.flac, it worked!

Code: [Select]
Block nr 0
Offset: 4
BLOCK_TYPE: 0 (STREAMINFO)
Size: 34
-------------
Block nr 1
Offset: 42
BLOCK_TYPE: 3 (SEEKTABLE)
Size: 1800
-------------
Block nr 2
Offset: 1846
BLOCK_TYPE: 1 (PADDING)
Last Block
Size: 1560
-------------


flac -d --decode-through-errors file.flac

Code: [Select]
file.flac: *** Got error code 0:FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC
file.flac: WARNING, MD5 signature mismatch


The file plays fine! There is no audible pop or anything, looked at the file in cool edit and it was perfectly fine!

Now I willl do some testing to see if there was a bug in metaflac...

Hopefully this thread will be useful if someone else is having problems!

Edit3:

Ok it was a confirmed bug... I did use --import-vc-from=- to add comments...
Quote
*   metaflac has a bug where, if --import-vc-from is used on a FLAC file that has no Vorbis comment block, the FLAC file can be corrupted. All FLAC files generated by 1.0.4 have a Vorbis comment block added automatically but files from 1.0.3 and before do not. This is fixed in CVS.

Flac Decoding Errors

Reply #1
Sorry about that.  If you don't mind compiling, you can get the flac 1.0.4 sources and replace src/metaflac/main.c with

http://cvs.sourceforge.net/cgi-bin/viewcvs...main.c?rev=1.47

You can see the diffs here:

http://cvs.sourceforge.net/cgi-bin/viewcvs...r1=1.45&r2=1.47

CVS is slightly unstable while I add the ReplayGain and cuesheet stuff but I plan to have a 1.0.5 with the fixes soon (maybe 3 weeks).

Josh