A
A
Andrei1penguin12022-04-17 15:49:15
JavaScript
Andrei1penguin1, 2022-04-17 15:49:15

How to decode Ogg Opus in django?

Good day, the following base64 encoded blob is sent to the server:

var blob = new Blob(chunks, {"type" : "audio/ogg; codecs=opus"});
blob = get_base64(blob);

On the server (django) there is a task to get the duration of this file using mutagen, that is:
import base64
from mutagen.oggopus import OggOpus
blob = request.get("blob").split(";base64")[1]
blob = OggOpus(base64.b64decode(blob))

The following error appears, here is part of it:
blob = OggOpus(base64.b64decode(blob))
File "/usr/lib/python3.10/site-packages/mutagen/_file.py", line 48, in __init__
self. load(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/mutagen/_util.py", line 154, in wrapper
with _openfile(self, filething, filename, fileobj,
File "/ usr/lib/python3.10/contextlib.py", line 135, in __enter__
return next(self.gen)
File "/usr/lib/python3.10/site-packages/mutagen/_util.py", line 251, in _openfile
fileobj = open(filename, "rb+" if writable else "rb")
ValueError: embedded null byte

Please tell mewhy is OggOpus not accepting the file and how to do it right?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question