VideoSpeed 1.0.0__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.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: VideoSpeed
3
+ Version: 1.0.0
4
+ Summary: A logging example application with sudo detection and log rotation
5
+ Author-email: Wilgat Wong <wilgat.wong@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Wilgat/VideoSpeed
8
+ Project-URL: Repository, https://github.com/Wilgat/VideoSpeed
9
+ Project-URL: Issues, https://github.com/Wilgat/VideoSpeed/issues
10
+ Keywords: logging,sudo,chronicle,example
11
+ Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: ChronicleLogger>=1.0.0
14
+
15
+ # VideoSpeed
16
+
17
+ A command-line video editing tool built in Python for cutting, speeding up, and applying a boomerang effect to MP4 videos. This project leverages FFmpeg for video processing and OpenCV to handle video file properties.
18
+
19
+ ## Features
20
+
21
+ - **Cut segments** from MP4 videos.
22
+ - Change the **speed** of video clips.
23
+ - Apply a **boomerang effect** by reversing video segments.
24
+ - Simple command-line interface for user interaction.
25
+
26
+ ## Installation
27
+
28
+ To install the VideoSpeed package, use the provided distributions:
29
+
30
+ 1. Download the wheel or tar.gz file from the `dist` directory:
31
+ - `VideoSpeed-1.0.0-py3-none-any.whl`
32
+ - `VideoSpeed-1.0.0.tar.gz`
33
+
34
+ 2. Install via pip:
35
+ ```bash
36
+ pip install dist/VideoSpeed-1.0.0-py3-none-any.whl
37
+ ```
38
+
39
+ Or
40
+ ```bash
41
+ pip install dist/VideoSpeed-1.0.0.tar.gz
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ You can run the tool directly from the command line:
47
+
48
+ ```bash
49
+ python -m VideoSpeed
50
+ ```
51
+
52
+ ### Steps:
53
+ 1. Select the folder containing your MP4 files (default is the current directory).
54
+ 2. Choose the video file from the listed options.
55
+ 3. Specify the start and end time for the cut.
56
+ 4. Enter the desired speed percentage for the clip.
57
+ 5. Optionally, choose to add a boomerang effect.
58
+ 6. The processed video will be saved in the same directory as the source file.
59
+
60
+ ## Folder Structure
61
+
62
+ ```
63
+ VideoSpeed
64
+ ├── build/ # Contains build artifacts
65
+ ├── dist/ # Distributions for installation
66
+ ├── docs/ # Documentation files
67
+ │ ├── CHANGELOG.md # Changes in each version
68
+ │ ├── folder-structure.md# Describes folder structure
69
+ │ └── LoggedExample-spec.md # Specifications for examples
70
+ ├── src/ # Source code directory
71
+ │ ├── VideoSpeed/ # Main package
72
+ │ ├── setup.py # Installation script
73
+ └── README.md # Project documentation
74
+ ```
75
+
76
+ ## Requirements
77
+
78
+ - Python 3.6 or higher
79
+ - FFmpeg installed on your system
80
+ - OpenCV library (`opencv-python`)
81
+
82
+ You can install OpenCV using pip:
83
+
84
+ ```bash
85
+ pip install opencv-python
86
+ ```
87
+
88
+ ## Contributing
89
+
90
+ Contributions are welcome! Please fork the repository and submit a pull request.
91
+
92
+ ## License
93
+
94
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
95
+
96
+ ## Acknowledgements
97
+
98
+ - **FFmpeg**: A powerful multimedia framework for handling video files.
99
+ - **OpenCV**: A library for computer vision tasks.
@@ -0,0 +1,85 @@
1
+ # VideoSpeed
2
+
3
+ A command-line video editing tool built in Python for cutting, speeding up, and applying a boomerang effect to MP4 videos. This project leverages FFmpeg for video processing and OpenCV to handle video file properties.
4
+
5
+ ## Features
6
+
7
+ - **Cut segments** from MP4 videos.
8
+ - Change the **speed** of video clips.
9
+ - Apply a **boomerang effect** by reversing video segments.
10
+ - Simple command-line interface for user interaction.
11
+
12
+ ## Installation
13
+
14
+ To install the VideoSpeed package, use the provided distributions:
15
+
16
+ 1. Download the wheel or tar.gz file from the `dist` directory:
17
+ - `VideoSpeed-1.0.0-py3-none-any.whl`
18
+ - `VideoSpeed-1.0.0.tar.gz`
19
+
20
+ 2. Install via pip:
21
+ ```bash
22
+ pip install dist/VideoSpeed-1.0.0-py3-none-any.whl
23
+ ```
24
+
25
+ Or
26
+ ```bash
27
+ pip install dist/VideoSpeed-1.0.0.tar.gz
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ You can run the tool directly from the command line:
33
+
34
+ ```bash
35
+ python -m VideoSpeed
36
+ ```
37
+
38
+ ### Steps:
39
+ 1. Select the folder containing your MP4 files (default is the current directory).
40
+ 2. Choose the video file from the listed options.
41
+ 3. Specify the start and end time for the cut.
42
+ 4. Enter the desired speed percentage for the clip.
43
+ 5. Optionally, choose to add a boomerang effect.
44
+ 6. The processed video will be saved in the same directory as the source file.
45
+
46
+ ## Folder Structure
47
+
48
+ ```
49
+ VideoSpeed
50
+ ├── build/ # Contains build artifacts
51
+ ├── dist/ # Distributions for installation
52
+ ├── docs/ # Documentation files
53
+ │ ├── CHANGELOG.md # Changes in each version
54
+ │ ├── folder-structure.md# Describes folder structure
55
+ │ └── LoggedExample-spec.md # Specifications for examples
56
+ ├── src/ # Source code directory
57
+ │ ├── VideoSpeed/ # Main package
58
+ │ ├── setup.py # Installation script
59
+ └── README.md # Project documentation
60
+ ```
61
+
62
+ ## Requirements
63
+
64
+ - Python 3.6 or higher
65
+ - FFmpeg installed on your system
66
+ - OpenCV library (`opencv-python`)
67
+
68
+ You can install OpenCV using pip:
69
+
70
+ ```bash
71
+ pip install opencv-python
72
+ ```
73
+
74
+ ## Contributing
75
+
76
+ Contributions are welcome! Please fork the repository and submit a pull request.
77
+
78
+ ## License
79
+
80
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
81
+
82
+ ## Acknowledgements
83
+
84
+ - **FFmpeg**: A powerful multimedia framework for handling video files.
85
+ - **OpenCV**: A library for computer vision tasks.
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "VideoSpeed"
7
+ version = "1.0.0"
8
+ description = "A logging example application with sudo detection and log rotation"
9
+ readme = "README.md"
10
+ requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Wilgat Wong", email = "wilgat.wong@gmail.com"}
14
+ ]
15
+ keywords = ["logging", "sudo", "chronicle", "example"]
16
+
17
+ dependencies = [
18
+ "ChronicleLogger>=1.0.0",
19
+ ]
20
+
21
+ # Official project links (this is what shows on PyPI!)
22
+ [project.urls]
23
+ Homepage = "https://github.com/Wilgat/VideoSpeed"
24
+ Repository = "https://github.com/Wilgat/VideoSpeed"
25
+ Issues = "https://github.com/Wilgat/VideoSpeed/issues"
26
+
27
+ # This makes `logged-example` command available after pip install
28
+ [project.scripts]
29
+ logged-example = "VideoSpeed.cli:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from .cli import ChronicleLogger, VideoSpeed
2
+
3
+ __version__ = "1.0.0"
4
+ __all__ = ["ChronicleLogger", "VideoSpeed"]
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env python
2
+ from __future__ import print_function, unicode_literals
3
+ import cv2
4
+ import sys
5
+ from ChronicleLogger import ChronicleLogger
6
+ import subprocess
7
+ from pathlib import Path
8
+ import tempfile
9
+ import os
10
+
11
+ def run_ffmpeg(cmd):
12
+ print(f" Running → {' '.join(cmd)}")
13
+ subprocess.run(cmd, check=True)
14
+
15
+ def get_mp4_files(folder="."):
16
+ folder = Path(folder)
17
+ files = list(folder.rglob("*.mp4")) + list(folder.rglob("*.MP4"))
18
+ files = [f for f in files if f.is_file()]
19
+ files.sort(key=lambda x: x.name.lower())
20
+ return files
21
+
22
+ def get_duration_cv2(video_path):
23
+ cap = cv2.VideoCapture(str(video_path))
24
+ fps = cap.get(cv2.CAP_PROP_FPS)
25
+ frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
26
+ cap.release()
27
+ return frame_count / fps if fps > 0 else 0
28
+
29
+ def format_time(seconds):
30
+ h = int(seconds // 3600)
31
+ m = int((seconds % 3600) // 60)
32
+ s = seconds % 60
33
+ return f"{h:02d}:{m:02d}:{s:06.3f}"[3:] if h == 0 else f"{h:02d}:{m:02d}:{s:06.3f}"
34
+
35
+ def cut_clip(src, start, end, output_path):
36
+ cmd = [
37
+ "ffmpeg", "-y", "-hide_banner", "-loglevel", "error",
38
+ "-i", str(src),
39
+ "-vf", f"trim=start={start}:end={end},setpts=PTS-STARTPTS",
40
+ "-af", f"atrim=start={start}:end={end},asetpts=PTS-STARTPTS",
41
+ "-c:v", "libx264", "-preset", "ultrafast", "-crf", "17",
42
+ "-c:a", "aac", "-avoid_negative_ts", "make_zero",
43
+ str(output_path)
44
+ ]
45
+ print(" ".join(cmd))
46
+
47
+ run_ffmpeg(cmd)
48
+
49
+ def speed_change(input_path, ratio_percent, output_path):
50
+ speed = 100.0 / ratio_percent
51
+ cmd = [
52
+ "ffmpeg", "-y", "-hide_banner", "-loglevel", "error",
53
+ "-i", str(input_path),
54
+ "-filter_complex",
55
+ f"[0:v]setpts={1/speed:.6f}*PTS[v];[0:a]atempo={speed:.6f}[a]",
56
+ "-map", "[v]", "-map", "[a]",
57
+ "-c:v", "libx264", "-preset", "medium", "-crf", "18",
58
+ "-c:a", "aac", "-b:a", "192k",
59
+ "-movflags", "+faststart",
60
+ str(output_path)
61
+ ]
62
+ print(" ".join(cmd))
63
+ run_ffmpeg(cmd)
64
+
65
+ def add_boomerang(forward_clip, final_output):
66
+ with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmp:
67
+ reverse_clip = Path(tmp.name)
68
+
69
+ run_ffmpeg([
70
+ "ffmpeg", "-y", "-hide_banner", "-loglevel", "error",
71
+ "-i", str(forward_clip), "-vf", "reverse", "-af", "areverse", str(reverse_clip)
72
+ ])
73
+ with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
74
+ f.write(f"file '{forward_clip}'\nfile '{reverse_clip}'\n")
75
+ concat_list = Path(f.name)
76
+ run_ffmpeg([
77
+ "ffmpeg", "-y", "-hide_banner", "-loglevel", "error",
78
+ "-f", "concat", "-safe", "0", "-i", str(concat_list),
79
+ "-c", "copy", str(final_output)
80
+ ])
81
+ os.unlink(reverse_clip)
82
+ os.unlink(concat_list)
83
+
84
+ def main():
85
+ print("ULTIMATE Video Editor: Cut → Speed → Optional Boomerang")
86
+ print("=" * 62)
87
+
88
+ folder = input("Folder (Enter = current): ").strip() or "."
89
+ files = get_mp4_files(folder)
90
+ if not files:
91
+ print("No MP4 files found!"); return
92
+ for i, f in enumerate(files, 1):
93
+ print(f"{i:2d}. {f.name}")
94
+ video_path = files[int(input(f"\nChoose video (1-{len(files)}): ")) - 1]
95
+
96
+ duration = get_duration_cv2(video_path)
97
+ print(f"\nSelected: {video_path.name}")
98
+ print(f"Duration: {format_time(duration)} ({duration:.3f}s)\n")
99
+
100
+ while True:
101
+ print("Step 1/4 – Cut segment")
102
+ start_str = input(" Start seconds (default 0.0): ").strip()
103
+ start = 0.0 if start_str == "" else float(start_str)
104
+ print(f" → Using start: {start:.3f}s")
105
+
106
+ end_str = input(f" End seconds [{duration:.3f}]: ").strip()
107
+ end = duration if end_str == "" else float(end_str)
108
+
109
+ if not (0 <= start < end <= duration):
110
+ print("Invalid range!\n"); continue
111
+
112
+ print("\nStep 2/4 – Resize length (20–200%)")
113
+ ratio_str = input(" New length % [100%]: ").strip() or "100"
114
+ ratio = float(ratio_str.replace("%", ""))
115
+
116
+ print("\nStep 3/4 – Add boomerang effect?")
117
+ boomerang = input(" Make it go forward + backward (y/n) [n]: ").strip().lower() == 'y'
118
+
119
+ name = f"{video_path.stem}_cut{start:.1f}-{end:.1f}s_{int(ratio)}pct"
120
+ if boomerang: name += "_BOOMERANG"
121
+ name += ".mp4"
122
+ final_out = video_path.parent / name
123
+
124
+ print(f"\nProcessing → {final_out}\n")
125
+
126
+ with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as t1, \
127
+ tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as t2:
128
+ cut_temp = Path(t1.name)
129
+ speed_temp = Path(t2.name)
130
+
131
+ try:
132
+ print("1. Cutting segment...")
133
+ cut_clip(video_path, start, end, cut_temp)
134
+ print(f"2. Changing length to {ratio}%...")
135
+ speed_change(cut_temp, ratio, speed_temp)
136
+ if boomerang:
137
+ print("3. Creating boomerang...")
138
+ add_boomerang(speed_temp, final_out)
139
+ else:
140
+ os.replace(speed_temp, final_out)
141
+ print(f"\nSUCCESS → {final_out}\n")
142
+ finally:
143
+ for p in (cut_temp, speed_temp):
144
+ if p.exists(): os.unlink(p)
145
+
146
+ if input("Again? (y/n): ").lower() != 'y': break
147
+
148
+ print("Done.")
149
+
150
+ if __name__ == "__main__":
151
+ main()
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: VideoSpeed
3
+ Version: 1.0.0
4
+ Summary: A logging example application with sudo detection and log rotation
5
+ Author-email: Wilgat Wong <wilgat.wong@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Wilgat/VideoSpeed
8
+ Project-URL: Repository, https://github.com/Wilgat/VideoSpeed
9
+ Project-URL: Issues, https://github.com/Wilgat/VideoSpeed/issues
10
+ Keywords: logging,sudo,chronicle,example
11
+ Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: ChronicleLogger>=1.0.0
14
+
15
+ # VideoSpeed
16
+
17
+ A command-line video editing tool built in Python for cutting, speeding up, and applying a boomerang effect to MP4 videos. This project leverages FFmpeg for video processing and OpenCV to handle video file properties.
18
+
19
+ ## Features
20
+
21
+ - **Cut segments** from MP4 videos.
22
+ - Change the **speed** of video clips.
23
+ - Apply a **boomerang effect** by reversing video segments.
24
+ - Simple command-line interface for user interaction.
25
+
26
+ ## Installation
27
+
28
+ To install the VideoSpeed package, use the provided distributions:
29
+
30
+ 1. Download the wheel or tar.gz file from the `dist` directory:
31
+ - `VideoSpeed-1.0.0-py3-none-any.whl`
32
+ - `VideoSpeed-1.0.0.tar.gz`
33
+
34
+ 2. Install via pip:
35
+ ```bash
36
+ pip install dist/VideoSpeed-1.0.0-py3-none-any.whl
37
+ ```
38
+
39
+ Or
40
+ ```bash
41
+ pip install dist/VideoSpeed-1.0.0.tar.gz
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ You can run the tool directly from the command line:
47
+
48
+ ```bash
49
+ python -m VideoSpeed
50
+ ```
51
+
52
+ ### Steps:
53
+ 1. Select the folder containing your MP4 files (default is the current directory).
54
+ 2. Choose the video file from the listed options.
55
+ 3. Specify the start and end time for the cut.
56
+ 4. Enter the desired speed percentage for the clip.
57
+ 5. Optionally, choose to add a boomerang effect.
58
+ 6. The processed video will be saved in the same directory as the source file.
59
+
60
+ ## Folder Structure
61
+
62
+ ```
63
+ VideoSpeed
64
+ ├── build/ # Contains build artifacts
65
+ ├── dist/ # Distributions for installation
66
+ ├── docs/ # Documentation files
67
+ │ ├── CHANGELOG.md # Changes in each version
68
+ │ ├── folder-structure.md# Describes folder structure
69
+ │ └── LoggedExample-spec.md # Specifications for examples
70
+ ├── src/ # Source code directory
71
+ │ ├── VideoSpeed/ # Main package
72
+ │ ├── setup.py # Installation script
73
+ └── README.md # Project documentation
74
+ ```
75
+
76
+ ## Requirements
77
+
78
+ - Python 3.6 or higher
79
+ - FFmpeg installed on your system
80
+ - OpenCV library (`opencv-python`)
81
+
82
+ You can install OpenCV using pip:
83
+
84
+ ```bash
85
+ pip install opencv-python
86
+ ```
87
+
88
+ ## Contributing
89
+
90
+ Contributions are welcome! Please fork the repository and submit a pull request.
91
+
92
+ ## License
93
+
94
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
95
+
96
+ ## Acknowledgements
97
+
98
+ - **FFmpeg**: A powerful multimedia framework for handling video files.
99
+ - **OpenCV**: A library for computer vision tasks.
@@ -0,0 +1,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/setup.py
4
+ src/VideoClip/__init__.py
5
+ src/VideoClip/__main__.py
6
+ src/VideoClip/cli.py
7
+ src/VideoSpeed.egg-info/PKG-INFO
8
+ src/VideoSpeed.egg-info/SOURCES.txt
9
+ src/VideoSpeed.egg-info/dependency_links.txt
10
+ src/VideoSpeed.egg-info/entry_points.txt
11
+ src/VideoSpeed.egg-info/requires.txt
12
+ src/VideoSpeed.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ logged-example = VideoSpeed.cli:main
@@ -0,0 +1 @@
1
+ ChronicleLogger>=1.0.0
@@ -0,0 +1,2 @@
1
+ VideoClip
2
+ setup
@@ -0,0 +1,7 @@
1
+ #!/home/adm01/.pyenv/shims/python3
2
+ from setuptools import setup
3
+ from Cython.Build import cythonize
4
+
5
+ setup(
6
+ ext_modules=cythonize("src/VideoSpeed.pyx",compiler_directives={"language_level" : "3"})
7
+ )