Skip to content

Commit 8de85d4

Browse files
authored
Merge pull request #8 from SimpNick6703/autoscale
Autoscale
2 parents 079ddf4 + acf33be commit 8de85d4

6 files changed

Lines changed: 962 additions & 76 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy Architecture Page
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- index.html
9+
- .github/workflows/deploy.yml
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: true
20+
21+
jobs:
22+
deploy:
23+
environment:
24+
name: github-pages
25+
url: ${{ steps.deployment.outputs.page_url }}
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Setup Pages
33+
uses: actions/configure-pages@v5
34+
35+
- name: Prepare site artifact
36+
shell: bash
37+
run: |
38+
mkdir -p _site
39+
cp index.html _site/index.html
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: _site
45+
46+
- name: Deploy to GitHub Pages
47+
id: deployment
48+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
run: pip install pyinstaller
3232

3333
- name: Build Executables
34+
env:
35+
BUILD_VERSION: ${{ github.ref_name }}
3436
run: python build.py
3537

3638
# --- Upload Section ---

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Discord has too small file size limit for free. And, any online video compressor
55
A normal user isn't curious about these configuration and just want a _targeted file size_ video compression with minimal quality loss.
66

77
So, here's a simple drag and drop usage (In Windows) easy solution.
8+
> [!TIP]
9+
> Visit [this page](https://simpnick6703.github.io/Video-Compression) for Architectural overview and more.
810
911
## Requirements
1012
For running the script locally (your own build):
@@ -23,7 +25,9 @@ For using prebuilt binaries from releases, you just need to download the executa
2325
- Download any of the target filesize build from [releases](<https://github.com/SimpNick6703/Video-Compression/releases>).
2426
- Drag and drop your video on the executable. (Or run in Command Prompt/Terminal as `./{size}mb-win64 <input.mp4> [output.mp4]`)
2527

26-
https://github.com/user-attachments/assets/0272427b-0db4-40dd-bd14-37d705d110a0
28+
29+
https://github.com/user-attachments/assets/2f9c79d7-ce15-41a5-8895-a89b549afa3e
30+
2731

2832
- In Linux:
2933
- Download your desired build from [releases](<https://github.com/SimpNick6703/Video-Compression/releases>).
@@ -45,7 +49,7 @@ python build.py
4549

4650
This will:
4751
1. Automatically download FFmpeg/FFprobe for your platform (if not already present)
48-
2. Generate all preset executables (8mb, 50mb, 100mb, 500mb) in `dist/`
52+
2. Generate all preset executables (10mb, 50mb, 100mb, 500mb) in `dist/`
4953
3. Clean up build artifacts and downloaded binaries
5054

5155
To keep build artifacts for debugging:
@@ -65,4 +69,4 @@ Considering the wide variety of hardware configurations, the script uses the fol
6569
6670
> [!NOTE]
6771
> Only NVENC supports Two-Pass encoding among the listed encoders. Other encoders use Single-Pass encoding only.
68-
> If your dedicated GPU is being bypassed in favor of integrated GPU or CPU encoding, you'll need to manually change the priority logic in the script to suit your hardware setup. Or, you may simply remove unwanted encoders from the priority list in the script, build the executable again, and use that custom build.
72+
> If your dedicated GPU is being bypassed in favor of integrated GPU or CPU encoding, you'll need to manually change the priority logic in the script to suit your hardware setup. Or, you may simply remove unwanted encoders from the priority list in the script, build the executable again, and use that custom build.

build.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
Build script for Video-Compression executables.
44
5-
Generates preset executables (8mb, 50mb, 100mb, 500mb) from videocompress.py
5+
Generates preset executables (10mb, 50mb, 100mb, 500mb) from videocompress.py
66
by creating temporary copies with hardcoded target sizes, then compiling with PyInstaller.
77
88
Usage:
@@ -23,7 +23,8 @@
2323
from pathlib import Path
2424

2525
# --- Configuration ---
26-
PRESET_SIZES = [8, 50, 100, 500]
26+
PRESET_SIZES = [10, 50, 100, 500]
27+
PRESET_CODECS = ["hevc", "h264"]
2728
SOURCE_SCRIPT = "videocompress.py"
2829
FFMPEG_BINARIES = ["ffmpeg", "ffprobe"]
2930
OUTPUT_DIR = "dist"
@@ -171,7 +172,7 @@ def check_ffmpeg_available() -> bool:
171172
return True
172173

173174

174-
def create_preset_script(target_mb: int, temp_dir: str) -> str:
175+
def create_preset_script(target_mb: int, codec: str, temp_dir: str) -> str:
175176
"""Create a temporary script with hardcoded target size."""
176177
with open(SOURCE_SCRIPT, "r", encoding="utf-8") as f:
177178
content = f.read()
@@ -183,24 +184,39 @@ def create_preset_script(target_mb: int, temp_dir: str) -> str:
183184
content
184185
)
185186

187+
# Replace the default codec value
188+
content = re.sub(
189+
r'CODEC_TYPE\s*=\s*"hevc"',
190+
f'CODEC_TYPE = "{codec}"',
191+
content
192+
)
193+
186194
# Update the usage message to reflect the preset
187195
content = re.sub(
188196
r'print\("Usage: python script\.py <input> \[output\] \[size_mb\]"\)',
189-
f'print("Usage: {target_mb}mb <input> [output]")',
197+
f'print("Usage: {target_mb}mb-{codec} <input> [output] [size_mb]")',
190198
content
191199
)
192200

193-
script_path = os.path.join(temp_dir, f"{target_mb}mb.py")
201+
script_path = os.path.join(temp_dir, f"{target_mb}mb_{codec}.py")
194202
with open(script_path, "w", encoding="utf-8") as f:
195203
f.write(content)
196204

197205
return script_path
198206

199207

200-
def build_executable(script_path: str, target_mb: int) -> bool:
208+
def build_executable(script_path: str, target_mb: int, codec: str) -> bool:
201209
"""Build a single executable using PyInstaller."""
202210
platform_suffix = get_platform_suffix()
203-
output_name = f"{target_mb}mb-{platform_suffix}"
211+
212+
version = os.environ.get("BUILD_VERSION")
213+
if version:
214+
# Sanitize version for filename (allow alphanumeric, dot, hyphen, underscore)
215+
# Using standard versioning (e.g. v1.1.0) is safer than stripping dots (110) to avoid ambiguity.
216+
safe_version = re.sub(r'[^\w\-\.]', '', version)
217+
output_name = f"{target_mb}mb-{codec}-{platform_suffix}-{safe_version}"
218+
else:
219+
output_name = f"{target_mb}mb-{codec}-{platform_suffix}"
204220

205221
log.info("Building %s...", output_name)
206222

@@ -287,8 +303,9 @@ def main() -> int:
287303

288304
with tempfile.TemporaryDirectory(prefix="vidcomp_build_") as temp_dir:
289305
for size in PRESET_SIZES:
290-
script_path = create_preset_script(size, temp_dir)
291-
results[size] = build_executable(script_path, size)
306+
for codec in PRESET_CODECS:
307+
script_path = create_preset_script(size, codec, temp_dir)
308+
results[f"{size}mb-{codec}"] = build_executable(script_path, size, codec)
292309

293310
# Clean build artifacts by default (unless --verbose)
294311
if not verbose:
@@ -302,7 +319,7 @@ def main() -> int:
302319

303320
for size, success in results.items():
304321
status = "Success" if success else "Failed"
305-
log.info(" %dMB: %s", size, status)
322+
log.info(" %s: %s", size, status)
306323

307324
failed = [s for s, ok in results.items() if not ok]
308325
if failed:

0 commit comments

Comments
 (0)