feat(free): watermark lockup arriba-izquierda + modal de upgrade + star-ask durante el render
- La marca pasa de texto abajo-centrado a un lockup blanco (símbolo + OpenShorts) superpuesto arriba a la izquierda: el borde inferior es lo que se recorta al repostear, así que ahí la marca se quitaba gratis. PNG pre-renderizado en assets/ para no depender de fuentes del contenedor. - WatermarkModal: aviso único al descargar en plan free (descargar igual / upgrade / no volver a mostrar), al estilo del de OpusClip. - StarBanner también durante la generación, que es donde el usuario tiene minutos muertos esperando.
This commit is contained in:
parent
f68bf12fee
commit
70260108cc
6 changed files with 192 additions and 25 deletions
46
assets/make_watermark.py
Normal file
46
assets/make_watermark.py
Normal file
|
|
@ -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)
|
||||||
BIN
assets/watermark.png
Normal file
BIN
assets/watermark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
|
|
@ -1286,6 +1286,13 @@ function App() {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* The wait is dead time — the best moment to ask for a star. */}
|
||||||
|
{status === 'processing' && (
|
||||||
|
<div className="my-3">
|
||||||
|
<StarBanner message="Free while it renders?" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Logs Terminal */}
|
{/* Logs Terminal */}
|
||||||
<div className={`bg-paper rounded-card border border-rule overflow-hidden flex flex-col transition-all duration-500 ${status === 'complete' ? 'h-32 min-h-0 opacity-50 hover:opacity-100' : 'flex-1 min-h-[200px]'}`}>
|
<div className={`bg-paper rounded-card border border-rule overflow-hidden flex flex-col transition-all duration-500 ${status === 'complete' ? 'h-32 min-h-0 opacity-50 hover:opacity-100' : 'flex-1 min-h-[200px]'}`}>
|
||||||
<div className="px-4 py-2 border-b border-rule flex items-center justify-between bg-paper2 shrink-0">
|
<div className="px-4 py-2 border-b border-rule flex items-center justify-between bg-paper2 shrink-0">
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import HookModal from './HookModal';
|
||||||
import TranslateModal from './TranslateModal';
|
import TranslateModal from './TranslateModal';
|
||||||
import Modal from './ui/Modal';
|
import Modal from './ui/Modal';
|
||||||
import SegmentedControl from './ui/SegmentedControl';
|
import SegmentedControl from './ui/SegmentedControl';
|
||||||
|
import WatermarkModal, { watermarkNoticeDismissed } from './WatermarkModal';
|
||||||
|
import { useAuth } from '../contexts/AuthContext';
|
||||||
import { renderInBrowser } from '../lib/renderInBrowser';
|
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';
|
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 [showModal, setShowModal] = useState(false);
|
||||||
const [showDescModal, setShowDescModal] = useState(false);
|
const [showDescModal, setShowDescModal] = useState(false);
|
||||||
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
||||||
|
const [showWatermarkModal, setShowWatermarkModal] = useState(false);
|
||||||
|
const { plan } = useAuth();
|
||||||
const videoRef = React.useRef(null);
|
const videoRef = React.useRef(null);
|
||||||
// Pristine base clip (no burned subtitles/hook), stable regardless of how
|
// Pristine base clip (no burned subtitles/hook), stable regardless of how
|
||||||
// clip.video_url mutates after server edits. Used as the compositing base
|
// 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 originalVideoUrl = getApiUrl((clip.video_url || '').replace(/[^/]+$/, stripBurns((clip.video_url || '').split('/').pop())));
|
||||||
const [currentVideoUrl, setCurrentVideoUrl] = useState(getApiUrl(clip.video_url));
|
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).
|
// Latest file that exists ON THE SERVER (blob: previews don't count).
|
||||||
// All server-side operations must chain from this, so burned-in edits
|
// All server-side operations must chain from this, so burned-in edits
|
||||||
// (subtitles, hooks, effects) never get silently dropped.
|
// (subtitles, hooks, effects) never get silently dropped.
|
||||||
|
|
@ -685,25 +709,15 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
<Share2 size={16} className="shrink-0" /> post
|
<Share2 size={16} className="shrink-0" /> post
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={async (e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
try {
|
// Free clips are watermarked — surface the upsell once
|
||||||
const response = await fetch(currentVideoUrl);
|
// before the first download, then get out of the way.
|
||||||
if (!response.ok) throw new Error('Download failed');
|
if (plan === 'free' && !watermarkNoticeDismissed()) {
|
||||||
const blob = await response.blob();
|
setShowWatermarkModal(true);
|
||||||
const url = window.URL.createObjectURL(blob);
|
return;
|
||||||
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');
|
|
||||||
}
|
}
|
||||||
|
downloadClip();
|
||||||
}}
|
}}
|
||||||
className={QUIET_BTN}
|
className={QUIET_BTN}
|
||||||
>
|
>
|
||||||
|
|
@ -905,6 +919,13 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
hasApiKey={!!elevenLabsKey}
|
hasApiKey={!!elevenLabsKey}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{showWatermarkModal && (
|
||||||
|
<WatermarkModal
|
||||||
|
onClose={() => setShowWatermarkModal(false)}
|
||||||
|
onContinue={downloadClip}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
65
dashboard/src/components/WatermarkModal.jsx
Normal file
65
dashboard/src/components/WatermarkModal.jsx
Normal file
|
|
@ -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 (
|
||||||
|
<Modal isOpen onClose={() => close(false)} eyebrow="FREE PLAN" title="Upgrade to remove the watermark" size="md">
|
||||||
|
<p className="text-muted text-sm mb-4">
|
||||||
|
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.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div className="rounded-card border border-rule overflow-hidden bg-paper mb-5">
|
||||||
|
<video
|
||||||
|
src="/demo/clip-vertical.mp4"
|
||||||
|
autoPlay
|
||||||
|
muted
|
||||||
|
loop
|
||||||
|
playsInline
|
||||||
|
className="w-full max-h-56 object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between gap-4 flex-wrap">
|
||||||
|
<label className="flex items-center gap-2 text-sm text-muted cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={dontShow}
|
||||||
|
onChange={(e) => setDontShow(e.target.checked)}
|
||||||
|
className="accent-brass"
|
||||||
|
/>
|
||||||
|
Don't show this again
|
||||||
|
</label>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button onClick={() => close(true)} className="btn-ghost px-4 py-2 text-sm">
|
||||||
|
Download anyway
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => { close(false); window.location.hash = '#/pricing'; }}
|
||||||
|
className="btn-primary px-4 py-2 text-sm"
|
||||||
|
>
|
||||||
|
Upgrade
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
44
main.py
44
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)
|
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):
|
def apply_watermark(video_path):
|
||||||
"""Burn the OpenShorts watermark into a finished clip (free plan).
|
"""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
|
GENERAL, horizontal passthrough) gets the mark, and later subtitle/hook
|
||||||
re-encodes keep it — they re-encode the already-marked pixels.
|
re-encodes keep it — they re-encode the already-marked pixels.
|
||||||
"""
|
"""
|
||||||
font_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
logo_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
"fonts", "NotoSerif-Bold.ttf")
|
"assets", "watermark.png")
|
||||||
font_arg = f"fontfile={font_path}:" if os.path.exists(font_path) else ""
|
if not os.path.exists(logo_path):
|
||||||
draw = (
|
print(f" ⚠️ Watermark asset missing ({logo_path}); clip kept unmarked.")
|
||||||
f"drawtext={font_arg}text=openshorts.app:"
|
return False
|
||||||
"fontcolor=white@0.6:borderw=2:bordercolor=black@0.4:"
|
|
||||||
"fontsize=h/30:x=(w-text_w)/2:y=h-(h/12)"
|
# 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"
|
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",
|
*video_encode_args(QUALITY), "-c:a", "copy",
|
||||||
"-movflags", "+faststart", tmp_path]
|
"-movflags", "+faststart", tmp_path]
|
||||||
result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
|
result = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue