[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-70789":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},70789,"ffmpeg-python","kkroening\u002Fffmpeg-python","kkroening","Python bindings for FFmpeg - with complex filtering support","",null,"Python",10997,942,111,479,0,4,8,12,79.72,"Apache License 2.0",false,"master",true,[],"2026-06-12 04:00:57","# ffmpeg-python: Python bindings for FFmpeg\n\n[![CI][ci-badge]][ci]\n\n[ci-badge]: https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg\n[ci]: https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Factions\u002Fworkflows\u002Fci.yml\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fkkroening\u002Fffmpeg-python\u002Fmaster\u002Fdoc\u002Fformula.png\" alt=\"ffmpeg-python logo\" width=\"60%\" \u002F>\n\n## Overview\n\nThere 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.\n\n\n## Quickstart\n\nFlip a video horizontally:\n```python\nimport ffmpeg\nstream = ffmpeg.input('input.mp4')\nstream = ffmpeg.hflip(stream)\nstream = ffmpeg.output(stream, 'output.mp4')\nffmpeg.run(stream)\n```\n\nOr if you prefer a fluent interface:\n```python\nimport ffmpeg\n(\n    ffmpeg\n    .input('input.mp4')\n    .hflip()\n    .output('output.mp4')\n    .run()\n)\n```\n\n## [API reference](https:\u002F\u002Fkkroening.github.io\u002Fffmpeg-python\u002F)\n\n## Complex filter graphs\nFFmpeg is extremely powerful, but its command-line interface gets really complicated rather quickly - especially when working with signal graphs and doing anything more than trivial.\n\nTake for example a signal graph that looks like this:\n\n![Signal graph](https:\u002F\u002Fraw.githubusercontent.com\u002Fkkroening\u002Fffmpeg-python\u002Fmaster\u002Fdoc\u002Fgraph1.png)\n\nThe corresponding command-line arguments are pretty gnarly:\n```bash\nffmpeg -i input.mp4 -i overlay.png -filter_complex \"[0]trim=start_frame=10:end_frame=20[v0];\\\n    [0]trim=start_frame=30:end_frame=40[v1];[v0][v1]concat=n=2[v2];[1]hflip[v3];\\\n    [v2][v3]overlay=eof_action=repeat[v4];[v4]drawbox=50:50:120:120:red:t=5[v5]\"\\\n    -map [v5] output.mp4\n```\n\nMaybe this looks great to you, but if you're not an FFmpeg command-line expert, it probably looks alien.\n\nIf you're like me and find Python to be powerful and readable, it's easier with `ffmpeg-python`:\n```python\nimport ffmpeg\n\nin_file = ffmpeg.input('input.mp4')\noverlay_file = ffmpeg.input('overlay.png')\n(\n    ffmpeg\n    .concat(\n        in_file.trim(start_frame=10, end_frame=20),\n        in_file.trim(start_frame=30, end_frame=40),\n    )\n    .overlay(overlay_file.hflip())\n    .drawbox(50, 50, 120, 120, color='red', thickness=5)\n    .output('out.mp4')\n    .run()\n)\n```\n\n`ffmpeg-python` takes care of running `ffmpeg` with the command-line arguments that correspond to the above filter diagram, in familiar Python terms.\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fkkroening\u002Fffmpeg-python\u002Fmaster\u002Fdoc\u002Fscreenshot.png\" alt=\"Screenshot\" align=\"middle\" width=\"60%\" \u002F>\n\nReal-world signal graphs can get a heck of a lot more complex, but `ffmpeg-python` handles arbitrarily large (directed-acyclic) signal graphs.\n\n## Installation\n\n### Installing `ffmpeg-python`\n\nThe latest version of `ffmpeg-python` can be acquired via a typical pip install:\n\n```bash\npip install ffmpeg-python\n```\n\nOr the source can be cloned and installed from locally:\n```bash\ngit clone git@github.com:kkroening\u002Fffmpeg-python.git\npip install -e .\u002Fffmpeg-python\n```\n\n> **Note**: `ffmpeg-python` makes no attempt to download\u002Finstall FFmpeg, as `ffmpeg-python` is merely a pure-Python wrapper - whereas FFmpeg installation is platform-dependent\u002Fenvironment-specific, and is thus the responsibility of the user, as described below.\n\n### Installing FFmpeg\n\nBefore using `ffmpeg-python`, FFmpeg must be installed and accessible via the `$PATH` environment variable.\n\nThere are a variety of ways to install FFmpeg, such as the [official download links](https:\u002F\u002Fffmpeg.org\u002Fdownload.html), or using your package manager of choice (e.g. `sudo apt install ffmpeg` on Debian\u002FUbuntu, `brew install ffmpeg` on OS X, etc.).\n\nRegardless 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):\n\n```\n$ ffmpeg\nffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers\n  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)\n```\n\n> **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.\n\n## [Examples](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Ftree\u002Fmaster\u002Fexamples)\n\nWhen in doubt, take a look at the [examples](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Ftree\u002Fmaster\u002Fexamples) to see if there's something that's close to whatever you're trying to do.\n\nHere are a few:\n- [Convert video to numpy array](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fexamples\u002FREADME.md#convert-video-to-numpy-array)\n- [Generate thumbnail for video](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fexamples\u002FREADME.md#generate-thumbnail-for-video)\n- [Read raw PCM audio via pipe](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fexamples\u002FREADME.md#convert-sound-to-raw-pcm-audio)\n\n- [JupyterLab\u002FNotebook stream editor](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fexamples\u002FREADME.md#jupyter-stream-editor)\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fkkroening\u002Fffmpeg-python\u002Fmaster\u002Fdoc\u002Fjupyter-demo.gif\" alt=\"jupyter demo\" width=\"75%\" \u002F>\n\n- [Tensorflow\u002FDeepDream streaming](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fexamples\u002FREADME.md#tensorflow-streaming)\n\n\u003Cimg src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fkkroening\u002Fffmpeg-python\u002Fmaster\u002Fexamples\u002Fgraphs\u002Fdream.png\" alt=\"deep dream streaming\" width=\"40%\" \u002F>\n\nSee the [Examples README](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Ftree\u002Fmaster\u002Fexamples) for additional examples.\n\n## Custom Filters\n\nDon't see the filter you're looking for?  While `ffmpeg-python` includes shorthand notation for some of the most commonly used filters (such as `concat`), all filters can be referenced via the `.filter` operator:\n```python\nstream = ffmpeg.input('dummy.mp4')\nstream = ffmpeg.filter(stream, 'fps', fps=25, round='up')\nstream = ffmpeg.output(stream, 'dummy2.mp4')\nffmpeg.run(stream)\n```\n\nOr fluently:\n```python\n(\n    ffmpeg\n    .input('dummy.mp4')\n    .filter('fps', fps=25, round='up')\n    .output('dummy2.mp4')\n    .run()\n)\n```\n\n**Special option names:**\n\nArguments with special names such as `-qscale:v` (variable bitrate), `-b:v` (constant bitrate), etc. can be specified as a keyword-args dictionary as follows:\n```python\n(\n    ffmpeg\n    .input('in.mp4')\n    .output('out.mp4', **{'qscale:v': 3})\n    .run()\n)\n```\n\n**Multiple inputs:**\n\nFilters that take multiple input streams can be used by passing the input streams as an array to `ffmpeg.filter`:\n```python\nmain = ffmpeg.input('main.mp4')\nlogo = ffmpeg.input('logo.png')\n(\n    ffmpeg\n    .filter([main, logo], 'overlay', 10, 10)\n    .output('out.mp4')\n    .run()\n)\n```\n\n**Multiple outputs:**\n\nFilters that produce multiple outputs can be used with `.filter_multi_output`:\n```python\nsplit = (\n    ffmpeg\n    .input('in.mp4')\n    .filter_multi_output('split')  # or `.split()`\n)\n(\n    ffmpeg\n    .concat(split[0], split[1].reverse())\n    .output('out.mp4')\n    .run()\n)\n```\n(In this particular case, `.split()` is the equivalent shorthand, but the general approach works for other multi-output filters)\n\n**String expressions:**\n\nExpressions to be interpreted by ffmpeg can be included as string parameters and reference any special ffmpeg variable names:\n```python\n(\n    ffmpeg\n    .input('in.mp4')\n    .filter('crop', 'in_w-2*10', 'in_h-2*20')\n    .input('out.mp4')\n)\n```\n\n\u003Cbr \u002F>\n\nWhen in doubt, refer to the [existing filters](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fffmpeg\u002F_filters.py), [examples](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Ftree\u002Fmaster\u002Fexamples), and\u002For the [official ffmpeg documentation](https:\u002F\u002Fffmpeg.org\u002Fffmpeg-filters.html).\n\n## Frequently asked questions\n\n**Why do I get an import\u002Fattribute\u002Fetc. error from `import ffmpeg`?**\n\nMake sure you ran `pip install ffmpeg-python` and _**not**_ `pip install ffmpeg` (wrong) or `pip install python-ffmpeg` (also wrong).\n\n**Why did my audio stream get dropped?**\n\nSome 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\u002Fvideo portions of a stream so that they can be processed separately and then re-combined later in the pipeline.\n\nThis 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.\n\nAs usual, take a look at the [examples](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Ftree\u002Fmaster\u002Fexamples#audiovideo-pipeline) (*Audio\u002Fvideo pipeline* in particular).\n\n**How can I find out the used command line arguments?**\n\nYou 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.\n\n**How do I do XYZ?**\n\nTake a look at each of the links in the [Additional Resources](https:\u002F\u002Fkkroening.github.io\u002Fffmpeg-python\u002F) 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.\n\nIssues 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.\n\nThat 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.\n\n## Contributing\n\n\u003Cimg align=\"right\" src=\"https:\u002F\u002Fraw.githubusercontent.com\u002Fkkroening\u002Fffmpeg-python\u002Fmaster\u002Fdoc\u002Flogo.png\" alt=\"ffmpeg-python logo\" width=\"20%\" \u002F>\n\nOne of the best things you can do to help make `ffmpeg-python` better is to answer [open questions](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Flabels\u002Fquestion) in the issue tracker.  The questions that are answered will be tagged and incorporated into the documentation, examples, and other learning resources.\n\nIf you notice things that could be better in the documentation or overall development experience, please say so in the [issue tracker](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fissues).  And of course, feel free to report any bugs or submit feature requests.\n\nPull requests are welcome as well, but it wouldn't hurt to touch base in the issue tracker or hop on the [Matrix chat channel](https:\u002F\u002Friot.im\u002Fapp\u002F#\u002Froom\u002F#ffmpeg-python:matrix.org) first.\n\nAnyone who fixes any of the [open bugs](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Flabels\u002Fbug) or implements [requested enhancements](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Flabels\u002Fenhancement) is a hero, but changes should include passing tests.\n\n### Running tests\n\n```bash\ngit clone git@github.com:kkroening\u002Fffmpeg-python.git\ncd ffmpeg-python\nvirtualenv venv\n. venv\u002Fbin\u002Factivate  # (OS X \u002F Linux)\nvenv\\bin\\activate    # (Windows)\npip install -e .[dev]\npytest\n```\n\n\u003Cbr \u002F>\n\n### Special thanks\n\n- [Fabrice Bellard](https:\u002F\u002Fbellard.org\u002F)\n- [The FFmpeg team](https:\u002F\u002Fffmpeg.org\u002Fdonations.html)\n- [Arne de Laat](https:\u002F\u002Fgithub.com\u002F153957)\n- [Davide Depau](https:\u002F\u002Fgithub.com\u002Fdepau)\n- [Dim](https:\u002F\u002Fgithub.com\u002Flloti)\n- [Noah Stier](https:\u002F\u002Fgithub.com\u002Fnoahstier)\n\n## Additional Resources\n\n- [API Reference](https:\u002F\u002Fkkroening.github.io\u002Fffmpeg-python\u002F)\n- [Examples](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Ftree\u002Fmaster\u002Fexamples)\n- [Filters](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fffmpeg\u002F_filters.py)\n- [FFmpeg Homepage](https:\u002F\u002Fffmpeg.org\u002F)\n- [FFmpeg Documentation](https:\u002F\u002Fffmpeg.org\u002Fffmpeg.html)\n- [FFmpeg Filters Documentation](https:\u002F\u002Fffmpeg.org\u002Fffmpeg-filters.html)\n- [Test cases](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fblob\u002Fmaster\u002Fffmpeg\u002Ftests\u002Ftest_ffmpeg.py)\n- [Issue tracker](https:\u002F\u002Fgithub.com\u002Fkkroening\u002Fffmpeg-python\u002Fissues)\n- Matrix Chat: [#ffmpeg-python:matrix.org](https:\u002F\u002Friot.im\u002Fapp\u002F#\u002Froom\u002F#ffmpeg-python:matrix.org)\n","ffmpeg-python 是一个用于 FFmpeg 的 Python 绑定库，支持复杂的滤镜操作。该项目允许用户通过简洁直观的 Python 代码来构建和执行从简单到复杂的音视频处理任务，如剪辑、翻转视频、叠加图像等，而无需深入了解 FFmpeg 的命令行参数。其核心功能包括对复杂信号图的支持，使得即使是高级的音视频编辑需求也能以易于理解和维护的方式实现。适用于需要进行多媒体文件转换、编辑的应用场景，特别是当项目中已经使用了 Python 技术栈时，能够极大提升开发效率。",2,"2026-06-11 03:34:13","high_star"]