Read and write FLAC audio files
Project description
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 by running:
pip install .
You will need to have a C compiler and the Python headers installed, as well as libFLAC and its headers.
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 plibflac
with 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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file plibflac-0.0.1.tar.gz.
File metadata
- Download URL: plibflac-0.0.1.tar.gz
- Upload date:
- Size: 686.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
136f3c940c3a4d25fda708ef65e9cb168fe9b060e69bb15a51892fac20aea67b
|
|
| MD5 |
41ad7aed9467b1a62536dada2e8d57de
|
|
| BLAKE2b-256 |
ae6baa5389768acbeb95a0e04536d3d993c5835c051fc1edc7dd7dcd23c806e7
|