Eskesthai Repeatable Video Compression Model


Every video is processed with the same basic rules:

1. Keep the original duration.

2. Keep the original frame rate.

3. Do not upscale small videos.

4. Reduce very large videos to a maximum width of 1280 pixels.

5. Encode video as H.264 using CRF 25.

6. Use the veryfast encoding preset.

7. Encode audio as AAC stereo at 128 kbps.

8. Put the result in an MP4 container.

9. Add fast-start metadata so web players can begin playback sooner.

The output receives the suffix:

-compressed.mp4

Example:

The Pilot Wave.mp4

becomes:

The Pilot Wave-compressed.mp4

Running it

Install FFmpeg first, then run:

python compress_video.py “The Pilot Wave.mp4″

The program is deliberately simple so the same compression method can be repeated on every video.

Important duration rule

The program does not intentionally trim, speed up, or slow down the video.

If the original is 6:07, the compressed result should remain approximately 6:07.

Compression reduces the amount of data required to represent the same moving images and sound; it does not mean shortening the song.

Why this model

For the Eskesthai archive, the goal is not maximum possible compression at any cost. The goal is a repeatable balance:

SOURCE VIDEO
↓
same duration
same frame rate
no unnecessary enlargement
↓
H.264 CRF 25
AAC 128 kbps
↓
WEB-READY MP4
↓
WordPress

If a particular video shows unacceptable visual loss, the quality setting can be changed systematically rather than changing the method at random.


!/usr/bin/env python3

“””

Eskesthai Repeatable Video Compression Model

Purpose:
Compress videos for web/WordPress while preserving the original duration.

Compression model:
– H.264 video
– CRF 25 (quality-based compression)
– veryfast preset (repeatable and practical)
– preserve the original resolution when it is already <= 1280 px wide
– never upscale a smaller source
– AAC stereo audio at 128 kbps
– MP4 container
– fast-start metadata for web playback
– original frame rate is preserved

Usage:
python compress_video.py “My Video.mp4”

The compressed file is created beside the original as:
My Video-compressed.mp4

Requirements:
FFmpeg and FFprobe must be installed and available in PATH.
“””

import argparse
import shutil
import subprocess
import sys
from pathlib import Path

MAX_WIDTH = 1280
CRF = “25”
PRESET = “veryfast”
AUDIO_BITRATE = “128k”

def require_program(name):
if shutil.which(name) is None:
raise SystemExit(
f”ERROR: {name} was not found. Install FFmpeg and make sure “
f”ffmpeg/ffprobe are available in your system PATH.”
)

def probe_dimensions(path):
cmd = [
“ffprobe”, “-v”, “error”,
“-select_streams”, “v:0”,
“-show_entries”, “stream=width,height”,
“-of”, “csv=p=0:s=x”,
str(path),
]
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
width, height = result.stdout.strip().split(“x”)
return int(width), int(height)

def make_scale_filter(width):
# Do not upscale. Only reduce very large sources.
if width <= MAX_WIDTH:
return None
return f”scale={MAX_WIDTH}:-2″

def compress(input_path):
input_path = Path(input_path).expanduser().resolve()

if not input_path.exists():
    raise SystemExit(f"ERROR: File not found: {input_path}")

output_path = input_path.with_name(
    input_path.stem + "-compressed.mp4"
)

width, height = probe_dimensions(input_path)
scale_filter = make_scale_filter(width)

cmd = [
    "ffmpeg", "-y",
    "-i", str(input_path),
    "-map", "0:v:0",
    "-map", "0:a:0?",
    "-c:v", "libx264",
    "-preset", PRESET,
    "-crf", CRF,
    "-pix_fmt", "yuv420p",
]

if scale_filter:
    cmd += ["-vf", scale_filter]

cmd += [
    "-c:a", "aac",
    "-b:a", AUDIO_BITRATE,
    "-movflags", "+faststart",
    str(output_path),
]

print(f"\nInput : {input_path.name}")
print(f"Video : {width}x{height}")
print(f"Model : H.264 / CRF {CRF} / {PRESET}")
print(f"Audio : AAC {AUDIO_BITRATE}")
print(f"Output: {output_path.name}\n")

subprocess.run(cmd, check=True)

print("\nCompression complete.")
print(f"Created: {output_path}")

def main():
parser = argparse.ArgumentParser(
description=”Compress a video using the Eskesthai repeatable web/WordPress model.”
)
parser.add_argument(“video”, help=”Path to the video to compress”)
args = parser.parse_args()

require_program("ffmpeg")
require_program("ffprobe")
compress(args.video)

if name == “main“:
main()


Leave a Reply