Skip to main content

typed-ffmpeg

CI Package Documentation PyPI Version codecov

typed-ffmpeg offers a modern, Pythonic interface to FFmpeg, providing extensive support for complex filters with detailed typing and documentation. Inspired by ffmpeg-python, this package enhances functionality by addressing common limitations, such as lack of IDE integration and comprehensive typing, while also introducing new features like JSON serialization of filter graphs and automatic FFmpeg validation.


Table of Contents


Features

typed-ffmpeg

  • Zero Dependencies: Built purely with the Python standard library, ensuring maximum compatibility and security.
  • User-Friendly: Simplifies the construction of filter graphs with an intuitive Pythonic interface.
  • Comprehensive FFmpeg Filter Support: Out-of-the-box support for most FFmpeg filters, with IDE auto-completion.
  • Integrated Documentation: In-line docstrings provide immediate reference for filter usage, reducing the need to consult external documentation.
  • Robust Typing: Offers static and dynamic type checking, enhancing code reliability and development experience.
  • Filter Graph Serialization: Enables saving and reloading of filter graphs in JSON format for ease of use and repeatability.
  • Graph Visualization: Leverages graphviz for visual representation, aiding in understanding and debugging.
  • Validation and Auto-correction: Assists in identifying and fixing errors within filter graphs.
  • Input and Output Options Support: Provide a more comprehensive interface for input and output options, including support for additional codecs and formats.
  • Partial Evaluation: Enhance the flexibility of filter graphs by enabling partial evaluation, allowing for modular construction and reuse.
  • Media File Analysis: Built-in support for analyzing media files using FFmpeg's ffprobe utility, providing detailed metadata extraction with both dictionary and dataclass interfaces.

Planned Features

Please note that the following features are under consideration or development for future releases:

  • Extended FFmpeg Version Support: While typed-ffmpeg is currently built with FFmpeg version 6.0 in mind, we are working to ensure compatibility across different FFmpeg versions. Feedback and issue reports are welcome to improve version support.
  • Additional Filter Support: We aim to expand the range of FFmpeg filters supported by typed-ffmpeg. Continuous updates will be made to include more complex and varied filters.

Installation

To install typed-ffmpeg, simply use pip:

pip install typed-ffmpeg

Note: FFmpeg must be installed on your system.

Note: If you need to install ffmpeg-python at the same time, use pip install typed-ffmpeg-compatible to prevent conflicts with the module name.​

Visualization Support

To enable graph visualization features:

pip install 'typed-ffmpeg[graph]'

Note: This requires Graphviz to be installed on your system.


Quick Usage

Here's how to quickly start using typed-ffmpeg:

import ffmpeg

# Analyze a media file
info = ffmpeg.probe("video.mp4")
print(f"Duration: {float(info['format']['duration']):.2f} seconds")
print(f"Streams: {len(info['streams'])}")

# Flip video horizontally and output
f = (
    ffmpeg
    .input(filename='input.mp4')
    .hflip()
    .output(filename='output.mp4')
)
f

svg

For a more complex example:

import ffmpeg.filters
import ffmpeg

# Complex filter graph example
in_file = ffmpeg.input("input.mp4")
overlay_file = ffmpeg.input("overlay.png")

f = (
    ffmpeg.filters
    .concat(
        in_file.trim(start_frame=10, end_frame=20),
        in_file.trim(start_frame=30, end_frame=40),
    )
    .video(0)
    .overlay(overlay_file.hflip())
    .drawbox(x="50", y="50", width="120", height="120", color="red", thickness="5")
    .output(filename="out.mp4")
)
f

svg

See the Usage section in our documentation for more examples and detailed guides.


Interactive Playground

Try out typed-ffmpeg directly in your browser with our Interactive Playground! The playground provides a live environment where you can:

Interactive Playground

  • Experiment with FFmpeg filters and commands
  • Visualize filter graphs in real-time
  • Test different input/output configurations
  • Learn through interactive examples
  • Share your filter graphs with others

The playground is perfect for learning and prototyping FFmpeg filter chains without setting up a local environment.


Acknowledgements

This project was initially inspired by the capabilities of GPT-3, with the original concept focusing on using GPT-3 to generate an FFmpeg filter SDK directly from the FFmpeg documentation. However, during the development process, I encountered limitations with GPT-3's ability to fully automate this task.

As a result, I shifted to traditional code generation methods to complete the SDK, ensuring a more robust and reliable tool. Despite this change in approach, both GitHub Copilot and GPT-3 were instrumental in accelerating the development process, providing valuable insights and saving significant time.

I would also like to extend my gratitude to the ffmpeg-python project, which inspired this project significantly. The API style and design ideas from ffmpeg-python have been influential, and I have utilized these aspects to shape the development of our SDK.

This project is dedicated to my son, Austin, on his seventh birthday (February 24, 2024), whose curiosity and zest for life continually inspire me.


Feel free to check the Documentation for detailed information and more advanced features.

Metadata

Release files for compatible-typed-ffmpeg 3.2.0

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

Source distribution (sdist)

Source distribution for compatible-typed-ffmpeg 3.2.0
File Size Uploaded
compatible_typed_ffmpeg-3.2.0.tar.gz 174.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for compatible-typed-ffmpeg 3.2.0
File Interpreter ABI Platform
compatible_typed_ffmpeg-3.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 368.2 kB

Release files / compatible_typed_ffmpeg-3.2.0.tar.gz

Download URL compatible_typed_ffmpeg-3.2.0.tar.gz
Size 174.6 kB
Tags Source
SHA-256 checksum
How to use checksums
72f03937bf00781b236e3b741918ce5ead4dc4830c56517d4dd10dd0cfd3abe4
BLAKE2b-256 checksum
How to use checksums
54912f8a00bd1f5dbd18a6c08d189d45d36248cd128413c28241188d5ac8e07f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / compatible_typed_ffmpeg-3.2.0-py3-none-any.whl

Download URL compatible_typed_ffmpeg-3.2.0-py3-none-any.whl
Size 193.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f89ddbdf29494730ddfef81fa98ef1de36fdc1ef9f8f30fdf941e502a6931ea
BLAKE2b-256 checksum
How to use checksums
67db94c123a068b53c4edf44f4e05cbd6c50856b897b1810d4bfdb9961a0aa56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files

3.1.1

2 release files

3.1.0

2 release files

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