core-flux 0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- core_flux-0.2/.DS_Store +0 -0
- core_flux-0.2/.gitignore +9 -0
- core_flux-0.2/PKG-INFO +106 -0
- core_flux-0.2/README.md +97 -0
- core_flux-0.2/fastvideo/__init__.py +3 -0
- core_flux-0.2/fastvideo/engine.py +62 -0
- core_flux-0.2/pyproject.toml +17 -0
core_flux-0.2/.DS_Store
ADDED
|
Binary file
|
core_flux-0.2/.gitignore
ADDED
core_flux-0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: core-flux
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: A blazing fast video editing library wrapping FFmpeg native filters.
|
|
5
|
+
Author: Faaris
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Dist: ffmpeg-python>=0.2.0
|
|
9
|
+
|
|
10
|
+
# FastVideo 🚀
|
|
11
|
+
|
|
12
|
+
A high-performance video editing library built on top of native FFmpeg filters.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install core-flux
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from fastvideo import FastVideo
|
|
26
|
+
|
|
27
|
+
video = FastVideo("input.mp4")
|
|
28
|
+
|
|
29
|
+
# Trim, resize, punch up colors, and fade out
|
|
30
|
+
(
|
|
31
|
+
video
|
|
32
|
+
.trim(start_time=2, end_time=7)
|
|
33
|
+
.resize(1280, 720)
|
|
34
|
+
.adjust_colors(contrast=1.3, saturation=1.4)
|
|
35
|
+
.fade_out(start_fade=4.0, duration=1.0)
|
|
36
|
+
.render("output.mp4")
|
|
37
|
+
)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Trimming** — cut clips to exact start and end times
|
|
43
|
+
- **Resizing** — scale video to any resolution
|
|
44
|
+
- **Color grading** — tweak contrast and saturation with simple parameters
|
|
45
|
+
- **Fade effects** — add smooth fade-outs with configurable timing
|
|
46
|
+
- **Chainable API** — compose operations fluently in a single expression
|
|
47
|
+
- **FFmpeg-native** — all processing runs through battle-tested FFmpeg filters for maximum performance
|
|
48
|
+
|
|
49
|
+
## API Reference
|
|
50
|
+
|
|
51
|
+
### `FastVideo(path)`
|
|
52
|
+
|
|
53
|
+
Load a video file for editing.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
video = FastVideo("input.mp4")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `.trim(start_time, end_time)`
|
|
60
|
+
|
|
61
|
+
Cut the video between two timestamps (in seconds).
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
video.trim(start_time=2, end_time=7)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `.resize(width, height)`
|
|
68
|
+
|
|
69
|
+
Scale the video to the given dimensions in pixels.
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
video.resize(1280, 720)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `.adjust_colors(contrast, saturation)`
|
|
76
|
+
|
|
77
|
+
Adjust contrast and saturation. Values above `1.0` increase the effect; below `1.0` decrease it.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
video.adjust_colors(contrast=1.3, saturation=1.4)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### `.fade_out(start_fade, duration)`
|
|
84
|
+
|
|
85
|
+
Add a fade-to-black effect starting at `start_fade` seconds, lasting `duration` seconds.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
video.fade_out(start_fade=4.0, duration=1.0)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `.render(output_path)`
|
|
92
|
+
|
|
93
|
+
Write the processed video to disk.
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
video.render("output.mp4")
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Requirements
|
|
100
|
+
|
|
101
|
+
- Python 3.8+
|
|
102
|
+
- FFmpeg installed and available on your `PATH`
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT
|
core_flux-0.2/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# FastVideo 🚀
|
|
2
|
+
|
|
3
|
+
A high-performance video editing library built on top of native FFmpeg filters.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install core-flux
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from fastvideo import FastVideo
|
|
17
|
+
|
|
18
|
+
video = FastVideo("input.mp4")
|
|
19
|
+
|
|
20
|
+
# Trim, resize, punch up colors, and fade out
|
|
21
|
+
(
|
|
22
|
+
video
|
|
23
|
+
.trim(start_time=2, end_time=7)
|
|
24
|
+
.resize(1280, 720)
|
|
25
|
+
.adjust_colors(contrast=1.3, saturation=1.4)
|
|
26
|
+
.fade_out(start_fade=4.0, duration=1.0)
|
|
27
|
+
.render("output.mp4")
|
|
28
|
+
)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **Trimming** — cut clips to exact start and end times
|
|
34
|
+
- **Resizing** — scale video to any resolution
|
|
35
|
+
- **Color grading** — tweak contrast and saturation with simple parameters
|
|
36
|
+
- **Fade effects** — add smooth fade-outs with configurable timing
|
|
37
|
+
- **Chainable API** — compose operations fluently in a single expression
|
|
38
|
+
- **FFmpeg-native** — all processing runs through battle-tested FFmpeg filters for maximum performance
|
|
39
|
+
|
|
40
|
+
## API Reference
|
|
41
|
+
|
|
42
|
+
### `FastVideo(path)`
|
|
43
|
+
|
|
44
|
+
Load a video file for editing.
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
video = FastVideo("input.mp4")
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `.trim(start_time, end_time)`
|
|
51
|
+
|
|
52
|
+
Cut the video between two timestamps (in seconds).
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
video.trim(start_time=2, end_time=7)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `.resize(width, height)`
|
|
59
|
+
|
|
60
|
+
Scale the video to the given dimensions in pixels.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
video.resize(1280, 720)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `.adjust_colors(contrast, saturation)`
|
|
67
|
+
|
|
68
|
+
Adjust contrast and saturation. Values above `1.0` increase the effect; below `1.0` decrease it.
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
video.adjust_colors(contrast=1.3, saturation=1.4)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `.fade_out(start_fade, duration)`
|
|
75
|
+
|
|
76
|
+
Add a fade-to-black effect starting at `start_fade` seconds, lasting `duration` seconds.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
video.fade_out(start_fade=4.0, duration=1.0)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `.render(output_path)`
|
|
83
|
+
|
|
84
|
+
Write the processed video to disk.
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
video.render("output.mp4")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Requirements
|
|
91
|
+
|
|
92
|
+
- Python 3.8+
|
|
93
|
+
- FFmpeg installed and available on your `PATH`
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import ffmpeg
|
|
2
|
+
import time # New import to measure speed!
|
|
3
|
+
|
|
4
|
+
class FastVideo:
|
|
5
|
+
def __init__(self, input_path):
|
|
6
|
+
"""Initialize the toolkit with an input video path."""
|
|
7
|
+
self.input_path = input_path
|
|
8
|
+
self.video_stream = ffmpeg.input(input_path)
|
|
9
|
+
self.audio_stream = ffmpeg.input(input_path).audio
|
|
10
|
+
|
|
11
|
+
def resize(self, width, height):
|
|
12
|
+
"""Resizes the video using FFmpeg's native scale filter."""
|
|
13
|
+
self.video_stream = self.video_stream.filter('scale', width, height)
|
|
14
|
+
return self
|
|
15
|
+
|
|
16
|
+
def adjust_colors(self, contrast=1.0, brightness=0.0, saturation=1.0):
|
|
17
|
+
"""Adjusts video contrast, brightness, and saturation."""
|
|
18
|
+
self.video_stream = self.video_stream.filter(
|
|
19
|
+
'eq',
|
|
20
|
+
contrast=contrast,
|
|
21
|
+
brightness=brightness,
|
|
22
|
+
saturation=saturation
|
|
23
|
+
)
|
|
24
|
+
return self
|
|
25
|
+
|
|
26
|
+
def trim(self, start_time, end_time):
|
|
27
|
+
"""Cuts the video and audio to only keep the section between start_time and end_time (in seconds)."""
|
|
28
|
+
# Trim the video pixels
|
|
29
|
+
self.video_stream = self.video_stream.filter('trim', start=start_time, end=end_time).filter('setpts', 'PTS-STARTPTS')
|
|
30
|
+
# Trim the audio sync'd up with the video
|
|
31
|
+
self.audio_stream = self.audio_stream.filter('atrim', start=start_time, end=end_time).filter('asetpts', 'PTS-STARTPTS')
|
|
32
|
+
return self
|
|
33
|
+
|
|
34
|
+
def fade_out(self, start_fade, duration=1.0):
|
|
35
|
+
"""Smoothly fades the video to black. start_fade is when it begins, duration is how long it takes."""
|
|
36
|
+
self.video_stream = self.video_stream.filter('fade', type='out', start_time=start_fade, duration=duration)
|
|
37
|
+
return self
|
|
38
|
+
|
|
39
|
+
def render(self, output_path):
|
|
40
|
+
"""Fuses video/audio together, runs the engine, and times the execution."""
|
|
41
|
+
print(f"🚀 Sending commands to FFmpeg... Rendering {output_path}")
|
|
42
|
+
|
|
43
|
+
# Start the stopwatch
|
|
44
|
+
start_clock = time.time()
|
|
45
|
+
|
|
46
|
+
output = ffmpeg.output(
|
|
47
|
+
self.video_stream,
|
|
48
|
+
self.audio_stream,
|
|
49
|
+
output_path,
|
|
50
|
+
vcodec='libx264',
|
|
51
|
+
acodec='aac',
|
|
52
|
+
pix_fmt='yuv420p'
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
output.overwrite_output().run()
|
|
56
|
+
|
|
57
|
+
# Stop the stopwatch
|
|
58
|
+
end_clock = time.time()
|
|
59
|
+
time_taken = end_clock - start_clock
|
|
60
|
+
|
|
61
|
+
print("✅ Render Complete!")
|
|
62
|
+
print(f"⏱️ Execution Time: {time_taken:.2f} seconds")
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core >=3.2,<4"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "core-flux"
|
|
7
|
+
version = "0.2"
|
|
8
|
+
description = "A blazing fast video editing library wrapping FFmpeg native filters."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{name = "Faaris"}]
|
|
11
|
+
classifiers = ["Programming Language :: Python :: 3"]
|
|
12
|
+
dependencies = [
|
|
13
|
+
"ffmpeg-python>=0.2.0"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.flit.module]
|
|
17
|
+
name = "fastvideo"
|