Skip to main content

Modern Python FFmpeg wrappers offer comprehensive support for complex filters, complete with detailed typing and documentation.

Project description

typed-ffmpeg

CI Package Documentation PyPI Version

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.

Planned Features

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

  • Partial Evaluation: Enhance the flexibility of filter graphs by enabling partial evaluation, allowing for modular construction and reuse.
  • 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.
  • Input and Output Options Support: Provide a more comprehensive interface for input and output options, including support for additional codecs and formats.

Installation

To install typed-ffmpeg, simply use pip:

pip install typed-ffmpeg

Note: FFmpeg must be installed on your system.

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

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

For a more complex example:

import ffmpeg

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

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

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


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.

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typed_ffmpeg-1.0.0.tar.gz (121.3 kB view details)

Uploaded Source

Built Distribution

typed_ffmpeg-1.0.0-py3-none-any.whl (126.7 kB view details)

Uploaded Python 3

File details

Details for the file typed_ffmpeg-1.0.0.tar.gz.

File metadata

  • Download URL: typed_ffmpeg-1.0.0.tar.gz
  • Upload date:
  • Size: 121.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for typed_ffmpeg-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b90a068c5e936394e89084b855280a01636d33348b44d72a61fdff1221e6dfeb
MD5 aa2fce57e3431565eb3177f887b88ef7
BLAKE2b-256 a22604c4b16c3d607df01ecdab9e1cbd717442e7a04df66d326a4fb27bbfeca6

See more details on using hashes here.

File details

Details for the file typed_ffmpeg-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: typed_ffmpeg-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 126.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for typed_ffmpeg-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d0de2c4760f1cb106daa4052aa155b996f1e198a694098469e8c6a98cf0ffc1
MD5 363760dc6f2c659bd6dd96a3e4287777
BLAKE2b-256 c1a9bbce0854444cf922d52222d6464882893140e956c7de11650565885906d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page