# Arithmetic for the storage guide: GB per hour from Mbps, hours that fit, implied Mbps of quoted per-minute figures.
# Usage: python3 plan.py   (no inputs; every number printed is computed here)
GIB = 2**30
rows = [("1080p30 H.264", 10), ("1080p60 H.264", 15), ("4K30 H.264", 23), ("4K60 H.264", 40), ("4K30 HEVC", 24.1)]
AUDIO = 0.13
print("profile | Mbps video+audio | GB(1e9)/h | GiB/h | MB(1e6)/min")
for n, v in rows:
    t = v + AUDIO
    byt_h = t * 1e6 * 3600 / 8
    print(f"{n} | {t:.2f} | {byt_h/1e9:.1f} | {byt_h/GIB:.1f} | {t*1e6*60/8/1e6:.0f}")
print("hours that fit (decimal GB free / GB per hour), 30/60/100 GB free")
for n, v in rows:
    gb_h = (v + AUDIO) * 1e6 * 3600 / 8 / 1e9
    print(n, [round(f / gb_h, 1) for f in (30, 60, 100)])
print("binary/decimal ratio", round(GIB / 1e9, 4))
print("implied Mbps of quoted per-minute figures (decimal MB, binary MiB)")
for label, mb in (("Apple 4K30 175 MB", 175), ("iDownloadBlog 4K30 H.264 350", 350), ("iDownloadBlog 4K60 HEVC 400", 400)):
    print(label, round(mb * 1e6 * 8 / 60 / 1e6, 1), round(mb * 2**20 * 8 / 60 / 1e6, 1))
print("CRF pair: 18.96/16.48 -1 =", round((18.96 / 16.48 - 1) * 100, 1), "%")
print("4K60 vs 1080p30 measured:", round(312924714 / 79148736, 2), "x ; 4K30 vs 1080p30:", round(180502966 / 79148736, 2), "x")
print("hours that fit from the MEASURED GB(1e9)/h of the test files (free GB / GB per hour), 30/60/100 GB free")
for n, g in (("1080p30 H.264", 4.75), ("1080p60 H.264", 7.10), ("4K30 H.264", 10.83), ("4K60 H.264", 18.78), ("4K30 HEVC", 10.91)):
    print(n, g, [round(f / g, 1) for f in (30, 60, 100)], [f"{int(f/g)} h {round((f/g-int(f/g))*60)} min" for f in (30, 60, 100)])
print("4K60 H.264 vs 1080p30 hours at 60 GB:", round(60/18.78, 1), "vs", round(60/4.75, 1))
print("checks for the page text")
print("blog 400 MB vs measured 4K60 312.9:", round(400/312.9, 3), "| 4K60 implied by 400 MB per minute, GB/h decimal:", round(400*60/1000, 1))
print("Apple 175 MB vs measured 4K30 H.264 180.5:", round((180.5/175-1)*100, 1), "% ; vs HEVC 181.8:", round((181.8/175-1)*100, 1), "%")
print("ProRes 422 4.4 GB/min x 60 =", round(4.4*60), "GB/h ; 4.4 GB per min vs measured 4K30 H.264 180.5 MB:", round(4400/180.5, 1), "x")
print("CRF pair decimal MB/min:", round(17283388/1e6, 2), round(19884716/1e6, 2), "+", round((19884716/17283388-1)*100, 1), "%")
print("7 s edge: bytes 13145186 / 7.0 s x 60 =", round(13145186/7.0*60/1e6, 1), "MB/min ; vs p3 180.5:", round((13145186/7.0*60/1e6/180.5-1)*100, 1), "% ; video kbps 14884 vs p3 23929 target 23000")
print("MB per minute = Mbps x 7.5 check: 10.415 x 7.5 =", round(10.415*7.5, 1), " 41.58 x 7.5 =", round(41.58*7.5, 1), "(video only, add 130 kbps audio = 0.98 MB)")
print("1 GB/h = MB/min x 60/1000: 79.15 ->", round(79.15*60/1000, 2), " 312.92 ->", round(312.92*60/1000, 2))
