Skip to main content

A blazing fast video editing library wrapping FFmpeg native filters.

Project description

core-flux

Concisely Optimized Render Engine — FFmpeg Linear User Xtension

A high-performance video editing and compositing library built entirely on top of native FFmpeg complex filtergraphs. By bypassing Python-level pixel manipulation and compiling layers directly into a single native filter graph, core-flux runs at maximum speed with a beautiful, modern API.


Installation

Stable Channel (Linear Engine v0.2.x)

pip install core-flux

Beta Channel (Compositing Layer Engine v0.3.x+)

To test the new non-linear pieces and layers architecture, install the pre-release explicitly:

pip install core-flux==0.3.2b1

Quick Start (v0.3.2b1+)

Create independent video and audio pieces, layer them onto a master canvas, change volume, add fades, and compile instantly:

from fastvideo import VideoLayer, AudioLayer, Composition

# 1. Initialize and configure independent pieces
background = VideoLayer("bg.mp4").resize(1920, 1080).fade_out(start_fade=10.0)
facecam = (VideoLayer("gamer_cam.mp4")
           .resize(400, 300)
           .set_position(x=50, y=50)
           .mute())  # Mute native webcam noise

# 2. Add an independent audio track
bg_music = AudioLayer("lofi_beats.mp3").with_volume_scaled_to(0.2)

# 3. Stack layers and tracks onto the composition timeline canvas
timeline = Composition(
    layers=[background, facecam],
    audio_tracks=[bg_music]
)

# 4. Render directly to a native FFmpeg stream
timeline.render("gaming_edit.mp4")

Features

  • Compositing Canvas — Treat video and audio tracks as individual layers that can be stacked, sized, and placed anywhere.
  • FFmpeg-Native Speed — Zero Python processing bottleneck; your timeline is compiled into a native C-level complex graph.
  • Granular Audio Routing — Scale or completely mute individual video stream audio tracks independently before final mixing.
  • Cinematic Transitions — Native hardware-accelerated video and audio fades.
  • Audio Mixing — Automatically mixes all distinct audio tracks using FFmpeg's amix filter.

API Reference

VideoLayer(input_path: str)

Represents an independent video clip layer. Automatically detects whether the file contains native audio.

clip = VideoLayer("input.mp4")

.set_position(x: int, y: int)

Sets the pixel coordinates where the layer will sit relative to the base canvas background.

clip.set_position(x=100, y=50)

.resize(width: int, height: int)

Scale this specific layer to the given dimensions in pixels.

clip.resize(1280, 720)

.crop(x1: int, y1: int, width: int, height: int)

Crop a rectangular region of the layer, starting from the top-left corner (x1, y1).

clip.crop(100, 50, 640, 480)

.trim(start_time: float, end_time: float)

Cut this layer between two timestamps in seconds. Handles internal audio timing safely if audio is present.

clip.trim(0, 10)

.adjust_colors(contrast: float = 1.0, brightness: float = 0.0, saturation: float = 1.0)

Adjust contrast, brightness, and saturation for this layer.

clip.adjust_colors(contrast=1.2, saturation=1.5)

.blackwhite()

Convert this layer to black and white.

clip.blackwhite()

.with_volume_scaled_to(factor: float)

Scale the video's embedded native audio stream volume. 0.5 halves volume; 2.0 doubles it.

clip.with_volume_scaled_to(0.5)

.mute()

Completely silence the embedded native audio stream on this video layer.

clip.mute()

.fade_in(start_time: float, duration: float = 1.0)

Smoothly fades both video visuals and its native audio in from black/silence.

clip.fade_in(start_time=0.0, duration=2.0)

.fade_out(start_fade: float, duration: float = 1.0)

Smoothly fades both video visuals and its native audio out to black/silence.

clip.fade_out(start_fade=13.5, duration=1.5)

AudioLayer(input_path: str)

Represents an independent secondary audio track (e.g., sound effects, background music).

music = AudioLayer("music.mp3")

.with_volume_scaled_to(factor: float)

Scale the audio volume. 0.5 halves volume; 2.0 doubles it.

music.with_volume_scaled_to(0.5)

.fade_out(start_time: float, duration: float = 1.0)

Smoothly fades the audio track out to complete silence.

music.fade_out(start_time=45.0, duration=2.0)

.trim(start_time: float, end_time: float)

Cut the audio track between two timestamps in seconds.

music.trim(15, 45)

Composition(layers: list = None, audio_tracks: list = None)

The central timeline manager. The first object in layers behaves as the background video canvas; subsequent layers are overlaid sequentially on top.

timeline = Composition(layers=[bg, overlay_1], audio_tracks=[music])

.render(output_path: str, format_type: str = 'video')

Compiles all layer blocks into an optimal FFmpeg filtergraph and writes the result to disk.

The format_type parameter controls the output mode:

Value Description
'video' Standard multi-layer video with mixed audio tracks (default). Encodes with H.264 + AAC.
'gif' Animated GIF output optimized with a custom high-fidelity color palette.
'audio' Compiles and mixes audio streams only into an MP3 or AAC file.
# Render standard multi-layer video
timeline.render("output.mp4")

# Render high-fidelity GIF
timeline.render("output.gif", format_type='gif')

# Render audio compilation only
timeline.render("master_mix.mp3", format_type='audio')

Note: Attempting to render with format_type='audio' when no tracks or layer audio streams are active raises a ValueError.


Requirements

  • Python 3.8+
  • FFmpeg installed and available on your system PATH

License

MIT

Project details


Download files

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

Source Distribution

core_flux-0.3.2b1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

core_flux-0.3.2b1-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file core_flux-0.3.2b1.tar.gz.

File metadata

  • Download URL: core_flux-0.3.2b1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.33.0

File hashes

Hashes for core_flux-0.3.2b1.tar.gz
Algorithm Hash digest
SHA256 4928f8d4ce569dbff2cdee8e401adc6c79ffcd479459a49221b78bbbfbc72bb5
MD5 a68567e72d84ec4b0aee840383cec23b
BLAKE2b-256 5fe9c998162d24d4993bb32e2031debf934820e7cb614757386e22e60c48b4f0

See more details on using hashes here.

File details

Details for the file core_flux-0.3.2b1-py2.py3-none-any.whl.

File metadata

  • Download URL: core_flux-0.3.2b1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.33.0

File hashes

Hashes for core_flux-0.3.2b1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1a21d395ca8149b9deb11f2c38f9f63683b3133b9c99fb57e82164617cafae5b
MD5 3e7a943cbc433c75576c41813aa4dc2d
BLAKE2b-256 f8bf1ca9336c9c4bfeb133f1de5686b2c2c7fff2a9b9bdafa8f99a961e4b8060

See more details on using hashes here.

Supported by

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