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 Doesn't Let Me Embed This Cuesheet (Read 77022 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Flac Doesn't Let Me Embed This Cuesheet

Flac (1.1.2) doesn't let me embed the follwing cuesheet

Code: [Select]
PERFORMER "Performer Name"
TITLE "Album Title"
FILE "mytestfile.wav" WAVE
 TRACK 01 AUDIO
   TITLE "Track01 Title"
   PERFORMER "Performer Name"
   INDEX 01 00:00:00

   ...

with this error:

Code: [Select]
ERROR initializing encoder
state= FLAC_STREAM_ENCODER_INVALID_METADATA


Is this a bug or there is something wrong with my cuesheet that I can't spot?

Cheers

Sergio


Edit: spelling. If also a mod could fix the topic title... thanks! (Done, thanks to the mod!)

Edit2: removed great part of the cuesheet as the problem was not with it (see subsequent posts), to make the thread more readable.

Edit3: Modified cuesheet example so that RIAA doesn't sue me, in case I die...
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #1
Your third line reads: FILE "Nearness of You- The Ballad Book.wav" WAVE

Should it be: FILE "Nearness of You- The Ballad Book.flac" FLAC

Flac Doesn't Let Me Embed This Cuesheet

Reply #2
Quote
Your third line reads: FILE "Nearness of You- The Ballad Book.wav" WAVE

Should it be: FILE "Nearness of You- The Ballad Book.flac" FLAC
[a href="index.php?act=findpost&pid=271328"][{POST_SNAPBACK}][/a]


No, it really doesn't matter. In the past I've made plenty of tests with that and it gives you exactly the same result, bit perfect, in both cases. I've tried to change it even this time, just in case it wasn't more the case with FLAC 1.1.2, but I got the same error. 

Edit: In any case it should be:

FILE "Nearness of You- The Ballad Book.flac" WAVE  (not FLAC)
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #3
Sorry to bump this post, but I think I have some (VERY STRANGE) news.

The problem is not the cuesheet.

If I try to embed that cuesheet to another FLAC there is no problem at all.

The problem is in the WAV file, but I really can't understand what's going on.

The file is a 2 channel, 44100Hz, 16bit, PCM file.
It's size is 639,117,832 bytes.
It's length is 60 minutes and 23 seconds

If I FLAC it without cuesheet everything is OK.

If I FLAC it with *ANY* cuesheet I get the error.

Even if I decode the FLACed original to a new WAV and then I try to reFLAC the new WAV with the cuesheet embedded I get the error.

I'm really puzzled... 


Sergio
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #4
I probably cannot tell anything without having the files (WAV and FLAC).

Josh

Flac Doesn't Let Me Embed This Cuesheet

Reply #5
Quote
I probably cannot tell anything without having the files (WAV and FLAC).
[a href="index.php?act=findpost&pid=271475"][{POST_SNAPBACK}][/a]


I know, but it will not be very practical to e-mail a 610MB attachment to you...

There are alternatives:

1) the FLAC file will be enough because from that you can decode a WAV that will have the problem. This will reduce the amount of data needed from 609 to 310 MB. I can share it for you on E-Mule or I can FTP it to a server of your choice. With a bit more of work I can setup an FTP server on my PC from where you can download.

2) I can try to enucleate the RIFF header from the WAV file, stick it to a "generic" WAV file (possibly all zero samples), and see if the problem persist.

3) I can give you remote desktop or VNC access to my PC.

4) I can send you a CD by snail-mail.

5) I can act as a "longa manus" of you and do whatever you ask me to on my PC

6) whatever else comes to your mind...


Many thanks in advance.


Sergio
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #6
Quote
Quote
I probably cannot tell anything without having the files (WAV and FLAC).
[a href="index.php?act=findpost&pid=271475"][{POST_SNAPBACK}][/a]

I know, but it will not be very practical to e-mail a 610MB attachment to you...
[a href="index.php?act=findpost&pid=271512"][{POST_SNAPBACK}][/a]

