python-soundfile icon indicating copy to clipboard operation
python-soundfile copied to clipboard

soundfile read ogg files error

Open kyowill opened this issue 5 years ago • 9 comments
trafficstars

Here is my code.

filename='kfc.ogg' data, samplerate = sf.read(filename) Then throw Error File "/PycharmProjects/.env/lib/python3.7/site-packages/soundfile.py", line 1184, in _open "Error opening {0!r}: ".format(self.name)) File "/PycharmProjects/.env/lib/python3.7/site-packages/soundfile.py", line 1357, in _error_check raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace')) RuntimeError: Error opening 'kfc.ogg': File contains data in an unimplemented format.

kyowill avatar Jan 15 '20 06:01 kyowill

Could you upload that file, so we ca have a look?

How did you install soundfile?

bastibe avatar Jan 15 '20 07:01 bastibe

pip install soundfile sudo apt-get install libsndfile kfc.ogg.zip

kyowill avatar Jan 15 '20 08:01 kyowill

Do you know if your version of libsndfile does in fact support OGG?

bastibe avatar Jan 15 '20 13:01 bastibe

@kyowill Your .ogg file is encoded with opus, while last version of libsndfile as well as pysoundfile can process only vorbis encoded files.

Islanna avatar Jan 15 '20 13:01 Islanna

I see your OGG file contains OPUS audio. As far as I know, libsndfile does not support OPUS.

bastibe avatar Jan 15 '20 13:01 bastibe

I think now it support oppus, please check https://libsndfile.github.io/libsndfile/formats.html

talhaanwarch avatar Aug 14 '22 14:08 talhaanwarch

I installed soundfile==0.11.0, and in release it writes "Updates libsndfile to v1.1.0". When I import soundfile and print libsndfile_version, I get '1.0.28', which does not support ogg/opus Is there any way to upgrade the libsndfile of soundfilev0.11.0?

yyong119 avatar Oct 11 '22 06:10 yyong119

Hi, you need to install it from source

I was trying to install it on aws lambda.

#all files are stored in var/task
RUN yum update -y && yum install gcc-c++ make -y
#with yum the cmake version is <3 and we need >3
# https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0.tar.gz
#OpenSSL(libssl-devel) for cmake
COPY cmake-3.24.0 ${LAMBDA_TASK_ROOT}/cmake3
RUN cd cmake3 && ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF && make && make install && cd ..
# # RUN wget https://github.com/libsndfile/libsndfile/archive/refs/tags/1.1.0.tar.gz
# # RUN tar xf 1.1.0.tar.gz 
COPY libsndfile-1.1.0 ${LAMBDA_TASK_ROOT}/libsndfile
RUN cd libsndfile && cmake -G"Unix Makefiles" && make && make install && cd ..

I think i am able to install the latest version. The above commands are docker commands. I just posted them for the hint

talhaanwarch avatar Oct 11 '22 07:10 talhaanwarch

That's not enough. You also need to install all the dependencies for Opus before you compile libsndfile. Have a look at https://github.com/bastibe/libsndfile-binaries/blob/master/mac_build.sh to get an idea of what is needed. On Linux, you can obviously install most dependencies from your package manager instead of compiling them manually.

bastibe avatar Oct 11 '22 08:10 bastibe