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: [Bug Report] FLAC files that have 2000+ kbps do not play correctly  (Read 5851 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[Bug Report] FLAC files that have 2000+ kbps do not play correctly

I am using Foobar 2000 Version 2.1.5. When you play FLAC files encoded at 2000+ bit rate the file stutters or ceases to play suddenly. Some samples from the audio do play, but only for a split second.  Even when you try to convert the files into another file type Foobar2000 sees the file as corrupt. The files in question play in every other media player just fine.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #1
May be unrelated, but first try 2.1.6:
Fixed FLAC files with exotic bit depths incorrectly failing audio MD5 verification.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #2
when you try to convert the files into another file type Foobar2000 sees the file as corrupt.
Right-click, Utilities -> Verify integrity. What does it say?

And, how long have you set the buffer to?
Preferences -> Playback -> Output

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #3
I am using Foobar 2000 Version 2.1.5. When you play FLAC files encoded at 2000+ bit rate the file stutters or ceases to play suddenly. Some samples from the audio do play, but only for a split second.  Even when you try to convert the files into another file type Foobar2000 sees the file as corrupt. The files in question play in every other media player just fine.

Check these settings on fb2k:
Preferences -> Playback -> Output (I have 1000ms)
Preferences -> Playback -> Output-> Devices (I've set the output to 32bits and no DSP)
Preferences -> Advanced -> Playback -> Buffering -> Read-ahead for remote files kB (I've set 128)
Preferences -> Advanced -> Playback -> Buffering -> Read-ahead for local files kB (I've set 0)
Preferences -> Advanced -> Playback -> Buffering -> Full file buffering up to kB (I've set 0)
Preferences -> Advanced -> Playback -> Exclusive output overrides (I've unchecked it)
Preferences -> Advanced -> Playback -> Thread priority -> Thread priority (I've set it to 7)
Preferences -> Advanced -> Playback -> Thread priority -> Use MMCSS (I've checked it)
Preferences -> Advanced -> Playback -> Thread priority -> MMCSS mode: Audio
Preferences -> Advanced -> Playback -> Prevent hard disk sleep while playing (For SSD uncheck and check for HDD)

Check these settings on you DAC:
Buffer Size (I have Auto)
Latency (I have 2ms)

These settings work for me with Hi-Res files such as DXD 384KHz 32bit and DSD 256.

I am also running fb2k in High Priority CPU using registry
You need to copy these and save to a file with .REG extension and double-click to run import it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foobar2000.exe]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\foobar2000.exe\PerfOptions]
"CpuPriorityClass"=dword:00000003

Beside these you can read this MS article about MMCSS and its settings in the registry (I left it is-as after Windows installation)
https://learn.microsoft.com/en-us/windows/win32/procthread/multimedia-class-scheduler-service

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #4
You should do as Porcus said. Though I expect it will simply report the file(s) to be corrupted. If you can use command prompt you could test the files with flac.exe using -t parameter.
But from the description it sounds like the files are not normal. What does "every other media player" mean? Note that many players use ffmpeg in the background letting it handle all content parsing and decoding. That approac doesn't really care about file types, it just guesses best content handlers from the bits.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #5
2000+ kbps files play well on my end.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #6
May be unrelated, but first try 2.1.6:
Fixed FLAC files with exotic bit depths incorrectly failing audio MD5 verification.
I upgraded to that version and I have the same problem. Sorry for not replying right away. I am unsure how to proceed as I never encountered an issue like this before as this specific soundtrack always played fine for years in my old 1.6.5 version of Foobar2000.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #7
If you don't want to provide any extra data about the track, like do what Porcus suggested, then please post the entire track as a sample.
Note that the bitrate of the track has nothing to do with the problem. Something about the file is wrong and newer FLAC decoder doesn't like it.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #8
Free test tracks > 4000 kbps stereo (because they are 192 kHz): https://www.linnrecords.com/recording-download-format-test-album
Nine Inch Nails: The Slip exceeds 3000 on several tracks. Released for free download, say https://freemusicarchive.org/music/Nine_Inch_Nails/The_Slip (if that is the 96/24 version, I have not checked)

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #9
when you try to convert the files into another file type Foobar2000 sees the file as corrupt.
Right-click, Utilities -> Verify integrity. What does it say?

And, how long have you set the buffer to?
Preferences -> Playback -> Output

OH my apologies, here is the log from my attempt at verification

Item: "T:\AUDIO\AUDIO LIBRARY\[VIDEO GAME AUDIO]\Sonic Roboblast 2\105 - Greenflower Zone, Act 2.flac"
MD5: AE6A65D2EC3FCDE71C26F3D4E92C85C9
CRC32: 32C5F268
Error: Corrupted FLAC stream
Error: File appears to be incomplete
Error: MD5 mismatch
Error: Reported length is inaccurate : 2:59.114667 vs 0:17.664000 decoded

I assume all the songs apart of this album have the same issue. Some don't even play anything and Foobar2000 skips them entirely.
If it is just the album from here https://www.srb2.org/download/soundtrack/ being the issue, I apologize for any confusion.
I guess I see it as bug because I played this album for years with no issue, if the album was corrupt all along or something I'd believe it. Its just so random from my perspective.
On the plus side, the WMA version they also have on the website is probably better overall anyway.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #10
Testing the files with flac -t (flac 1.4.3) as suggested above does indeed report a lot of errors and fail, so the current version of the FLAC decoder does not like those files.

I tried re-encoding one track with ffmpeg, and that seemed to work at least, with the reported MD5 staying the same (and with a large reduction in bit rate).
.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #11
When testing with old flac.exe 1.3.4, most of files are OK, only few ones have md5 mismatch.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #12
The files are created with a bad encoder. They are 24-bit files with garbage in the unused bits. That's why they are so huge as the garbage is also included in the encodes.
I have no idea why the FLAC 1.4+ included a check for this, it seems like testing this causes a slow down and just prevents decoding files that would otherwise be fine. I have an old test FLAC from 2018 where such file caused some misbehavior in foobar2000 but I don't remember further details, but I remember it was easily solved by just nulling the garbage bits in the decoder.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #13
On the plus side, the WMA version they also have on the website is probably better overall anyway.
Note that decoding of WMA lossless is not guaranteed to be lossless on modern OS's when using Windows' built-in decoder  :D - https://hydrogenaud.io/index.php/topic,117275.0.html

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #14
A post here was enough to slashdot thewaitingroom's server it seems.
Anyway, with a soundcloud account you can download a version of that track 105 - in FLAC format. It is 2:59.115 long, has MD5 of EFAAAE6D8CB53BE4FB82909990868C57 and was encoded with reference libFLAC 1.2.1 20070917 at 1825 kbit/s. Parameters are too high for preset "-6".

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #15
... bad encoder? The official one, it seems.
At least, using official flac 1.3.1/1.3.2/1.3.4 to re-encode, gets bloated files with precisely the same error message from 1.4.x.

1.4.0 suddenly rejecting files that "everything else" decodes to the right MD5, is ... potentially a serious thing.

@ktf - is this that runaway-rice bug that produced bloat? In which case: compliant or not? In case not: Any good reason to refuse to decode, when there is a known decoding method that produces PCM with the correct MD5?

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #16
Official encoder doesn't create such files, but it doesn't fix bad input. I recall some old Reaper had a bug causing this issue. FLAC uses 32-bit buffers and for some reason encodes and decodes even the bits that aren't supposed to be there. When going to WAV the extra bits get dropped as there is no room for useless padding in WAV. But when going from FLAC to FLAC there is no such cleanup being performed.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #17
These files probably have samples exceeding the valid range. (see here) I'll check later.

edit: I see now @Case said the same thing but clearer  :))
Music: sounds arranged such that they construct feelings.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #18
Actually, I was working on clearer error messages for cases like these. With my work-in-progress I get this output

Code: [Select]
flac -t 101\ -\ Title\ Screen.flac 

flac git-e42f723b 20240912
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.

101 - Title Screen.flac: *** Got error code 5:FLAC__STREAM_DECODER_ERROR_STATUS_OUT_OF_BOUNDS after processing 0 samples
[...]

The problem is: there is no obvious way to repair these files. The easiest (although probably not the most pleasing way) to fix this is by wrapping the values: decode the FLAC file to a WAV file, then re-encode. Better would be to clip them. Even better is to lower the volume a bit, but neither of these options is lossless of course. Also, I have seen some files in which samples go more than a little out-of-bounds (like, actually using 20 bits instead of 16 or something like that). In any case, there is no way to find out how the creator reviewed those files and what the intended outcome was.

So, these files are obviously broken, and have actually been created broken. Because of that, there is no obvious way to repair them. The best way would be to ask the source to review the files and if possible re-export them, perhaps with the volume turned down slightly (or with a limiter in the signal chain), so no out-of-bounds samples get through.
Music: sounds arranged such that they construct feelings.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #19
OK, so what likely happens:
* whatever used to encode them, fed an old library (1.2.1 found) signals that exceed the 24 bit range?
* the Soundcloud file was re-encoded using 1.3.1, and 1.3.x will re-encode without checking that the signal is indeed above the 24 bits range?
* Commands ffmpeg -i "105 - Greenflower Zone, Act 2.flac" 105 - Greenflower Zone, Act 2.ffmpeg.flac" and ffmpeg -i "105 - Greenflower Zone, Act 2.flac" 105 - Greenflower Zone, Act 2.ffmpeg.wv" also re-encode. Note, this command will make a 32-bit (integer) .wv file.
* the WMAL file was likely made from the flac?

Questions then - yes they might have been asked and answered before:
* Fitting it into 32-bit integer - presuming it doesn't overshoot that range - is that any worse than any alternative? Isn't that the best guess on what was fed into the encoder?
* How was the MD5 calculated in the first place? If it was calculated on the samples, and it verifies ... ?

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #20
Questions then - yes they might have been asked and answered before:
* Fitting it into 32-bit integer - presuming it doesn't overshoot that range - is that any worse than any alternative? Isn't that the best guess on what was fed into the encoder?
Yes, that would be the best alternative, although still imperfect, because the warmup samples at the start of each frame are still wrapped.

edit: although, it might still not be what the author intended. There is no way to know whether the author reviewed those files in a player that clipped or wrapped the samples, and there is no way to know how the DAW rendered them on playback. So, there is no best way to fix these files except ask the author.
Quote
* How was the MD5 calculated in the first place? If it was calculated on the samples, and it verifies ... ?
On samples with the MSBs cut-off, in effect 'wrapped'. The MD5 calculation process placed the samples after on another, using the prescribed bit depth.
Music: sounds arranged such that they construct feelings.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #21
So, best solution available to topicstarter in this particular case, is to use old version of fb2k to re-encode files.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #22
OK, so MD5 is likely computed on wrapped samples. What about the verify option as of 1.2.1 and 1.3.x? Wrap the input PCM it is compared to?

Questions then - yes they might have been asked and answered before:
* Fitting it into 32-bit integer - presuming it doesn't overshoot that range - is that any worse than any alternative? Isn't that the best guess on what was fed into the encoder?
Yes, that would be the best alternative, although still imperfect, because the warmup samples at the start of each frame are still wrapped.

edit: although, it might still not be what the author intended. There is no way to know whether the author reviewed those files in a player that clipped or wrapped the samples, and there is no way to know how the DAW rendered them on playback. So, there is no best way to fix these files except ask the author.

I still think that a null output is less than optimal behaviour. You got files that have been "playing well" for years, and that are "lost" upon upgrade. Sure at least a warning is due.
In a larger picture, you got a potential wishlist of "zealousness level" settings (possibly separate for decoding, encoding and conversion, looks like capital letters -C -D -E are vacant ... uh and foreign metadata handling as well as audio). And handling.
* Say here it exceeds the range. What to do? Possible options are
- expand range (uh, open new .wav or .aiff file to write to?)
- wrap
- clip
- zero out
- drop the frame
I have earlier advocated "zero out" over drop - at least the subsequent samples are right in time, and a CD TOC will still be correct.
(Hm, idea: to distinguish it from intentional digital zero, what about writing a frame of "+1"? I have seen CONSTANT frames with value -1 in actual CD rips, and hypothesized it is due to digital phase inversion flipping all the bits - but nothing else than 0 and -1 I think.)
* Then this phenomenon is awkward when it comes to a frame which is broken with say a bit-flip in the encoded audio: User might want to keep decoding all the samples to get as many as possible correct in order to repair (or even, check by ear whether it is good enough), and then one might think that at least if and when decode exceeds the bitdepth range then we are sure we are past the error. But now it turns out, it could be a different error than post-encode file corruption. Sure if "all CRC-matching frames" stay within bounds, you have a better indication ...

Anyway, it should be thought over, of course subject to developer time budget ...
And/or possibly have a look at what ffmpeg does to potentially decide that "not the reference's job, use that tool instead". But relying on ffmpeg ... which doesn't fix errors?

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #23
BTW, some players/decoders just happily produce horrible mutilated output, when decoding/playing/converting these files, without any warnings.
For example, xmplay. Tested version 3.8.5.42 with FLAC input plugin revision 15.
And so does foobar2000 in versions prior to 1.2.3 when workaround was added.. Dangerously loud noise on playback.
So, these files are not so safe as it seems.

Re: [Bug Report] FLAC files that have 2000+ kbps do not play correctly

Reply #24
I just looked at these files a little more, they are very, very broken.

I imported one of the tracks in FLAC and Vorbis in Audacity 3.0.3 (an older version of Audacity using an older version of FLAC, that doesn't detect this kind of malformed files), and the FLAC files have pretty much all samples way beyond full scale, not just a few. FLAC file is the top one (note the vertical scale from 2 to -2) and the bottom one is the vorbis one.

X

I don't think there is a way to fix these files. @SYXG98 could you listen to the files on soundcloud and tell us whether this is how you remember listening to them on older Foobar? If that is the case, I don't know how they were decoded 'properly'.
Music: sounds arranged such that they construct feelings.