diff --git a/assets/make_watermark.py b/assets/make_watermark.py new file mode 100644 index 0000000..a962d32 --- /dev/null +++ b/assets/make_watermark.py @@ -0,0 +1,46 @@ +"""Render the OpenShorts watermark lockup (white mark + wordmark) to a PNG. + +Pre-rendered at 4x so it downscales cleanly onto any clip size, with a soft +dark shadow so it stays legible over bright footage. +""" +from PIL import Image, ImageDraw, ImageFont, ImageFilter + +S = 4 # supersampling +H = 64 * S # lockup height +PAD = 6 * S + +font = ImageFont.truetype("/System/Library/Fonts/HelveticaNeue.ttc", int(38 * S), index=1) # Bold +text = "OpenShorts" + +tmp = Image.new("RGBA", (10, 10)) +tb = ImageDraw.Draw(tmp).textbbox((0, 0), text, font=font) +tw, th = tb[2] - tb[0], tb[3] - tb[1] + +mark = int(40 * S) # square mark +gap = int(12 * S) +W = mark + gap + tw + PAD * 2 + +img = Image.new("RGBA", (W, H), (0, 0, 0, 0)) +d = ImageDraw.Draw(img) + +# Rounded square outline + play triangle: reads as "clip/play" at small sizes. +mx, my = PAD, (H - mark) // 2 +r = int(mark * 0.28) +d.rounded_rectangle([mx, my, mx + mark, my + mark], radius=r, + outline=(255, 255, 255, 255), width=int(3.5 * S)) +t = mark * 0.30 +cx, cy = mx + mark / 2, my + mark / 2 +d.polygon([(cx - t * 0.55, cy - t), (cx - t * 0.55, cy + t), (cx + t * 0.85, cy)], + fill=(255, 255, 255, 255)) + +d.text((mx + mark + gap - tb[0], (H - th) // 2 - tb[1]), text, font=font, + fill=(255, 255, 255, 255)) + +# Soft shadow behind everything for contrast on light footage. +shadow = Image.new("RGBA", (W, H), (0, 0, 0, 0)) +shadow.paste((0, 0, 0, 170), (0, 0), img.split()[3]) +shadow = shadow.filter(ImageFilter.GaussianBlur(int(2.5 * S))) +out = Image.alpha_composite(shadow, img) + +out.save("watermark.png") +print("watermark.png", out.size) diff --git a/assets/watermark.png b/assets/watermark.png new file mode 100644 index 0000000..43b7b3b Binary files /dev/null and b/assets/watermark.png differ diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index 194b371..27590d9 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -1286,6 +1286,13 @@ function App() { /> )} + {/* The wait is dead time — the best moment to ask for a star. */} + {status === 'processing' && ( +
+ +
+ )} + {/* Logs Terminal */}
diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index dd79d26..cd26bcd 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -7,6 +7,8 @@ import HookModal from './HookModal'; import TranslateModal from './TranslateModal'; import Modal from './ui/Modal'; import SegmentedControl from './ui/SegmentedControl'; +import WatermarkModal, { watermarkNoticeDismissed } from './WatermarkModal'; +import { useAuth } from '../contexts/AuthContext'; import { renderInBrowser } from '../lib/renderInBrowser'; const QUIET_BTN = 'group flex flex-col items-center justify-center gap-1 py-2 px-1 rounded-input border border-rule hover:bg-paper3 text-[11px] lowercase text-ink2 whitespace-nowrap transition-colors disabled:opacity-45 disabled:cursor-not-allowed'; @@ -27,6 +29,8 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK const [showModal, setShowModal] = useState(false); const [showDescModal, setShowDescModal] = useState(false); const [showSubtitleModal, setShowSubtitleModal] = useState(false); + const [showWatermarkModal, setShowWatermarkModal] = useState(false); + const { plan } = useAuth(); const videoRef = React.useRef(null); // Pristine base clip (no burned subtitles/hook), stable regardless of how // clip.video_url mutates after server edits. Used as the compositing base @@ -39,6 +43,26 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK }; const originalVideoUrl = getApiUrl((clip.video_url || '').replace(/[^/]+$/, stripBurns((clip.video_url || '').split('/').pop()))); const [currentVideoUrl, setCurrentVideoUrl] = useState(getApiUrl(clip.video_url)); + + const downloadClip = async () => { + try { + const response = await fetch(currentVideoUrl); + if (!response.ok) throw new Error('Download failed'); + const blob = await response.blob(); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = `clip-${index + 1}.mp4`; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + document.body.removeChild(a); + } catch (err) { + console.error('Download error:', err); + window.open(currentVideoUrl, '_blank'); + } + }; // Latest file that exists ON THE SERVER (blob: previews don't count). // All server-side operations must chain from this, so burned-in edits // (subtitles, hooks, effects) never get silently dropped. @@ -685,25 +709,15 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK post
); } diff --git a/dashboard/src/components/WatermarkModal.jsx b/dashboard/src/components/WatermarkModal.jsx new file mode 100644 index 0000000..a4ca81c --- /dev/null +++ b/dashboard/src/components/WatermarkModal.jsx @@ -0,0 +1,65 @@ +import React, { useState } from 'react'; +import Modal from './ui/Modal'; + +const DISMISS_KEY = 'os_watermark_notice_dismissed'; + +export function watermarkNoticeDismissed() { + try { return localStorage.getItem(DISMISS_KEY) === '1'; } catch { return false; } +} + +// Shown to free users before their first download: the clip carries a +// watermark, and upgrading removes it. Dismissible for good, like OpusClip's. +export default function WatermarkModal({ onClose, onContinue }) { + const [dontShow, setDontShow] = useState(false); + + const close = (proceed) => { + if (dontShow) { + try { localStorage.setItem(DISMISS_KEY, '1'); } catch { /* ignore */ } + } + if (proceed) onContinue?.(); + onClose(); + }; + + return ( + close(false)} eyebrow="FREE PLAN" title="Upgrade to remove the watermark" size="md"> +

