这个模块提供了libav c库的包装器
audiolayer的Python项目详细描述
这个包包含一个python 3扩展,用于播放音频文件、读取和 编写元数据并转换这些文件。用于解码和编码文件 使用libav库。播放由libportaudio处理。
项目网站可以在 GitHub。
要求
- python3.x(使用python3.3测试)
- libavcodec
- libavformat
- libavutil
- libportaudio
安装
使用pip:
pip install audiolayer
来自github:
git clone https://github.com/remcohaszing/python-audiolayer.git cd python-audiolayer python3 setup.py install
用法
正在读取歌曲元数据:
>>> from audiolayer import Song >>> filename = 'Finntroll - Trollhammaren.flac' >>> song = Song(filename) >>> song['artist'] Finntroll >>> song['album'] Trollhammaren >>> song['title'] Trollhammaren >>>
保存歌曲元数据:
>>> song['album'] = 'Nattfödd' >>> song['album'] 'Nattfödd' >>> song.save() >>>
将带有新元数据的歌曲副本保存到新文件: >;gt;gt;song.save(文件名='finntroll/nattfódd-trollhammaren.flac') >>>gt;
转换歌曲(未实现):
>>> converted = song.convert('Finntroll - Trollhammaren.ogg', ... format='opus', q=4) >>> converted.filename Finntroll - Trollhammaren.ogg >>>
回放(当前实现):
>>> song.play() # Wait for the song to finish. >>>
回放(目标实现):
>>> song.play() 0.00 >>> song.pause() 4.29 >>> song.play_or_pause() 4.29 >>> song.playing_time 12.53 >>>
编码方式
要测试python代码是否符合pep8,请转到项目根目录 然后运行:
python3 setup.py flake8
许可证
本项目根据BSD 3条款许可证获得许可。