python-soundfile: Soundfile cannot read the full FLAC file it generated
I am generating a soundfile by appending to
audioFile = sf.SoundFile(conf['pSavAudio'], mode='w', samplerate=samplerate, channels=nChan, subtype='PCM_16', format='FLAC')
,but when I try to read all frames from it:
arrA=audio.read(audio.frames, dtype='int16')
I get an empty array, and the extra_info is changed to
“File : ‘C:\Users\hoffmmax\Documents\Recordings\20190319_1807_TestCongruency13\20190319_1807_TestCongruency13_Audio.flac’ (utf-8 converted from ucs-2)\nLength : 48373662\nFLAC Stream Metadata\n Channels : 5\n Sample rate : 192000\n Frames : 26000000\n Bit width : 16\nVorbis Comment Metadata\nEnd\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216 channels 5\nError: pflac->remain 16777216”
I understand that this is an error from the underlying library relating to the length not being divisble by the channels, but I only interact with the soundfile bei soundfile.Soundfile.write and MATLAB/Audacity don’t complain
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 19 (6 by maintainers)
@MaximilianHoffmann Strangely, I ran into the same problem as you when I tried to read a 7-channel .flac file, but I managed to code a crude function that works around this issue (based on the advice given in libsndfile/libsndfile#431) by reading the file chunk by chunk, so if it helps, I’ve placed it in a repo at https://github.com/kenowr/read_flac and replicated the function below: