question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't open FLAC file with read on macOS (get unimplemented format error)

See original GitHub issue

Hi!

I got an issue when trying to open a FLAC file using the following simple code:

>>> import soundfile as sf
>>> data, sr = sf.read('test.flac')

That results in the following traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/anaconda3/envs/mqa/lib/python3.6/site-packages/soundfile.py", line 373, in read
    subtype, endian, format, closefd) as f:
  File "/usr/local/anaconda3/envs/mqa/lib/python3.6/site-packages/soundfile.py", line 740, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "/usr/local/anaconda3/envs/mqa/lib/python3.6/site-packages/soundfile.py", line 1265, in _open
    "Error opening {0!r}: ".format(self.name))
  File "/usr/local/anaconda3/envs/mqa/lib/python3.6/site-packages/soundfile.py", line 1455, in _error_check
    raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening '/Users/afuhrmann/Desktop/test.flac': File contains data in an unimplemented format.

The available formats don’t show FLAC:

>>> sf.available_formats()
{'AIFF': 'AIFF (Apple/SGI)', 'AU': 'AU (Sun/NeXT)', 'AVR': 'AVR (Audio Visual Research)', 'CAF': 'CAF (Apple Core Audio File)', 'HTK': 'HTK (HMM Tool Kit)', 'SVX': 'IFF (Amiga IFF/SVX8/SV16)', 'MAT4': 'MAT4 (GNU Octave 2.0 / Matlab 4.2)', 'MAT5': 'MAT5 (GNU Octave 2.1 / Matlab 5.0)', 'MPC2K': 'MPC (Akai MPC 2k)', 'PAF': 'PAF (Ensoniq PARIS)', 'PVF': 'PVF (Portable Voice Format)', 'RAW': 'RAW (header-less)', 'RF64': 'RF64 (RIFF 64)', 'SD2': 'SD2 (Sound Designer II)', 'SDS': 'SDS (Midi Sample Dump Standard)', 'IRCAM': 'SF (Berkeley/IRCAM/CARL)', 'VOC': 'VOC (Creative Labs)', 'W64': 'W64 (SoundFoundry WAVE 64)', 'WAV': 'WAV (Microsoft)', 'NIST': 'WAV (NIST Sphere)', 'WAVEX': 'WAVEX (Microsoft)', 'WVE': 'WVE (Psion Series 3)', 'XI': 'XI (FastTracker 2)'}

but the subformats with format flac does:

>>> sf.available_subtypes(format='FLAC')
{'PCM_S8': 'Signed 8 bit PCM', 'PCM_16': 'Signed 16 bit PCM', 'PCM_24': 'Signed 24 bit PCM'}

Also FLAC is in the supported formats in both soundfile.py and sndfile.h

    SF_FORMAT_FLAC          = 0x170000,     /* FLAC lossless file format */

Also, FLAC files can be played in macOS.

Does anyone know how to resolve that issue?

Thanks in advance

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ghostcommented, Nov 10, 2020

Find a work around with the issue hope it might help out, still to try @mgeier solution with the def dummy_find_library() function,

but what I did was I uninstall librosa and it uninstalled all it dependent packages 😒 conda uninstall librosa -y

and I install soundfile and loaded the .flac file and it works. but when I install librosa again installed libsnfile and soundfile._libname by default picks and "/…/anaconda//libsndfile.so.1"* found in anaconda.

I uninstall just that package 😒 conda remove --force libndfile

soundfile._libname default to “libsnfile.so.1”, which works alongside librosa.

Hoping to get a far more better and accurate solution in the future.

1reaction
mgeiercommented, Dec 13, 2019

I get “/…/anaconda/envs/dynamite/bin/…/lib/libsndfile.dylib” but I don’t know how to interpret this info.

This tells you from which file on your system the libsndfile library is loaded.

The path you are getting points somewhere inside your Anaconda folder. It’s not the one distributed with the soundfile wheel package.

There seem to be FLAC problems with the macOS version of the Anaconda package, see https://github.com/conda-forge/libsndfile-feedstock/issues/2 and https://github.com/librosa/librosa/pull/847#issuecomment-475044902. There doesn’t seem to be a resolution.

You should try to uninstall libsndfile with conda, then it probably works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

inability to use .flac files in Music app. - Apple Community
The problem is converting FLAC files to iTunes compatible files like AIFF. The "Free" converters are all dodgy attempting to get $30 -...
Read more >
How to play FLAC files on a Mac - Quora
Launch it on your Mac, find the Format Converter from the ...
Read more >
SoundFile - Read the Docs
SoundFile can open all file formats that libsndfile supports, for example WAV, FLAC, OGG and MAT files (see Known Issues below about writing...
Read more >
How to open FLAC on Mac? - YouTube
More useful information on Elmedia Player: http://elmedia-video-player.com/Content:0:00​ - Intro0:29 - What is a FLAC file ?0:56 - Elmedia ...
Read more >
soundfile - PyPI
read () . The soundfile module can open all file formats that libsndfile supports, for example WAV, FLAC, OGG and MAT files (see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found