The `ffmpeg` Python package (often referred to as `ffmpeg-python`) provides a lightweight, fluent Python wrapper for the `ffmpeg` command-line tool. It enables programmatic construction of `ffmpeg` commands, management of audio/video streams, application of filters, and format conversions. It currently stands at version 1.4, with its release cadence tied to upstream `ffmpeg` tool features and community contributions.
pip install ffmpegVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to construct and compile an `ffmpeg` command using the Python wrapper. To execute the command (e.g., `ffmpeg.run()`), the `ffmpeg` command-line tool must be installed separately on your system, and input files like `input.mp4` must exist.
Install the `ffmpeg` CLI tool. On macOS: `brew install ffmpeg`. On Debian/Ubuntu: `sudo apt update && sudo apt install ffmpeg`. On Windows, download from `ffmpeg.org` and add to PATH.
Use `try: ffmpeg.run(...) except ffmpeg.Error as e: print(f"Error: {e.stderr.decode()}")` to handle errors gracefully and get feedback from the underlying process.For input from memory: `ffmpeg.input('pipe:', format='rawvideo', ... , pix_fmt='rgb24', s='640x480', pipe_input=True)`. For output to memory: `.output('pipe:', format='rawvideo', ... , pipe_output=True).run(capture_stdout=True)`.Use `process = ffmpeg.run_async(...)` to get a `subprocess.Popen` object, then manage it (e.g., `process.wait()`, `process.poll()`) or integrate with `asyncio`.
Ensure `ffmpeg-python` is installed using `pip install ffmpeg-python` or `conda install -c conda-forge ffmpeg-python`.
Install the `ffmpeg` command-line tool for your operating system (e.g., via Homebrew on macOS, apt-get on Linux, or by downloading binaries and adding to PATH on Windows).
Rename any local file named `ffmpeg.py` to something else (e.g., `my_ffmpeg_script.py`) to avoid conflicts, and ensure `ffmpeg-python` is installed and correctly imported.
Carefully review the `ffmpeg-python` command arguments to ensure they are valid for the `ffmpeg` binary, check for proper handling of input/output pipes, and ensure that the `ffmpeg` process completes successfully with the given parameters.
Verify that the output file extension is appropriate for the desired format and codec, and ensure all codec and format-related arguments (e.g., `vcodec`, `acodec`, `f`) are correct and compatible with the `ffmpeg` tool version being used.
No dependency data recorded yet.