+ Clips on the free plan carry the OpenShorts mark in the corner, and are + kept for 7 days. Any paid plan exports them clean and keeps them for good. +

+ +
+
+ +
+ +
+ + +
+
+
+ ); +} diff --git a/main.py b/main.py index 8464138..d66c18f 100644 --- a/main.py +++ b/main.py @@ -687,6 +687,14 @@ def render_clip(input_video, final_output_video, output_format="auto"): return process_video_to_vertical(input_video, final_output_video, aspect_ratio=aspect) +# Watermark geometry, as fractions of the clip width/height. Top-left (not +# bottom) on purpose: the bottom strip is what gets cropped away when a clip is +# re-posted, so a bottom mark is trivially removed. +WATERMARK_WIDTH_RATIO = 0.30 +WATERMARK_MARGIN_RATIO = 0.05 +WATERMARK_OPACITY = 0.85 + + def apply_watermark(video_path): """Burn the OpenShorts watermark into a finished clip (free plan). @@ -694,16 +702,36 @@ def apply_watermark(video_path): GENERAL, horizontal passthrough) gets the mark, and later subtitle/hook re-encodes keep it — they re-encode the already-marked pixels. """ - font_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - "fonts", "NotoSerif-Bold.ttf") - font_arg = f"fontfile={font_path}:" if os.path.exists(font_path) else "" - draw = ( - f"drawtext={font_arg}text=openshorts.app:" - "fontcolor=white@0.6:borderw=2:bordercolor=black@0.4:" - "fontsize=h/30:x=(w-text_w)/2:y=h-(h/12)" + logo_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), + "assets", "watermark.png") + if not os.path.exists(logo_path): + print(f" ⚠️ Watermark asset missing ({logo_path}); clip kept unmarked.") + return False + + # Scale the lockup from the clip's real width: overlay can't read the other + # input's size, and computing it here avoids the deprecated scale2ref. + try: + probe = subprocess.check_output( + ["ffprobe", "-v", "error", "-select_streams", "v:0", + "-show_entries", "stream=width,height", "-of", "csv=p=0:s=x", video_path], + stderr=subprocess.STDOUT, timeout=60, + ).decode().strip().split("x") + vw, vh = int(probe[0]), int(probe[1]) + except Exception as e: + print(f" ⚠️ Could not probe clip for watermark ({e}); clip kept unmarked.") + return False + + wm_w = max(80, int(vw * WATERMARK_WIDTH_RATIO)) + # Same pixel inset on both axes so the corner gap reads as square. + x = y = int(vw * WATERMARK_MARGIN_RATIO) + filt = ( + f"[1:v]scale={wm_w}:-1,format=rgba," + f"colorchannelmixer=aa={WATERMARK_OPACITY}[wm];" + f"[0:v][wm]overlay=x={x}:y={y}" ) tmp_path = video_path + ".wm.mp4" - cmd = ["ffmpeg", "-y", "-i", video_path, "-vf", draw, + cmd = ["ffmpeg", "-y", "-i", video_path, "-i", logo_path, + "-filter_complex", filt, *video_encode_args(QUALITY), "-c:a", "copy", "-movflags", "+faststart", tmp_path] result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,