Skip to main content

批量压缩视频素材的 CLI 工具

Project description

🎬 Video Toolkit

一个用于批量压缩视频素材的 Python 工具,支持 .mov 转码、.mp4 压缩、智能分辨率控制、输出目录指定、GPU 加速、快速压缩模式等功能。适用于素材库清理、自动化预处理、视频体积优化等场景。


🚀 安装

确保你已安装 ffmpeg 并将其加入系统 PATH。

然后在项目根目录执行:

pip install .

或开发模式安装(推荐调试时使用):

pip install -e .

🧪 使用示例

video-toolkit -d ./videos -s 100 -c 26 -p _compressed_ -r 1920x1080 -o ./output -f -g -w

⚙️ 参数说明

参数 简写 说明
--directory -d 要处理的根目录(必填)
--size -s 文件大小阈值(单位 MB,默认 100)
--crf -c 压缩质量(默认 26,范围 18–35)
--prefix -p 压缩后文件名前缀(默认 _compressed_
--resolution -r 目标分辨率(如 1920x1080,仅对高于此分辨率的视频生效)
--output-dir -o 压缩文件输出目录(默认保存在源目录)
--verbose -v 显示 ffmpeg 输出信息(调试用)
--fast -f 使用快速压缩模式(preset=fast)
--gpu -g 使用 GPU 编码(h264_nvenc)
--dry-run -n 仅打印将处理的文件,不执行压缩
--overwrite -w 强制覆盖已存在的压缩文件

📦 依赖

  • ffmpeg(必须安装并加入系统 PATH)
  • tqdm

安装依赖:

pip install tqdm

🧠 示例用途

  • 批量压缩 .mov 素材为 .mp4
  • 自动统一分辨率为 1920x1080
  • 清理素材库中超过 100MB 的视频
  • 使用 GPU 加速压缩过程
  • 快速预览将要处理的文件(dry-run)

📁 项目结构建议

video_toolkit/
├── video_toolkit/
│   ├── __init__.py
│   ├── cli.py
│   ├── compressor.py
│   ├── utils.py
├── setup.py
├── pyproject.toml
├── README.md
├── requirements.txt

🧼 后续

  • ✅ 支持多线程并发处理
  • ✅ 支持 YAML 配置文件
  • ✅ 支持更多格式(如 .avi, .mkv

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

video_toolkit_litouge-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

video_toolkit_litouge-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file video_toolkit_litouge-0.1.0.tar.gz.

File metadata

  • Download URL: video_toolkit_litouge-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for video_toolkit_litouge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d05c2217de03a6cbd3bcd3c65dd09fa659b58dd978c63528e0c633349d855d3
MD5 93f8cce966c3b99c8840c91eeff707b5
BLAKE2b-256 2709ba0e0eec9f5aaf47d13a3c8ab9010acf233a6f5b38fdfdcd25d853635438

See more details on using hashes here.

File details

Details for the file video_toolkit_litouge-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for video_toolkit_litouge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13abb6437ffe51569d2f5aeae125b25b76dc4c4ddad1ec85c38ed25a569919c6
MD5 35ae9d7b4336a0d9dd4390a32567e52c
BLAKE2b-256 bf82e9cd4fbcb8723d58f2377c11cd0b4b3b898df607b6e370ba81b10474e6e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page