能力标签
FFmpeg-Python 视频处理库
🛠
AI工具

FFmpeg-Python 视频处理库

基于 Python · 开源免费,本地部署,数据完全自主可控
英文名:ffmpeg-python
⭐ 9.8k Stars 💻 Python 📄 Apache-2.0 🏷 AI 8.2分
8.2AI 综合评分
视频处理FFmpeg绑定视频转码批量自动化Python库
✦ AI Skill Hub 推荐

FFmpeg-Python 视频处理库 是 AI Skill Hub 本期精选AI工具之一。已获得 9.8k 颗 GitHub Star,综合评分 8.2 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。

📚 深度解析

ffmpeg-python 是对 FFmpeg 命令行工具的 Python 封装库,让你可以用 Python 代码以流式 API 的方式构建复杂的 FFmpeg 处理管线。FFmpeg 本身是音视频处理领域最全能的开源工具,支持几乎所有视频格式的解码、编码、转码、剪辑、拼接、滤镜处理,而 ffmpeg-python 让这些能力在 Python 脚本和自动化工作流中得到更好的复用。

在实际使用中,ffmpeg-python 特别适合构建批量视频处理管线。例如将 1000 个 .mov 文件批量转换为 H.264 MP4,或者从大量视频中批量提取第一帧作为缩略图,这些任务用 subprocess 直接调用 FFmpeg 很繁琐,而 ffmpeg-python 的链式 API 可以让代码既简洁又可维护。它与 NumPy、OpenCV 的深度集成也是重要优势,可以直接在 Python 中读取视频帧进行图像处理,再输出回视频流。

📋 工具概览

FFmpeg的Python绑定库,提供简洁的API接口实现视频转码、剪辑、滤镜、合并等操作。适合视频工程师、内容创作者和自动化脚本开发者进行批量视频处理和工程化应用。

FFmpeg-Python 视频处理库 是一款基于 Python 开发的开源工具,专注于 视频处理、FFmpeg绑定、视频转码 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 9.8k
开发语言
Python
支持平台
Windows / macOS / Linux
维护状态
持续维护,定期更新
开源协议
Apache-2.0
AI 综合评分
8.2 分
工具类型
AI工具
Forks

📖 中文文档

以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

FFmpeg的Python绑定库,提供简洁的API接口实现视频转码、剪辑、滤镜、合并等操作。适合视频工程师、内容创作者和自动化脚本开发者进行批量视频处理和工程化应用。

FFmpeg-Python 视频处理库 是一款基于 Python 开发的开源工具,专注于 视频处理、FFmpeg绑定、视频转码 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:pip 安装(推荐)
pip install ffmpeg-python

# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install ffmpeg-python

# 方式三:从源码安装(获取最新功能)
git clone https://github.com/kkroening/ffmpeg-python
cd ffmpeg-python
pip install -e .

# 验证安装
python -c "import ffmpeg_python; print('安装成功')"
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 基本视频转码
import ffmpeg

ffmpeg.input('input.mp4').output('output.mp4').run()

# 调整分辨率(缩放到 1280x720)
(
    ffmpeg
    .input('input.mp4')
    .filter('scale', 1280, 720)
    .output('output_720p.mp4')
    .run()
)

# 提取音频
ffmpeg.input('video.mp4').output('audio.mp3').run()

# 视频压缩(调整码率)
(
    ffmpeg
    .input('input.mp4')
    .output('output_compressed.mp4', video_bitrate='1000k', audio_bitrate='128k')
    .run()
)

# 添加水印
main = ffmpeg.input('input.mp4')
logo = ffmpeg.input('logo.png')
(
    ffmpeg
    .filter([main, logo], 'overlay', 10, 10)
    .output('output_watermark.mp4')
    .run()
)
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# ffmpeg-python 配置文件示例(config.yml)
app:
  name: "ffmpeg-python"
  debug: false
  log_level: "INFO"

# 运行时指定配置文件
ffmpeg-python --config config.yml

# 或通过环境变量配置
export FFMPEG_PYTHON_API_KEY="your-key"
export FFMPEG_PYTHON_OUTPUT_DIR="./output"
📑 README 深度解析 真实文档 完整度 52/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

ffmpeg-python: Python bindings for FFmpeg

[![CI][ci-badge]][ci]

[ci-badge]: https://github.com/kkroening/ffmpeg-python/actions/workflows/ci.yml/badge.svg [ci]: https://github.com/kkroening/ffmpeg-python/actions/workflows/ci.yml

<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/formula.png" alt="ffmpeg-python logo" width="60%" />

Overview

There are tons of Python FFmpeg wrappers out there but they seem to lack complex filter support. ffmpeg-python works well for simple as well as complex signal graphs.

Installation

Installing `ffmpeg-python`

The latest version of ffmpeg-python can be acquired via a typical pip install:

pip install ffmpeg-python

Or the source can be cloned and installed from locally:

git clone git@github.com:kkroening/ffmpeg-python.git
pip install -e ./ffmpeg-python

Note: ffmpeg-python makes no attempt to download/install FFmpeg, as ffmpeg-python is merely a pure-Python wrapper - whereas FFmpeg installation is platform-dependent/environment-specific, and is thus the responsibility of the user, as described below.

Installing FFmpeg

Before using ffmpeg-python, FFmpeg must be installed and accessible via the $PATH environment variable.

