Captions are table stakes for short-form — a clip without them barely works on any platform — but every burn cost 2 minutes, 10% of the free monthly quota, roughly what generating the clip cost in the first place. People skipped them: only 9% of delivered clips had captions in the 25-jul-2026 prod audit (35 subtitle jobs against 380 process jobs). The charge never matched the work. The normal path reads the transcript already stored in metadata.json and runs one short FFmpeg pass — measured at 4s on CPU for a 12s clip, 1-2s on the GPU. Charging 120s of quota for that is ~30x the compute, and it was invisible in the UI, so users were drained without being told. The endpoint is already gated by require_managed_entitlement, so the charge was never what bounded abuse. Dubbed clips keep the charge: subtitling them re-runs Whisper over the translated audio, which is real work. The rule lives in cloud.config next to the constant so it stays testable without importing app. Also short-circuit reserve_managed_action on a zero-minute action rather than writing a 0-minute ledger row on every call.
32 lines
1.5 KiB
Python
32 lines
1.5 KiB
Python
"""What burning captions costs the user.
|
|
|
|
Captions are mandatory for short-form to work at all, and the normal path costs
|
|
the server nothing beyond one short FFmpeg pass — the transcript is already in
|
|
metadata.json. Charging for it (2 min, 10% of the free monthly quota per clip)
|
|
priced captions out of the product: only 9% of delivered clips had them in the
|
|
25-jul-2026 prod audit. Only the dubbed path, which re-runs Whisper, still pays.
|
|
"""
|
|
from cloud.config import SUBTITLE_MINUTES, subtitle_minutes_for
|
|
|
|
|
|
class TestSubtitleMetering:
|
|
def test_normal_clip_is_free(self):
|
|
assert subtitle_minutes_for("Some_Video_Title_clip_1.mp4") == 0
|
|
|
|
def test_already_subtitled_clip_is_free(self):
|
|
# Restyling captions must not cost anything either.
|
|
assert subtitle_minutes_for("subtitled_1784974487_My_Video_clip_1.mp4") == 0
|
|
|
|
def test_hooked_or_edited_clip_is_free(self):
|
|
assert subtitle_minutes_for("edited_My_Video_clip_2.mp4") == 0
|
|
|
|
def test_dubbed_clip_still_pays_for_the_transcription(self):
|
|
# This path runs a fresh Whisper pass over the translated audio.
|
|
assert subtitle_minutes_for("translated_es_My_Video_clip_1.mp4") == SUBTITLE_MINUTES
|
|
|
|
def test_dubbed_prefix_must_be_at_the_start(self):
|
|
# A clip merely containing the word must not be charged.
|
|
assert subtitle_minutes_for("my_translated_notes_clip_1.mp4") == 0
|
|
|
|
def test_handles_non_string_input(self):
|
|
assert subtitle_minutes_for(None) == 0
|