Skip to content

Commit 70402dc

Browse files
committed
init opus enc
1 parent 9ad2f21 commit 70402dc

File tree

8 files changed

+499
-0
lines changed

8 files changed

+499
-0
lines changed

.gitignore

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Using https://github.com/github/gitignore/blob/master/Python.gitignore
2+
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
share/python-wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
MANIFEST
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.nox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
*.py,cover
52+
.hypothesis/
53+
.pytest_cache/
54+
cover/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
db.sqlite3-journal
65+
66+
# Flask stuff:
67+
instance/
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build/
75+
76+
# PyBuilder
77+
.pybuilder/
78+
target/
79+
80+
# Jupyter Notebook
81+
.ipynb_checkpoints
82+
83+
# IPython
84+
profile_default/
85+
ipython_config.py
86+
87+
# pyenv
88+
# For a library or package, you might want to ignore these files since the code is
89+
# intended to run in multiple environments; otherwise, check them in:
90+
# .python-version
91+
92+
# pipenv
93+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96+
# install all needed dependencies.
97+
#Pipfile.lock
98+
99+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100+
__pypackages__/
101+
102+
# Celery stuff
103+
celerybeat-schedule
104+
celerybeat.pid
105+
106+
# SageMath parsed files
107+
*.sage.py
108+
109+
# Environments
110+
.env
111+
.venv
112+
env/
113+
venv/
114+
ENV/
115+
env.bak/
116+
venv.bak/
117+
118+
# Spyder project settings
119+
.spyderproject
120+
.spyproject
121+
122+
# Rope project settings
123+
.ropeproject
124+
125+
# mkdocs documentation
126+
/site
127+
128+
# mypy
129+
.mypy_cache/
130+
.dmypy.json
131+
dmypy.json
132+
133+
# Pyre type checker
134+
.pyre/
135+
136+
# pytype static type analyzer
137+
.pytype/
138+
139+
# Cython debug symbols
140+
cython_debug/
141+
libs

.pre-commit-config.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ci:
2+
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autofix_commit_msg: "style: pre-commit fixes"
4+
5+
repos:
6+
# Standard hooks
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v4.6.0
9+
hooks:
10+
- id: check-added-large-files
11+
- id: check-case-conflict
12+
- id: check-merge-conflict
13+
- id: check-symlinks
14+
- id: check-yaml
15+
exclude: ^conda\.recipe/meta\.yaml$
16+
- id: debug-statements
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
- id: requirements-txt-fixer
20+
- id: trailing-whitespace
21+
22+
# Lints code
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: "v0.4.2"
25+
hooks:
26+
- id: ruff
27+
args: ["--fix", "--show-fixes"]
28+
- id: ruff-format
29+
30+
# Changes tabs to spaces
31+
- repo: https://github.com/Lucas-C/pre-commit-hooks
32+
rev: v1.5.5
33+
hooks:
34+
- id: remove-tabs

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
# opusenc
2+
3+
For any system <= Ubuntu 22.04, you need to install libopusenc-dev manually, run `install_opus.sh`
4+
5+
For Ubuntu 24.04, you can install libopusenc-dev via apt:
6+
7+
```bash
8+
sudo apt install libopus-dev libopusfile-dev libopusenc-dev
9+
```

install_opus.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
sudo apt install libopus-dev libopusfile-dev
5+
6+
# OGG and OpenSSL are required to install.
7+
mkdir -p libs
8+
cd libs
9+
10+
if [ ! -d "libopusenc-0.2.1" ]; then
11+
wget http://downloads.xiph.org/releases/opus/libopusenc-0.2.1.tar.gz
12+
tar -xf libopusenc-0.2.1.tar.gz
13+
fi
14+
cd libopusenc-0.2.1
15+
16+
./configure
17+
make -j
18+
sudo make install
19+
sudo ldconfig
20+
21+
cd ..

pyproject.toml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=42",
4+
"pybind11>=2.10.0",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
9+
[tool.cibuildwheel]
10+
test-command = "python {project}/tests/test.py"
11+
test-skip = "*universal2:arm64"
12+
13+
14+
[tool.ruff]
15+
target-version = "py37"
16+
17+
[tool.ruff.lint]
18+
extend-select = [
19+
"B", # flake8-bugbear
20+
"I", # isort
21+
"PGH", # pygrep-hooks
22+
"RUF", # Ruff-specific
23+
"UP", # pyupgrade
24+
]

setup.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from pybind11.setup_helpers import Pybind11Extension, build_ext
2+
from setuptools import setup
3+
4+
__version__ = "0.0.1"
5+
6+
7+
ext_modules = [
8+
Pybind11Extension(
9+
"opusenc",
10+
["src/main.cpp"],
11+
define_macros=[("VERSION_INFO", __version__)],
12+
include_dirs=[
13+
"/usr/include/opus",
14+
"/usr/include/opusfile",
15+
"/usr/include/opusenc",
16+
],
17+
),
18+
]
19+
20+
setup(
21+
name="opusenc",
22+
version=__version__,
23+
author="Fish Audio",
24+
author_email="[email protected]",
25+
url="https://github.com/fishaudio/opusenc",
26+
description="OPUS wrapper that supports streaming",
27+
long_description="",
28+
ext_modules=ext_modules,
29+
extras_require={"test": "pytest"},
30+
# Currently, build_ext only provides an optional "highest supported C++
31+
# level" feature, but in the future it may provide more features.
32+
cmdclass={"build_ext": build_ext},
33+
zip_safe=False,
34+
python_requires=">=3.7",
35+
)

0 commit comments

Comments
 (0)