-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems reading opus files #19
Comments
Hello @snakers4, unfortunately it's quite difficult to do the task you're trying to achieve.
I think the easiest way to solve this would be as follows: Next you'll need numpy, which you already have. The first step will be to turn the pointer into a numpy array. import ctypes, numpy, pyogg
[...]
file = pyogg.OpusFile("detodos.opus")
target_datatype = ctypes.c_short * file.buffer_length
buffer_as_array = ctypes.cast(file.buffer, ctypes.POINTER(target_datatype)).contents
buffer_as_numpy_array = numpy.array(buffer_as_array) Now we need to reorganize the numpy array to a 2d array as requested in the documentation I found. left_data = buffer_as_numpy_array[0::2] # starting from 0, every second value
right_data = buffer_as_numpy_array[1::2]
final_data = numpy.array((left_data, right_data)) I think that should do it. I hope the code doesn't contain any typos. And I hope it helps you! |
Hi, Many thanks for your replies! (i)
It is weird, when I run this, I get (ii)
Many thanks for you example, I tried it.
(iii)
(iv) |
Hi again, okay. (ii) (iii)
(iv) Cheers, |
I think I will will cover the available options when I will be writing a post
Correct me if I am wrong, but it looks like there is no proper in-memory library to work with Technically it does support it, but there are no binaries available, etc I tried using the packaged version in 18.04, but there is still no support.
Are you planning on adding the write functionality?
Do you think that even if there was a class for writing files, your library is not suitable for production usage, i.e. there may be memory leaks? |
I don't really know any other libraries that don't have massive overhead in terms of unnecessary frameworks and functionality.
Yes, that should be part of a library that claims to give access to Ogg, FLAC and Opus' functionality.
If I take the time and care, I'm pretty certain that I can make it production ready. Of course, there may always be memory leaks, but none that can't be fixed. |
Gave your library a shout-out here Keep up the good work! =) |
Closing this issue. This repository now includes an example of how to read and play Opus-encoded audio using PyOgg (see the file |
Hi @Zuzu-Typ ,
Many thanks for your library, it seems to be working, but I am facing some issues.
I managed to successfully load the library on
Ubuntu-18.04
after running these commands (some of them may be redundant)After that I could open and listen to an
opus
file like this:Looks like there are a few problems
Please tell if I am doing something wrong!
The text was updated successfully, but these errors were encountered: