FFmpeg-Python 视频处理库 是 AI Skill Hub 本期精选AI工具之一。已获得 9.8k 颗 GitHub Star,综合评分 8.2 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
FFmpeg的Python绑定库,提供简洁的API接口实现视频转码、剪辑、滤镜、合并等操作。适合视频工程师、内容创作者和自动化脚本开发者进行批量视频处理和工程化应用。
FFmpeg-Python 视频处理库 是一款基于 Python 开发的开源工具,专注于 视频处理、FFmpeg绑定、视频转码 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
FFmpeg的Python绑定库,提供简洁的API接口实现视频转码、剪辑、滤镜、合并等操作。适合视频工程师、内容创作者和自动化脚本开发者进行批量视频处理和工程化应用。
FFmpeg-Python 视频处理库 是一款基于 Python 开发的开源工具,专注于 视频处理、FFmpeg绑定、视频转码 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一: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('安装成功')"
# 基本视频转码
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"
[![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%" />
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.
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-pythonmakes no attempt to download/install FFmpeg, asffmpeg-pythonis merely a pure-Python wrapper - whereas FFmpeg installation is platform-dependent/environment-specific, and is thus the responsibility of the user, as described below.
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.
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()
)
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.
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.
成熟的FFmpeg Python封装,提供流畅API设计简化视频处理复杂度。9800+星标验证其实用价值,适合工程化视频处理项目。
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。
经综合评估,FFmpeg-Python 视频处理库 在AI工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | ffmpeg-python |
| 原始描述 | FFmpeg 的 Python 绑定,用代码实现视频转码/剪辑/滤镜/合并等批量操作 |
| Topics | 视频处理FFmpeg绑定视频转码批量自动化Python库 |
| GitHub | https://github.com/kkroening/ffmpeg-python |
| License | Apache-2.0 |
| 语言 | Python |
收录时间:2026-05-13 · 更新时间:2026-05-30 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。