jonghwanhyeon/python-ffmpeg

A python binding for FFmpeg which provides sync and async APIs

What it solves

This library gives Python developers a clean, programmatic way to control FFmpeg, the popular multimedia tool. Instead of typing complex command-line arguments, you can build commands step by step in Python, run them, and even react to progress events.

How it works

You create an FFmpeg object and chain methods like .input(), .output(), and .option() to set up the conversion or recording task. Options can be passed as keyword arguments (e.g., vf for video filters, preset, crf) or as a dictionary for codec settings. Then you call execute() to run FFmpeg. Two APIs are available: a synchronous (blocking) version and an asynchronous one (ffmpeg.asyncio.FFmpeg) for use with asyncio. You can also listen for events like progress by decorating a callback with @ffmpeg.on("progress"), which receives a Progress object with fields such as frame. This lets you monitor or terminate a running task programmatically.

Who it's for

Python developers who need to embed FFmpeg functionality in their applications—whether transcoding videos, streaming from RTSP cameras, or building media pipelines—and want a more Pythonic interface without shelling out to command lines.

Highlights

  • Synchronous and asynchronous APIs for both blocking and non-blocking use cases
  • Chainable, readable method calls to construct FFmpeg commands
  • Support for custom options, codec settings, and video filters via keyword arguments or dictionaries
  • Event listener mechanism for progress updates, enabling conditional termination (e.g., stop after 200 frames)
  • Installable via pip install python-ffmpeg

Related

  • Project
  • Project
  • Project
  • Project