xiph / flac

Free Lossless Audio Codec
https://xiph.org/flac/
GNU Free Documentation License v1.3
1.67k stars 282 forks source link

.WAV files are deleted after decoding attempt #763

Open hat3k opened 3 days ago

hat3k commented 3 days ago

Hello. In case you accidentally try to decode .WAV instead of .FLAC there is an error shown:

_ERROR while decoding metadata state = FLAC__STREAM_DECODER_END_OFSTREAM Press any key to continue . . . and .WAV file disappears.

build is taken here https://github.com/xiph/flac/actions/runs/11893043149

ktmf01 commented 3 days ago

Please provide the command used and the whole output

hat3k commented 3 days ago

C:\test>flac.exe -d -f 1.flac

flac 1.4.3 Copyright (C) 2000-2009 Josh Coalson, 2011-2024 Xiph.Org Foundation flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details.

1.flac: done

C:\test>flac.exe -d -f 1.wav

flac 1.4.3 Copyright (C) 2000-2009 Josh Coalson, 2011-2024 Xiph.Org Foundation flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Type `flac' for details.

1.wav: ERROR while decoding metadata state = FLAC__STREAM_DECODER_END_OF_STREAM

C:\test>

ktmf01 commented 1 day ago

Thanks. This behaviour is expected although a little 'clumsy'. I'll look into it.

H2Swine commented 7 hours ago

I had started looking into flac.md, and maybe I should open an entire new issue on the help file and the handling of input files, but this behaviour is at least at odds with it. This example shows that at least when -d is used, flac assumes a .wav file with RIFF WAVE headers to be FLAC even still - and that is contrary to this text:

flac assumes that files ending in “.wav” or that have the RIFF WAVE header present are WAVE files, files ending in “.w64” or have the Wave64 header present are Wave64 files, files ending in “.rf64” or have the RF64 header present are RF64 files, files ending in “.aif” or “.aiff” or have the AIFF header present are AIFF files, files ending in “.flac” or have the FLAC header present are FLAC files and files ending in “.oga” or “.ogg” or have the Ogg FLAC header present are Ogg FLAC files.

So I tested the following: copied a flacfile.flac to flacfile.wrongextension.aiff, flacfile.wrongextension.wav, flacfile.wrongextension.w64, flacfile.wrongextension.rf64, flacfile.wrongextension.ogg and flacfile.wrongextension.oga. Then tried to flac -d each of them. The four former produced .wav output. The two latter did not. On the other hand, "re-encoding" works for all. (Putting "re-encoding" in quotation marks, because nothing is overwritten when the original extension wasn't ".flac" - even if it is ".fla", it doesn't replace files.)

Which brings me to asking what the encoder/decoder actually does under all circumstances (hm, does foreign metadata change anything?) - and maybe ask whether something is pending a change, rather than writing an elaborate help file text that is about to become obsolete.

(Honestly it looks puzzling that if it knows headers, it relies on filenames; if it knows headers, it doesn't need filename - and if it doesn't know the headers of the file, it cannot use the filename for anything?)