There are a variety of ways to install FFmpeg, such as the official download links, or using your package manager of choice (e.g. sudo apt install ffmpeg on Debian/Ubuntu, brew install ffmpeg on OS X, etc.).

Regardless of how FFmpeg is installed, you can check if your environment path is set correctly by running the ffmpeg command from the terminal, in which case the version information should appear, as in the following example (truncated for brevity):

$ ffmpeg
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
Note: The actual version information displayed here may vary from one system to another; but if a message such as ffmpeg: command not found appears instead of the version information, FFmpeg is not properly installed.

Quickstart

Flip a video horizontally:

import ffmpeg
stream = ffmpeg.input('input.mp4')
stream = ffmpeg.hflip(stream)
stream = ffmpeg.output(stream, 'output.mp4')
ffmpeg.run(stream)

Or if you prefer a fluent interface:

import ffmpeg
(
    ffmpeg
    .input('input.mp4')
    .hflip()
    .output('output.mp4')
    .run()
)

[Examples](https://github.com/kkroening/ffmpeg-python/tree/master/examples)

When in doubt, take a look at the examples to see if there's something that's close to whatever you're trying to do.

Here are a few: - Convert video to numpy array - Generate thumbnail for video - Read raw PCM audio via pipe

<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/doc/jupyter-demo.gif" alt="jupyter demo" width="75%" />

<img src="https://raw.githubusercontent.com/kkroening/ffmpeg-python/master/examples/graphs/dream.png" alt="deep dream streaming" width="40%" />

See the Examples README for additional examples.

[API reference](https://kkroening.github.io/ffmpeg-python/)

Frequently asked questions

Why do I get an import/attribute/etc. error from import ffmpeg?

Make sure you ran pip install ffmpeg-python and not pip install ffmpeg (wrong) or pip install python-ffmpeg (also wrong).

Why did my audio stream get dropped?

Some ffmpeg filters drop audio streams, and care must be taken to preserve the audio in the final output. The `.audio and .video` operators can be used to reference the audio/video portions of a stream so that they can be processed separately and then re-combined later in the pipeline.

This dilemma is intrinsic to ffmpeg, and ffmpeg-python tries to stay out of the way while users may refer to the official ffmpeg documentation as to why certain filters drop audio.

As usual, take a look at the examples (Audio/video pipeline in particular).

How can I find out the used command line arguments?

You can run stream.get_args() before stream.run() to retrieve the command line arguments that will be passed to ffmpeg. You can also run stream.compile() that also includes the ffmpeg executable as the first argument.

How do I do XYZ?

Take a look at each of the links in the Additional Resources section at the end of this README. If you look everywhere and can't find what you're looking for and have a question that may be relevant to other users, you may open an issue asking how to do it, while providing a thorough explanation of what you're trying to do and what you've tried so far.

Issues not directly related to ffmpeg-python or issues asking others to write your code for you or how to do the work of solving a complex signal processing problem for you that's not relevant to other users will be closed.

That said, we hope to continue improving our documentation and provide a community of support for people using ffmpeg-python to do cool and exciting things.

🎯 aiskill88 AI 点评 A 级 2026-05-21

成熟的FFmpeg Python封装,提供流畅API设计简化视频处理复杂度。9800+星标验证其实用价值,适合工程化视频处理项目。

📚 实用指南(长尾问题)
适合谁
  • 需要 ffmpeg-python 解决具体问题的开发者与运营人员
最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • Python 依赖冲突:建议用 venv / uv 隔离环境
部署方案
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
ffmpeg-python 中文教程ffmpeg-python 安装报错怎么办ffmpeg-python 与同类工具对比ffmpeg-python 最佳实践ffmpeg-python 适合谁用

⚡ 核心功能

👥 适合谁
  • 需要 ffmpeg-python 解决具体问题的开发者与运营人员
⭐ 最佳实践
  • 先在测试环境跑通最小用例,再接入生产数据
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • Python 依赖冲突:建议用 venv / uv 隔离环境

👥 适合人群

AI 技术爱好者研究人员和学生开发者和工程师技术创业者

🎯 使用场景

  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发

⚖️ 优点与不足

✅ 优点
  • +GitHub 9.8k Star,社区高度认可
  • +Apache-2.0 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。

🔗 相关工具推荐

📚 相关教程推荐
📰 相关 AI 新闻
🗺️ 相关解决方案
🧩 你可能还需要
基于当前 Skill 的能力图谱,自动补全的工具组合

❓ 常见问题 FAQ

结合Python多进程或队列系统,对输入目录遍历批量调用ffmpeg-python接口实现并行处理
💡 AI Skill Hub 点评

经综合评估,FFmpeg-Python 视频处理库 在AI工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。

📚 深入学习 FFmpeg-Python 视频处理库
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 ffmpeg-python
原始描述 FFmpeg 的 Python 绑定,用代码实现视频转码/剪辑/滤镜/合并等批量操作
Topics 视频处理FFmpeg绑定视频转码批量自动化Python库
GitHub https://github.com/kkroening/ffmpeg-python
License Apache-2.0
语言 Python
🔗 原始来源
🐙 GitHub 仓库  https://github.com/kkroening/ffmpeg-python 🌐 官方网站  https://github.com/kkroening/ffmpeg-python

收录时间:2026-05-13 · 更新时间:2026-05-30 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。

📺 订阅 AI Skill Hub Daily Telegram 频道
每天 8 条精选 AI Skill、MCP、Agent 与自动化工具推送
加入频道 →