Martijn van Beurden
2022-Nov-02 12:48 UTC
[flac-dev] Looking for users of --keep-foreign-metadata
Op ma 31 okt. 2022 om 01:37 schreef brianw <brianw at audiobanshee.com>:> - There is a generally-accepted industry practice concerning these extra chunks that points out that it's problematic to preserve all types of chunks when editing the audio. For example, a visual overview or a cue list might easily become incorrect if the audio is changed. Of course, there are some chunks that can always be preserved, like original recording date, name of engineer, etc., but FLAC cannot know how to distinguish between the two types. My opinion is that FLAC should not suffer from this category of issues because the audio is specifically unchanged by the compression. Thus, it should be the case that all meta data can be preserved without risk, since the audio is also preserved exactly. >Perhaps FLAC should refuse to do operations like --skip or --until on a file with foreign metadata embedded? I don't think it blocks that currently. What I think would be a nice option is pick the correct format according to the stored foreign metadata. Currently, one can use flac --keep-foreign-metadata somefile.aiff without problems, but flac --keep-foreign-metadata somefile.flac will then fail because flac tries to restore to wav by default. Also, there are the mentioned problems with WAVE_FORMAT_PCM and WAVE_FORMAT_EXTENSIBLE. One possible solution is adding an option --force-foreign-metadata-format (similar to the --force-aiff-format, --force-rf64-format, etc. options) which would then pick a format according to what is stored in the foreign metadata. This could work two ways: it could simply instruct FLAC to find which format should be written to, or it could instruct FLAC to not construct any chunks of its own but exclusively use the stored chunks.> > Reading your email question, Martijn, I think you might be asking whether FLAC should always preserve meta data - "restore ... bit-for-bit ... something that FLAC should strive for" - or leave this as an optional feature, so I want to comment on the two scenarios: >Considering being bit-for-bit accurate, I might be opening Pandora's box here, but I think this should be dealt with properly, so I'll do it anyway The thing is, FLAC will store all chunks (except the contents of the data chunk) on encoding, but currently ignores the master chunk, the format chunk and the header of the data chunk on decoding. Usually the result is still bit-for-bit the same (because there is usually no ambiguity in how those chunks are formatted) but perhaps (I really don't know, don't know whether such a thing is even possible) there are cases where FLAC reconstructs something different than what is stored. Choosing between WAVE_FORMAT_PCM and WAVE_FORMAT_EXTENSIBLE is one such difference, but there might be others. That is why I'm reaching out: perhaps the answer is obvious to people that use this feature daily. Perhaps an option --force-stored-foreign-metadata could be added to have FLAC blindly use the foreign metadata chunks and data chunk headers. I think this might result in invalid files (wrong chunk sizes) in corner cases, for example when a FLAC file has been altered (shortened/lengthened) but the chunks haven't been updated. I think that might be the reason for the current behaviour.> p.p.s. AIFF > I cannot remember whether --keep-foreign-metadata works with AIFFYes, it does. It works with plain WAV and AIFF, and also with RF64 and Wave64.
Martijn van Beurden
2022-Nov-02 18:20 UTC
[flac-dev] Looking for users of --keep-foreign-metadata
Op wo 2 nov. 2022 om 13:48 schreef Martijn van Beurden <mvanb1 at gmail.com>:> Perhaps an option --force-stored-foreign-metadata could be added to > have FLAC blindly use the foreign metadata chunks and data chunk > headers. I think this might result in invalid files (wrong chunk > sizes) in corner cases, for example when a FLAC file has been altered > (shortened/lengthened) but the chunks haven't been updated. I think > that might be the reason for the current behaviour. >Perhaps the middle ground here is to let FLAC output as it does now, but warn the users when it differs from what is stored?
Federico Miyara
2022-Nov-02 20:54 UTC
[flac-dev] Looking for users of --keep-foreign-metadata
Considering that 1) audio data is always (I believe...) in a single connected block, 2) its location and length is unambiguously known, 3) its basic formatting information is at the header, hence readily and unambiguously known, and 4) all metadata, either native or foreign, including the header, is before or after the audio data (or both), would it be very difficult to just store all the information before and after the audio, even compress it with any content-unaware algorithm such as LZW, compress the audio with FLAC's algorithm and when decoding restore each block (pre-audio metadata, audio, and post-audio metadata) at its correct location? This would provide bit-for-bit accuracy, even for inconsistent or ill-formed metadata, as long as the audio data is consistent, with known format and correctly located. I don't know whether this would cause backward-compatibility issues, probably yes. Regards, Federico Miyara On 02/11/2022 09:48, Martijn van Beurden wrote:> Op ma 31 okt. 2022 om 01:37 schreef brianw <brianw at audiobanshee.com>: >> - There is a generally-accepted industry practice concerning these extra chunks that points out that it's problematic to preserve all types of chunks when editing the audio. For example, a visual overview or a cue list might easily become incorrect if the audio is changed. Of course, there are some chunks that can always be preserved, like original recording date, name of engineer, etc., but FLAC cannot know how to distinguish between the two types. My opinion is that FLAC should not suffer from this category of issues because the audio is specifically unchanged by the compression. Thus, it should be the case that all meta data can be preserved without risk, since the audio is also preserved exactly. >> > Perhaps FLAC should refuse to do operations like --skip or --until on > a file with foreign metadata embedded? I don't think it blocks that > currently. > > What I think would be a nice option is pick the correct format > according to the stored foreign metadata. Currently, one can use flac > --keep-foreign-metadata somefile.aiff without problems, but flac > --keep-foreign-metadata somefile.flac will then fail because flac > tries to restore to wav by default. Also, there are the mentioned > problems with WAVE_FORMAT_PCM and WAVE_FORMAT_EXTENSIBLE. One possible > solution is adding an option --force-foreign-metadata-format (similar > to the --force-aiff-format, --force-rf64-format, etc. options) which > would then pick a format according to what is stored in the foreign > metadata. This could work two ways: it could simply instruct FLAC to > find which format should be written to, or it could instruct FLAC to > not construct any chunks of its own but exclusively use the stored > chunks. > >> Reading your email question, Martijn, I think you might be asking whether FLAC should always preserve meta data - "restore ... bit-for-bit ... something that FLAC should strive for" - or leave this as an optional feature, so I want to comment on the two scenarios: >> > Considering being bit-for-bit accurate, I might be opening Pandora's > box here, but I think this should be dealt with properly, so I'll do > it anyway > > The thing is, FLAC will store all chunks (except the contents of the > data chunk) on encoding, but currently ignores the master chunk, the > format chunk and the header of the data chunk on decoding. Usually the > result is still bit-for-bit the same (because there is usually no > ambiguity in how those chunks are formatted) but perhaps (I really > don't know, don't know whether such a thing is even possible) there > are cases where FLAC reconstructs something different than what is > stored. Choosing between WAVE_FORMAT_PCM and WAVE_FORMAT_EXTENSIBLE is > one such difference, but there might be others. That is why I'm > reaching out: perhaps the answer is obvious to people that use this > feature daily. > > Perhaps an option --force-stored-foreign-metadata could be added to > have FLAC blindly use the foreign metadata chunks and data chunk > headers. I think this might result in invalid files (wrong chunk > sizes) in corner cases, for example when a FLAC file has been altered > (shortened/lengthened) but the chunks haven't been updated. I think > that might be the reason for the current behaviour. > >> p.p.s. AIFF >> I cannot remember whether --keep-foreign-metadata works with AIFF > Yes, it does. It works with plain WAV and AIFF, and also with RF64 and Wave64. > _______________________________________________ > flac-dev mailing list > flac-dev at xiph.org > http://lists.xiph.org/mailman/listinfo/flac-dev >-- El software de antivirus Avast ha analizado este correo electr?nico en busca de virus. https://www.avast.com/antivirus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/flac-dev/attachments/20221102/b9ea29ef/attachment-0001.htm>