On Dec 14, 2014, at 10:02 AM, lvqcl <lvqcl.mail at gmail.com> wrote:> Currently the header of a decoded WAV file can be different to the > original WAV file because FLAC doesn't preserve 'fmt ' chunk. > > For example: create a 24-bit stereo .wav file with WAVEFORMATEXTENSIBLE > header with channel mask == 3. Encode it to .flac then decode back to .wav. > FLAC creates a 24-bit stereo .wav file with WAVEFORMATEX header.Did you try this when using the FLAC command-line option --keep-foreign-metadata? I did not write the code for that option, but I did write a proposal for a method that would have allowed the header to be preserved for either WAV or AIFF. I'm not sure what was implemented, though, and I have not tested whether abnormal WAV headers are preserved. If --keep-foreign-metadata is not used, then nothing is preserved from the original WAV except the audio. Brian Willoughby
Brian Willoughby wrote:>> Currently the header of a decoded WAV file can be different to the >> original WAV file because FLAC doesn't preserve 'fmt ' chunk. >> >> For example: create a 24-bit stereo .wav file with WAVEFORMATEXTENSIBLE >> header with channel mask == 3. Encode it to .flac then decode back to .wav. >> FLAC creates a 24-bit stereo .wav file with WAVEFORMATEX header. > > Did you try this when using the FLAC command-line option --keep-foreign-metadata?Yes. I created a 24-bit stereo .wav file with SoX. It writes WAVEFORMATEXTENSIBLE 'fmt ' chunk and a 'fact' chunk. FLAC keeps 'fact' chunk but writes WAVEFORMATEX header.
On Dec 14, 2014, at 5:23 PM, lvqcl <lvqcl.mail at gmail.com> wrote:> Brian Willoughby wrote: >>> Currently the header of a decoded WAV file can be different to the >>> original WAV file because FLAC doesn't preserve 'fmt ' chunk. >>> >>> For example: create a 24-bit stereo .wav file with WAVEFORMATEXTENSIBLE >>> header with channel mask == 3. Encode it to .flac then decode back to .wav. >>> FLAC creates a 24-bit stereo .wav file with WAVEFORMATEX header. >> >> Did you try this when using the FLAC command-line option --keep-foreign-metadata? > > Yes. I created a 24-bit stereo .wav file with SoX. It writes > WAVEFORMATEXTENSIBLE 'fmt ' chunk and a 'fact' chunk. FLAC keeps > 'fact' chunk but writes WAVEFORMATEX header.Thanks for checking this out. My vote: If --keep-foreign-metadata does not preserve the "header" of a RIFF/WAVE file (the header is actually a special chunk, 'fmt ', that does not always appear at the head of the file), then FLAC should be "fixed" so that this is also preserved when --keep-foreign-metadata is used. It should be as simple as saving the 'fmt ' chunk along with the others. If it's already being saved, then it should be even simpler to restore the "header" when decoding. Brian Willoughby Sound Consulting