Skip to main content

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, Progress


def main():
    ffmpeg = (
        FFmpeg()
        .option("y")
        .input("input.mp4")
        .output(
            "ouptut.mp4",
            {"codec:v": "libx264"},
            vf="scale=1280:-1",
            preset="veryslow",
            crf=24,
        )
    )

    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("input.mp4")
        .output(
            "ouptut.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())

Metadata

Release files for python-ffmpeg 2.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-ffmpeg 2.0.4
File Size Uploaded Provenance Actions
python-ffmpeg-2.0.4.tar.gz 9.4 kB Without provenance Details for python-ffmpeg-2.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-ffmpeg 2.0.4
File Interpreter ABI Platform Actions
python_ffmpeg-2.0.4-py3-none-any.whl Python 3 none any Details for python_ffmpeg-2.0.4-py3-none-any.whl

Total release size: 21.6 kB

Release files / python-ffmpeg-2.0.4.tar.gz

Download URL python-ffmpeg-2.0.4.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4d5275a58da2a82fb550acbf496ff86e76d677e06b781baeefbe05a4cd47ab50
BLAKE2b-256 checksum
How to use checksums
931af865e159fc54bba3e51c18cfb2f027570f8b30ce40885e58fd67bff43e1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / python_ffmpeg-2.0.4-py3-none-any.whl

Download URL python_ffmpeg-2.0.4-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
89aa9a0a6232a4fda58a9153af7d6c73b4d80d52b08dcde2b3c4ddcceb392b95
BLAKE2b-256 checksum
How to use checksums
bcab7cef12479fe1cbffa64f3ed9d91994160fdb00f8900416d67972ffe99f9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for python-ffmpeg 2.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page