ftrvxmtrx / split2flac

Split flac/ape/wv/wav + cue sheet into separate tracks
252 stars 34 forks source link

Add support for internal cue sheets stored in CUESHEET metadata block of FLAC file #10

Open siebenstreich opened 10 years ago

siebenstreich commented 10 years ago

It seems that there are two ways how cue sheets are internally stored in FLAC files. The "official" way, which is produced for example by executing

flac --cuesheet=[file.cue] [file.flac]

is to store the cue sheet in a seperate metadata block in the FLAC metadata. When I execute split2flac on a FLAC file with such an "official" internal cue sheet, I get the message "No cue sheet" So I guess that this kind of internal cue sheet is not supported right now.

It would be great if support for those "official" internal cue sheets could be added to split2flac.

The CUESHEET block can be extracted with

metaflac –export-cuesheet-to=[file.cue] [file.flac]

The relevant part in the output of

metaflac --list [file.flac]

on a FLAC file with a cue sheet in a CUESHEET block looks like this, for example:

METADATA block #2 type: 5 (CUESHEET) is last: false length: 1236 media catalog number: lead-in: 88200 is CD: true number of tracks: 15 track[0] offset: 0 number: 1 ISRC: BRGI30500001 type: AUDIO pre-emphasis: false number of index points: 1 index[0] offset: 0 number: 1 track[1] offset: 11625348 number: 2 ISRC: BRGI30500002 type: AUDIO pre-emphasis: false number of index points: 1 index[0] offset: 0 number: 1 [...] track[14] offset: 155611848 number: 170 (LEAD-OUT)

Some information on the version numbers on my system:

split2flac -v split2flac version: 114

shntool 3.0.7 flac 1.2.1 oggenc from vorbis-tools 1.4.0 LAME 64bits version 3.99.5 (http://lame.sf.net)

diffycat commented 10 years ago

@mkimki , it seems that metadata block stores only index information (without title,preformer and other fields). Is it ok or I've missed something?

diffycat commented 10 years ago

Nevermind, I've found explanation: https://xiph.org/flac/faq.html#general__no_cuesheet_tags

siebenstreich commented 10 years ago

Wow, that was really fast. Thank you!! Yeah, the CUESHEET block is not for ALBUM, ARTIST ect, which probably is the reason for the existence of the second way for storing the cue sheet.

The program flactag stores this information in the following way (part of metaflac --list output):

METADATA block #3 type: 4 (VORBIS_COMMENT) is last: false length: 3585 vendor string: reference libFLAC 1.3.0 20130526 comments: 92 comment[0]: ALBUM=4321 comment[1]: ARTIST=Giana Viscardi comment[2]: ARTISTSORT=Viscardi, Giana comment[3]: DATE=2005 comment[4]: MUSICBRAINZ_ALBUMARTISTID=fbb2d494-bb5b-4e70-a288-73a87f7ca4e9 comment[5]: MUSICBRAINZ_ALBUMID=bd306992-e25b-44a7-9700-73bf0b02516e comment[6]: MUSICBRAINZ_ALBUMSTATUS=official comment[7]: MUSICBRAINZ_ALBUMTYPE=album comment[8]: TRACKNUMBER[1]=1 comment[9]: ARTIST[1]=Giana Viscardi comment[10]: ARTISTSORT[1]=Viscardi, Giana comment[11]: MUSICBRAINZ_ARTISTID[1]=fbb2d494-bb5b-4e70-a288-73a87f7ca4e9 comment[12]: MUSICBRAINZ_TRACKID[1]=2bf0af4f-d425-43b1-9af4-cadefab4e08c comment[13]: TITLE[1]=4321 comment[14]: TRACKNUMBER[2]=2 comment[15]: ARTIST[2]=Giana Viscardi comment[16]: ARTISTSORT[2]=Viscardi, Giana comment[17]: MUSICBRAINZ_ARTISTID[2]=fbb2d494-bb5b-4e70-a288-73a87f7ca4e9 comment[18]: MUSICBRAINZ_TRACKID[2]=4d4cf9bc-a369-4646-8243-8f4c3c311f85 comment[19]: TITLE[2]=Metades [...]

I don't know if this is a more widespread method to store the metadata. Do you think it is worth to be supported by split2flac?

diffycat commented 10 years ago

@mkimki , that will be more complicated than just sed one-liner. I'll try to add it, but don't know when. Also it will be interesting to add new ability to download information from musicbrainz and write it instead of cue-data.