#!/usr/bin/env python3
"""Reference table for the video podcast file size guide (Koldflux, 2026-12-01).

Usage: python3 table.py
Size = (video kbps + audio kbps) x 1,000 x seconds / 8 bytes. GB = 1,000,000,000 bytes; Windows GB (GiB) = 1,073,741,824.
Bitrates are the platform recommendations read on 2026-12-01: YouTube Help "YouTube recommended upload encoding settings"
(SDR video bitrates; stereo audio 384 kbps) and Spotify for Creators "Video specs" (1080p 25 Mbit/s CBR, 4K 35 Mbit/s CBR,
audio 128 kbps or higher, file size less than 10 GB recommended, up to 60 GB). YouTube upload limit: 256 GB or 12 hours.
"""
PROFILES = [
    ("YouTube 720p, 24-30 fps", 5000, 384),
    ("YouTube 720p, 48-60 fps", 7500, 384),
    ("YouTube 1080p, 24-30 fps", 8000, 384),
    ("YouTube 1080p, 48-60 fps", 12000, 384),
    ("YouTube 1440p, 24-30 fps", 16000, 384),
    ("YouTube 4K, 24-30 fps, low end", 35000, 384),
    ("YouTube 4K, 24-30 fps, high end", 45000, 384),
    ("YouTube 4K, 48-60 fps, high end", 68000, 384),
    ("Spotify 1080p (CBR)", 25000, 128),
    ("Spotify 4K (CBR)", 35000, 128),
    ("Audio only, 128 kbps", 0, 128),
]
GB, GIB = 1e9, 2 ** 30


def size(kbps, seconds):
    return kbps * 1000 * seconds / 8


print("profile | video kbps | audio kbps | GB 60 min | GB 90 min | Windows GB 60 min | MB per minute | "
      "minutes in 10 GB | hours in 60 GB | hours in 256 GB")
for name, v, a in PROFILES:
    t = v + a
    print(f"{name} | {v} | {a} | {size(t, 3600) / GB:.2f} | {size(t, 5400) / GB:.2f} | {size(t, 3600) / GIB:.2f} | "
          f"{size(t, 60) / 1e6:.1f} | {10 * GB / size(t, 60):.1f} | {60 * GB / size(t, 3600):.2f} | {256 * GB / size(t, 3600):.2f}")
print()
print("rule: GB per hour = total kbps x 0.00045 (1,000 x 3,600 / 8 / 1,000,000,000)")
sp = 25000 + 128
print(f"Spotify 1080p at 25,128 kbps: the 10 GB recommendation is reached after {10 * GB / size(sp, 1):.0f} s "
      f"= {10 * GB / size(sp, 60):.1f} min; a 60 min episode is {size(sp, 3600) / GB:.2f} GB")
for kbps, label in ((8384, "YouTube 1080p30 8000+384"), (45384, "YouTube 4K30 45000+384"), (68384, "YouTube 4K60 68000+384")):
    print(f"{label}: 12 h = {size(kbps, 43200) / GB:.2f} GB (YouTube limit 256 GB)")
for kbps in (25128, 35128):
    print(f"{kbps} kbps: 12 h = {size(kbps, 43200) / GB:.2f} GB (Spotify limit 60 GB) -> "
          f"60 GB reached after {60 * GB / size(kbps, 3600):.2f} h")
