python-ffmpeg
A python binding for FFmpeg which provides sync and async APIs
Help
See documentation for more details.
Install
To install python-ffmpeg, simply use pip:
$ pip install python-ffmpeg
Examples
You can find more examples in the documentation.
Transcoding
Synchronous API
from ffmpeg import FFmpeg
def main():
ffmpeg = (
FFmpeg()
.option("y")
.input("input.mp4")
.output(
"output.mp4",
{"codec:v": "libx264"},
vf="scale=1280:-1",
preset="veryslow",
crf=24,
)
)
ffmpeg.execute()
if __name__ == "__main__":
main()
Asynchronous API
import asyncio
from ffmpeg.asyncio import FFmpeg
async def main():
ffmpeg = (
FFmpeg()
.option("y")
.input("input.mp4")
.output(
"output.mp4",
{"codec:v": "libx264"},
vf="scale=1280:-1",
preset="veryslow",
crf=24,
)
)
await ffmpeg.execute()
if __name__ == "__main__":
asyncio.run(main())
Recording
Synchronous API
from ffmpeg import FFmpeg, Progress
def main():
ffmpeg = (
FFmpeg()
.option("y")
.input(
"rtsp://username:password@127.0.0.1/cam",
rtsp_transport="tcp",
rtsp_flags="prefer_tcp",
)
.output("output.mp4", vcodec="copy")
)
@ffmpeg.on("progress")
def time_to_terminate(progress: Progress):
if progress.frame > 200:
ffmpeg.terminate()
ffmpeg.execute()
if __name__ == "__main__":
main()
Asynchronous API
import asyncio
from ffmpeg import Progress
from ffmpeg.asyncio import FFmpeg
async def main():
ffmpeg = (
FFmpeg()
.option("y")
.input(
"rtsp://username:password@127.0.0.1/cam",
rtsp_transport="tcp",
rtsp_flags="prefer_tcp",
)
.output("output.mp4", vcodec="copy")
)
@ffmpeg.on("progress")
def time_to_terminate(progress: Progress):
if progress.frame > 200:
ffmpeg.terminate()
await ffmpeg.execute()
if __name__ == "__main__":
asyncio.run(main())
Release files for python-ffmpeg 2.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_ffmpeg-2.0.12.tar.gz | 14.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_ffmpeg-2.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.1 MB
Release files / python_ffmpeg-2.0.12.tar.gz
| Download URL | python_ffmpeg-2.0.12.tar.gz |
|---|---|
| Size | 14.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19ac80af5a064a2f53c245af1a909b2d7648ea045500d96d3bcd507b88d43dc7
|
|
BLAKE2b-256 checksum How to use checksums |
dd4d7ecffb341d646e016be76e36f5a42cb32f409c9ca21a57b68f067fad3fc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / python_ffmpeg-2.0.12-py3-none-any.whl
| Download URL | python_ffmpeg-2.0.12-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d86697da8dfb39335183e336d31baf42fb217468adf5ac97fd743898240faae3
|
|
BLAKE2b-256 checksum How to use checksums |
7f6d02e817aec661defe148cb9eb0c4eca2444846305f625c2243fb9f92a9045
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|