基于 FFmpeg 的音视频格式转换工具
Project description
FFmpeg Converter
基于 FFmpeg 的音视频格式转换工具,支持异步操作和进度监控。
特性
- 支持异步操作
- 实时进度监控
- 支持音频和视频格式转换
- 丰富的转换参数配置
- 类型提示支持
安装
-
安装 FFmpeg(必需)
# Windows (使用 chocolatey) choco install ffmpeg # Linux (Ubuntu/Debian) sudo apt-get update && sudo apt-get install ffmpeg
-
安装 ffmpeg-converter
pip install ffmpeg-converter
快速开始
音频转换
import asyncio
from ffmpeg_converter import AudioConverter
async def main():
converter = AudioConverter()
def progress_callback(progress, time_remaining, info):
print(f"进度: {progress:.2f}%, 剩余时间: {time_remaining}")
success = await converter.convert(
input_file="input.mp3",
output_file="output",
output_format="wav",
sample_rate=44100,
channels=2,
progress_callback=progress_callback,
)
if success:
print("转换完成")
else:
print("转换失败")
if __name__ == "__main__":
asyncio.run(main())
视频转换
import asyncio
from ffmpeg_converter import VideoConverter
async def main():
converter = VideoConverter()
def progress_callback(progress, time_remaining, info):
print(f"进度: {progress:.2f}%, 剩余时间: {time_remaining}")
if "conversion_speed" in info:
print(f"转换速度: {info['conversion_speed']}")
success = await converter.convert(
input_file="input.mp4",
output_file="output",
output_format="mkv",
video_codec="h264",
video_bitrate="5M",
resolution="1920x1080",
fps=30,
audio_codec="aac",
audio_bitrate="192k",
preset="fast",
crf=23,
progress_callback=progress_callback,
)
if success:
print("转换完成")
else:
print("转换失败")
if __name__ == "__main__":
asyncio.run(main())
开发
-
克隆仓库
git clone https://github.com/ospoon/ffmpeg-converter.git cd ffmpeg-converter
-
安装开发依赖
pip install uv uv venv uv sync
-
运行测试
uv run pytest
贡献指南
欢迎贡献!请遵循以下步骤:
- Fork 本仓库
- 创建功能分支 ( git checkout -b feature/amazing-feature )
- 提交更改 ( git commit -m 'Add amazing feature' )
- 推送到分支 ( git push origin feature/amazing-feature )
- 开启 Pull Request
许可证
本项目采用 MIT 许可证 - 详见 LICENSE 文件
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ffmpeg_converter-0.3.7.tar.gz
(11.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ffmpeg_converter-0.3.7.tar.gz.
File metadata
- Download URL: ffmpeg_converter-0.3.7.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a838ecfdd32f718cef1badb02d35c7c2b025edd54783ff443f9584747458eb5e
|
|
| MD5 |
a25a28f675a8762d8cb763b680409d3b
|
|
| BLAKE2b-256 |
b21596579a7ae849d28e00617b65d932859217e2d31762d1cdc0a42a0fc4224c
|
File details
Details for the file ffmpeg_converter-0.3.7-py3-none-any.whl.
File metadata
- Download URL: ffmpeg_converter-0.3.7-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb5fdff726716742f39b05370d2676e31a972dbd7cf48d7994f8616726f1a24
|
|
| MD5 |
ef33c029fb4a25672d997ee97502215e
|
|
| BLAKE2b-256 |
c004aec709bc6c111dbbba6611e53bef254876dc2fc48a1f6b4959647fdc5065
|