https://github.com/mit-lcp/plibflac
Read and write FLAC audio files in Python
https://github.com/mit-lcp/plibflac
Last synced: about 1 month ago
JSON representation
Read and write FLAC audio files in Python
- Host: GitHub
- URL: https://github.com/mit-lcp/plibflac
- Owner: MIT-LCP
- License: gpl-3.0
- Created: 2024-07-26T21:48:30.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-23T23:35:50.000Z (8 months ago)
- Last Synced: 2025-02-15T19:51:15.401Z (3 months ago)
- Language: C
- Homepage:
- Size: 759 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
plibflac
========This package provides a Python library for reading and writing audio
files in FLAC (Free Lossless Audio Codec) format.`plibflac` is implemented as a wrapper around the reference FLAC
implementation (libFLAC) written by Josh Coalson and maintained by
Xiph.Org.Installation
------------Install this package from PyPI by running:
```
pip install plibflac
```If you want to build the package from source (e.g., from the git
repository), you will need to have a C compiler and the Python headers
installed.Project goals
-------------The main goal of this project is to provide a portable and efficient
interface for reading and writing raw sample data, in FLAC format,
from Python applications.This package currently does not implement the complete functionality
provided by the FLAC library. If there are particular missing
features that your application needs, please report them via GitHub
issues.Example
-------In the code below, we first open a FLAC file and print the first 10
samples of each channel. Next, we read the entire stream and write it
out to a new FLAC file (re-encoding it using compression level 8.)```
import plibflacwith plibflac.Decoder("input.flac") as decoder:
samples = decoder.read(10)
for i, s in enumerate(samples):
print("First 10 samples of channel {}: {}".format(i, list(s)))decoder.seek(0)
with plibflac.Encoder("output.flac", compression_level=8,
channels=decoder.channels,
bits_per_sample=decoder.bits_per_sample,
sample_rate=decoder.sample_rate) as encoder:
while data := decoder.read(1000):
encoder.write(data)
```