try and see if you can cut a part of the wav and then encode it with that cue sheet into flac. if it fails (with that error) then you can upload ~5mb into the forum's upload section. that way it's manageble size, and still has the problem you have with the biggie.
The Plan Within Plans

Flac Doesn't Let Me Embed This Cuesheet

Reply #7
Quote
try and see if you can cut a part of the wav and then encode it with that cue sheet into flac.
....
[{POST_SNAPBACK}][/a]


Bingo! The snippet of the wav file has the same problem as the whole.

For some reason I cannot upload to here, but I've made it available at my web space:

- the first 5MB of the WAV file ([a href="http://www.smz.it/flac_cue_problem/test_small.wav]test_small.wav[/url])
- a cuesheet (test_small.cue) (but any cuesheet will do the job)

in case one wants to rebuild a synthetic WAV of the same size as my original:

- a piece to be replicated 120 times and appended to the first one (test_wav.2)
- the last 4619KB (test_wav.122) to be appended at the end.

Thanks!

Sergio

Edit: formatting, spelling.
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #8
Does anybody knows a tool to validate the structure of a WAV file?

If my file is "correct" it will definitely be the case of a weired FLAC bug...


Sergio
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #9
I just tested your WAVE and CUE and got the same result.

However, I then tried the CUE with a WAVE I have kicking about, and still got the same result/error.

I tried it with another WAVE with another CUE and it worked fine.  I tried the new CUE with my "bad" WAVE and it didn't work.  I have therefore concluded that it is the WAVE files (as I think we knew).

I have just converted a small MP3 I had kicking about to WAV using foobar, and got the same error.  If I convert the file to FLAC and then back again to WAVE I still get the error, so I have uploaded it to my webspace (I can't upload to HA as it is a Zuton's track at 37 seconds).  Please feel free to download, convert to WAVE and try adding a cuesheet using FLAC --cuesheet=<x> untitled.wav.  Please delete after testing though.

I used METAFLAC to add the cuesheet using --import-cuesheet-from and it seems to have worked (I'm not familiar with METAFLAC or FLAC).  If I do METAFLAC --list I get:

Code: [Select]
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minumum blocksize: 4608 samples
  maximum blocksize: 4608 samples
  minimum framesize: 3261 bytes
  maximum framesize: 11467 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 1668096
  MD5 signature: 875b837e0fcf8df4f5a8f97292d97d6a
METADATA block #1
  type: 3 (SEEKTABLE)
  is last: false
  length: 90
  seek points: 5
    point 0: sample_number=0, stream_offset=0, frame_samples=4608
    point 1: sample_number=552960, stream_offset=892787, frame_samples=4608
    point 2: sample_number=880128, stream_offset=1585974, frame_samples=4608
    point 3: sample_number=1110528, stream_offset=2085320, frame_samples=4608
    point 4: sample_number=1764000, stream_offset=0, frame_samples=0
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 40
  vendor string: reference libFLAC 1.1.2 20050205
  comments: 0
METADATA block #3
  type: 5 (CUESHEET)
  is last: false
  length: 576
  media catalog number:
  lead-in: 88200
  is CD: true
  number of tracks: 4
    track[0]
      offset: 0
      number: 1
      ISRC:
      type: AUDIO
      pre-emphasis: false
      number of index points: 1
        index[0]
          offset: 0
          number: 1
    track[1]
      offset: 882000
      number: 2
      ISRC:
      type: AUDIO
      pre-emphasis: false
      number of index points: 1
        index[0]
          offset: 0
          number: 1
    track[2]
      offset: 1764000
      number: 3
      ISRC:
      type: AUDIO
      pre-emphasis: false
      number of index points: 1
        index[0]
          offset: 0
          number: 1
    track[3]
      offset: 1668096
      number: 170 (LEAD-OUT)
METADATA block #4
  type: 1 (PADDING)
  is last: true
  length: 3480

Edit: link to FLAC file removed
I'm on a horse.

Flac Doesn't Let Me Embed This Cuesheet

Reply #10
Quote
Does anybody knows a tool to validate the structure of a WAV file?
[a href="index.php?act=findpost&pid=271787"][{POST_SNAPBACK}][/a]


If it plays on most players, it should be pretty valid, unless FLAC is being too strict (wouldn't surprise me)

Flac Doesn't Let Me Embed This Cuesheet

Reply #11
Quote
Quote
Does anybody knows a tool to validate the structure of a WAV file?
If it plays on most players, it should be pretty valid, unless FLAC is being too strict (wouldn't surprise me)
I used foobar to convert the MP3 to WAVE, and I would trust foobar with my baby.
I'm on a horse.

Flac Doesn't Let Me Embed This Cuesheet

Reply #12
I see the problem, but I'm not sure what to do about it.  here's the problem:

1. the wave file has a number of samples that is not evenly divisible by 588, i.e. not a full CD sector

2. when importing a cuesheet, flac creates a 'leadout' track for the cuesheet implicitly based on the size of the wave file, since cuesheets do not explicitly describe the leadout track.

3. when flac is told to apply a cuesheet to a file, if the input is 2 channels, 16 bps, and 44.1kHz it assumes that the cuesheet is applying to CD-DA and applies more strict checks to it.

4. flac sees a leadout track that is not on a sector boundary and complains that it is invalid in a vague way.

5. metaflac --import-cuesheet-from works because it is not as strict at checking against the CD-DA spec (it actually should be as strict, that's a bug), namely it does not check that the leadout is on a sector boundary.

maybe flac/metaflac need an option to tell it to not check the CD-DA subset on a cuesheet.

Josh

Flac Doesn't Let Me Embed This Cuesheet

Reply #13
Josh, thank-you for analyzing the problem.

Here are my considerations about it:

Quote
1. the wave file has a number of samples that is not evenly divisible by 588, i.e. not a full CD sector

Being evenly divisible by 588 is not required by the WAV standard, AFAIK.

Quote
2. when importing a cuesheet, flac creates a 'leadout' track for the cuesheet implicitly based on the size of the wave file, since cuesheets do not explicitly describe the leadout track.

I can't understand that. If the cuesheets "standard" doesn't calls for an explicitly defined leadout, why should FLAC do? I've always thought FLAC as a lossless codec, bit perfect, independently of the content and/or size of my input file. I've thought of the embedded cuesheet just as metatdata to be parsed by an external application, associated to specific seekpoints. And shouldn't be the businness of a CD burning (or emulation) application to eventually deal with a possibly incomplete last sector of the PCM stream?

Quote
3. when flac is told to apply a cuesheet to a file, if the input is 2 channels, 16 bps, and 44.1kHz it assumes that the cuesheet is applying to CD-DA and applies more strict checks to it.

It shouldn't IMHO and if I'm not missing some crucial point.

Quote
4. flac sees a leadout track that is not on a sector boundary and complains that it is invalid in a vague way.

I think the message should be made more clear... or just shuldn't be necessary at all, always IMO.

Quote
5. metaflac --import-cuesheet-from works because it is not as strict at checking against the CD-DA spec (it actually should be as strict, that's a bug), namely it does not check that the leadout is on a sector boundary.

Not a bug at all, from my point of view, at least if it doesn't have any weired side-effect in some situation I can't now foresee.

Quote
maybe flac/metaflac need an option to tell it to not check the CD-DA subset on a cuesheet.

... and this option should be made the default! 


Please take my consideration for what they are: just the opinion of an otherwise very satisfied user of your wanderful work. But  I've really the strong feeling that something is wrong with your assumptions that a FLAC file with an embedded cuesheet should obey to the rules of a CD-DA.

Cheers!

Sergio
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #14
Quote
Quote
maybe flac/metaflac need an option to tell it to not check the CD-DA subset on a cuesheet.
... and this option should be made the default! 
I would agree - add an option, but the option will be to turn on the check. (IMHO.)  Perhaps a warning could be visible without the option.  I.e.: If no option, a warning is displayed but the process continues. If option on, an error is displayed,  and the process stops.

Obviously both FLAC and METAFLAC should approach the situation in the same manner.

Well done for finding the cause so quickly Josh.
I'm on a horse.

Flac Doesn't Let Me Embed This Cuesheet

Reply #15
IMHO the assumption(s) that flac and metaflac make seem pretty reasonable.

The only way I can imagine how the number of samples could not be divisible by 588 is when you're downloading live show recordings. (edit: or using broken ripping programs)

One vote for strict checking as the default, with a little more verbose error messages when checking fails.

Flac Doesn't Let Me Embed This Cuesheet

Reply #16
Quote
...
The only way I can imagine how the number of samples could not be divisible by 588 is when you're downloading live show recordings. (edit: or using broken ripping programs)
...[a href="index.php?act=findpost&pid=272075"][{POST_SNAPBACK}][/a]
Or you do your own recording...
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #17
Quote
One vote for strict checking as the default
[a href="index.php?act=findpost&pid=272075"][{POST_SNAPBACK}][/a]


In what manner would that be an advantage to the codec user?

Flac Doesn't Let Me Embed This Cuesheet

Reply #18
the majority of cuesheet use is via cuesheets ripped from CD-DA, hence the current default towards checking.

Josh

Flac Doesn't Let Me Embed This Cuesheet

Reply #19
Quote
the majority of cuesheet use is via cuesheets ripped from CD-DA
[a href="index.php?act=findpost&pid=272125"][{POST_SNAPBACK}][/a]


The majority, not all of them.

Quote
hence the current default towards checking.


Why checking? That's completely out of the scope of a lossless compressor (I.E, detecting if the original WAV has the correct lenght). People should use an external tool if they want to know if their WAV has a multiple of 588 samples or not (foobar can do that).

Such strictness is just anal, IMO (specially considering there are other sources of CUE files, E.G, hand-made cues done on audio editors), and doesn't help the user in any way whatsoever, this thread being a good proof of it.


Flac Doesn't Let Me Embed This Cuesheet

Reply #21
Quote
The cuesheet format screams out "CD-DA". Timestamps are in CD frames.

Hence the checking.[a href="index.php?act=findpost&pid=272278"][{POST_SNAPBACK}][/a]

Correct. We are not talking about screwing up the cuesheet standard introducing the possiblity to add non frame aligned timestamps, not at all. We are talking about a lossless codec arbitrarily adding (virtual) data at the end of a stream. Not very lossless, IMHO.

@rjamorim:
I think this fact should be evidenced in your "Which is the best lossless codec?" thread . Don't you? And while I'm at that, though totally OT, I think that also the borked LA foobar component should be evidenced there.

Sergio

Edit: spelling. Sh*t, my english is getting worse and worse... 
Sergio
M-Audio Delta AP + Revox B150 + (JBL 4301B | Sennheiser Amperior | Sennheiser HD598)

Flac Doesn't Let Me Embed This Cuesheet

Reply #22
I agree with rjamorim and smz. FLAC is making assumptions that, with my limited knowledge, I don't think are necessary. Cue sheets don't have any kind of information regarding the end of the last track, so FLAC should only check if all tracks defined in the cue sheet are possible within the duration of the flac file.

Quote
And shouldn't be the businness of a CD burning (or emulation) application to eventually deal with a possibly incomplete last sector of the PCM stream?


I agree. And don't most burning apps "solve"/ignore this problem by adding silent samples? This shouldn't be a problem unless someone wants to do "source file" -> Audio CD -> "source file" (burn to cd audio and being able to extract a file equal to the source file). [edit: but I believe this doesn't have anything to do with FLAC]

Cya

Flac Doesn't Let Me Embed This Cuesheet

Reply #23
Er, correction. I wrote:

Quote
Cue sheets don't have any kind of information regarding the end of the last track, so FLAC should only check if all tracks defined in the cue sheet are possible within the duration of the flac file.


This is wrong, what I mean is that FLAC should only check if the cue sheet duration is not bigger than the FLAC file duration.

Flac Doesn't Let Me Embed This Cuesheet

Reply #24
Quote
<snip> what I mean is that FLAC should only check if the cue sheet duration is not bigger than the FLAC file duration.
I don't think it does check the cuesheet duration against the WAV duration.
I'm on a horse.