Upload 3 files
Browse files- Dockerfile +31 -0
- requirements.txt +4 -0
- templates/index.html +624 -0
Dockerfile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
# Install system ffmpeg
|
| 4 |
+
RUN apt-get update && \
|
| 5 |
+
apt-get install -y --no-install-recommends ffmpeg && \
|
| 6 |
+
apt-get clean && \
|
| 7 |
+
rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
# Create a non-root user (HF Spaces requirement)
|
| 10 |
+
RUN useradd -m -u 1000 user
|
| 11 |
+
USER user
|
| 12 |
+
ENV HOME=/home/user \
|
| 13 |
+
PATH=/home/user/.local/bin:$PATH
|
| 14 |
+
|
| 15 |
+
WORKDIR /home/user/app
|
| 16 |
+
|
| 17 |
+
# Install Python dependencies
|
| 18 |
+
COPY --chown=user requirements.txt .
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 20 |
+
pip install --no-cache-dir -r requirements.txt
|
| 21 |
+
|
| 22 |
+
# Copy application files
|
| 23 |
+
COPY --chown=user app.py .
|
| 24 |
+
COPY --chown=user templates/ templates/
|
| 25 |
+
|
| 26 |
+
# Create working directories under /tmp (writable in HF Spaces)
|
| 27 |
+
RUN mkdir -p /tmp/uploads /tmp/processed
|
| 28 |
+
|
| 29 |
+
EXPOSE 7860
|
| 30 |
+
|
| 31 |
+
CMD ["python", "app.py"]
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
opencv-python-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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes">
|
| 6 |
+
<title>Vid Enhancer & Watermark Remover</title>
|
| 7 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 10 |
+
<style>
|
| 11 |
+
:root {
|
| 12 |
+
--bg-base: #0f172a;
|
| 13 |
+
--glass-bg: rgba(30, 41, 59, 0.6);
|
| 14 |
+
--glass-border: rgba(255, 255, 255, 0.08);
|
| 15 |
+
--text-main: #f8fafc;
|
| 16 |
+
--text-muted: #94a3b8;
|
| 17 |
+
--accent: #6366f1;
|
| 18 |
+
--accent-hover: #4f46e5;
|
| 19 |
+
--accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
|
| 20 |
+
--danger: #ef4444;
|
| 21 |
+
--success: #10b981;
|
| 22 |
+
--radius-sm: 12px;
|
| 23 |
+
--radius-md: 16px;
|
| 24 |
+
--radius-lg: 24px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
| 28 |
+
|
| 29 |
+
body {
|
| 30 |
+
font-family: 'Inter', sans-serif;
|
| 31 |
+
background-color: var(--bg-base);
|
| 32 |
+
color: var(--text-main);
|
| 33 |
+
min-height: 100vh;
|
| 34 |
+
display: flex;
|
| 35 |
+
justify-content: center;
|
| 36 |
+
align-items: flex-start;
|
| 37 |
+
padding: 20px 16px 60px 16px;
|
| 38 |
+
position: relative;
|
| 39 |
+
overflow-x: hidden;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/* Ambient glowing background */
|
| 43 |
+
body::before {
|
| 44 |
+
content: ''; position: fixed; top: -20%; left: -10%; width: 60vw; height: 60vw;
|
| 45 |
+
background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 60%);
|
| 46 |
+
filter: blur(80px); z-index: -1; pointer-events: none;
|
| 47 |
+
}
|
| 48 |
+
body::after {
|
| 49 |
+
content: ''; position: fixed; bottom: -20%; right: -10%; width: 50vw; height: 50vw;
|
| 50 |
+
background: radial-gradient(circle, rgba(168, 85, 247, 0.15) 0%, transparent 60%);
|
| 51 |
+
filter: blur(80px); z-index: -1; pointer-events: none;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.app-container {
|
| 55 |
+
width: 100%;
|
| 56 |
+
max-width: 800px;
|
| 57 |
+
display: flex;
|
| 58 |
+
flex-direction: column;
|
| 59 |
+
gap: 24px;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
header {
|
| 63 |
+
text-align: center;
|
| 64 |
+
margin-bottom: 8px;
|
| 65 |
+
margin-top: 16px;
|
| 66 |
+
animation: fadeInDown 0.6s ease-out;
|
| 67 |
+
}
|
| 68 |
+
h1 {
|
| 69 |
+
font-size: 2.2rem; margin-bottom: 8px; font-weight: 800; letter-spacing: -0.02em;
|
| 70 |
+
background: linear-gradient(to right, #ffffff, #a5b4fc);
|
| 71 |
+
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
|
| 72 |
+
}
|
| 73 |
+
p.subtitle { color: var(--text-muted); font-size: 1rem; line-height: 1.5; }
|
| 74 |
+
|
| 75 |
+
/* Stepper */
|
| 76 |
+
.stepper {
|
| 77 |
+
display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;
|
| 78 |
+
position: relative;
|
| 79 |
+
animation: fadeIn 0.8s ease-out;
|
| 80 |
+
}
|
| 81 |
+
.stepper::before {
|
| 82 |
+
content: ''; position: absolute; left: 10%; right: 10%; height: 2px;
|
| 83 |
+
background: var(--glass-border); z-index: 1; top: 50%; transform: translateY(-50%);
|
| 84 |
+
}
|
| 85 |
+
.step {
|
| 86 |
+
display: flex; flex-direction: column; align-items: center; gap: 8px;
|
| 87 |
+
position: relative; z-index: 2; width: 60px;
|
| 88 |
+
}
|
| 89 |
+
.step-circle {
|
| 90 |
+
width: 32px; height: 32px; border-radius: 50%; background: var(--bg-base); border: 2px solid var(--glass-border);
|
| 91 |
+
display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 600;
|
| 92 |
+
color: var(--text-muted); transition: all 0.3s ease;
|
| 93 |
+
}
|
| 94 |
+
.step.active .step-circle {
|
| 95 |
+
border-color: var(--accent); background: var(--accent); color: white;
|
| 96 |
+
box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
|
| 97 |
+
}
|
| 98 |
+
.step.completed .step-circle {
|
| 99 |
+
border-color: var(--success); background: var(--success); color: white;
|
| 100 |
+
}
|
| 101 |
+
.step-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.6; transition: 0.3s;}
|
| 102 |
+
.step.active .step-label { color: var(--text-main); opacity: 1; }
|
| 103 |
+
|
| 104 |
+
/* Glassmorphism Cards */
|
| 105 |
+
.card {
|
| 106 |
+
background: var(--glass-bg);
|
| 107 |
+
backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
|
| 108 |
+
border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
|
| 109 |
+
padding: 24px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
|
| 110 |
+
animation: fadeInUp 0.5s ease-out backwards;
|
| 111 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/* Section visibility */
|
| 115 |
+
#section-upload, #section-mark, #section-process, #section-download { display: none; }
|
| 116 |
+
#section-upload.active, #section-mark.active, #section-process.active, #section-download.active { display: flex; flex-direction: column; gap: 20px; }
|
| 117 |
+
|
| 118 |
+
/* Upload area */
|
| 119 |
+
.upload-area {
|
| 120 |
+
border: 2px dashed var(--glass-border); border-radius: var(--radius-md);
|
| 121 |
+
padding: 40px 20px; text-align: center; cursor: pointer; transition: 0.3s;
|
| 122 |
+
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
|
| 123 |
+
background: rgba(255, 255, 255, 0.02);
|
| 124 |
+
}
|
| 125 |
+
.upload-area:hover, .upload-area.dragover {
|
| 126 |
+
border-color: var(--accent); background: rgba(99, 102, 241, 0.05); transform: translateY(-2px);
|
| 127 |
+
}
|
| 128 |
+
.upload-area i { font-size: 3rem; margin-bottom: 8px; font-style: normal; }
|
| 129 |
+
.upload-area input { display: none; }
|
| 130 |
+
|
| 131 |
+
/* Buttons */
|
| 132 |
+
.btn {
|
| 133 |
+
appearance: none; border: none; outline: none; padding: 16px 24px;
|
| 134 |
+
border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: 600;
|
| 135 |
+
cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
| 136 |
+
display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
|
| 137 |
+
position: relative; overflow: hidden;
|
| 138 |
+
}
|
| 139 |
+
.btn:active { transform: scale(0.97); }
|
| 140 |
+
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
|
| 141 |
+
.btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(255,255,255,0.2), transparent); opacity: 0; transition: 0.2s; }
|
| 142 |
+
.btn:hover::after { opacity: 1; }
|
| 143 |
+
|
| 144 |
+
.btn-primary { background: var(--accent-gradient); color: white; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); }
|
| 145 |
+
.btn-success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4); }
|
| 146 |
+
.btn-secondary { background: rgba(255,255,255,0.1); color: var(--text-main); border: 1px solid var(--glass-border); }
|
| 147 |
+
.btn-secondary:hover { background: rgba(255,255,255,0.15); }
|
| 148 |
+
|
| 149 |
+
/* Image/Canvas Container */
|
| 150 |
+
.workspace-wrapper {
|
| 151 |
+
position: relative; width: 100%; border-radius: var(--radius-md);
|
| 152 |
+
overflow: hidden; background: #000; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
|
| 153 |
+
display: flex; justify-content: center; align-items: center; border: 1px solid var(--glass-border);
|
| 154 |
+
touch-action: pinch-zoom; /* allowing native zoom, prevent inline scroll */
|
| 155 |
+
}
|
| 156 |
+
.editor-container { position: relative; max-width: 100%; display: inline-block; }
|
| 157 |
+
#video-frame { max-width: 100%; max-height: 60vh; width: auto; height: auto; display: block; object-fit: contain; pointer-events: none; user-select: none; }
|
| 158 |
+
#overlay-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: crosshair; z-index: 10; touch-action: none; }
|
| 159 |
+
|
| 160 |
+
/* Tools */
|
| 161 |
+
.tool-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px;}
|
| 162 |
+
.tool-btn {
|
| 163 |
+
padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
|
| 164 |
+
background: rgba(255,255,255,0.05); color: var(--text-muted); font-weight: 500; font-size: 0.95rem;
|
| 165 |
+
cursor: pointer; transition: 0.3s; display: flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box;
|
| 166 |
+
}
|
| 167 |
+
.tool-btn.active { background: rgba(99, 102, 241, 0.15); border-color: var(--accent); color: white; box-shadow: inset 0 0 10px rgba(99,102,241,0.2); }
|
| 168 |
+
|
| 169 |
+
.slider-container { display: none; flex-direction: column; gap: 8px; margin-bottom: 20px; transition: 0.3s; }
|
| 170 |
+
.slider-header { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--text-muted); }
|
| 171 |
+
input[type="range"] {
|
| 172 |
+
-webkit-appearance: none; width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 4px; outline: none;
|
| 173 |
+
}
|
| 174 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 175 |
+
-webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); cursor: pointer; transition: 0.2s; box-shadow: 0 0 10px rgba(99,102,241,0.5);
|
| 176 |
+
}
|
| 177 |
+
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
|
| 178 |
+
|
| 179 |
+
/* Form elements */
|
| 180 |
+
.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
|
| 181 |
+
.form-group label { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
|
| 182 |
+
select {
|
| 183 |
+
appearance: none; width: 100%; padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
|
| 184 |
+
background: rgba(15, 23, 42, 0.8) url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") no-repeat right 1rem center;
|
| 185 |
+
background-size: 1.2em; color: white; font-family: inherit; font-size: 1rem; outline: none; transition: 0.3s; cursor: pointer;
|
| 186 |
+
}
|
| 187 |
+
select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); }
|
| 188 |
+
select option { background: var(--bg-base); color: white; }
|
| 189 |
+
|
| 190 |
+
/* Status Toast */
|
| 191 |
+
.toast-container { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 100; pointer-events: none; display: flex; flex-direction: column; gap: 10px; width: 90%; max-width: 400px; }
|
| 192 |
+
.toast {
|
| 193 |
+
background: rgba(30, 41, 59, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
|
| 194 |
+
border: 1px solid var(--glass-border); padding: 16px 20px; border-radius: var(--radius-md); font-weight: 500;
|
| 195 |
+
display: flex; gap: 12px; align-items: center; box-shadow: 0 10px 25px rgba(0,0,0,0.3); pointer-events: auto;
|
| 196 |
+
animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
|
| 197 |
+
}
|
| 198 |
+
.toast.hiding { animation: fadeOut 0.4s ease forwards; }
|
| 199 |
+
.toast-icon { width: 24px; height: 24px; display: inline-flex; justify-content: center; align-items: center; font-size: 1.2rem; }
|
| 200 |
+
.toast-content { flex-grow: 1; font-size: 0.95rem; word-break: break-word;}
|
| 201 |
+
|
| 202 |
+
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
|
| 203 |
+
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 204 |
+
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
| 205 |
+
@keyframes slideUp { from { opacity: 0; transform: translateY(50px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
|
| 206 |
+
@keyframes fadeOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.9); } }
|
| 207 |
+
|
| 208 |
+
/* Mobile specific adjustments */
|
| 209 |
+
@media (max-width: 600px) {
|
| 210 |
+
body { padding: 16px 12px 80px 12px; }
|
| 211 |
+
h1 { font-size: 1.8rem; }
|
| 212 |
+
.card { padding: 20px 16px; }
|
| 213 |
+
.step-label { font-size: 0.65rem; }
|
| 214 |
+
.upload-area { padding: 30px 10px; }
|
| 215 |
+
.btn { padding: 18px 20px; font-size: 1.05rem; /* Larger for mobile thumbs */ }
|
| 216 |
+
select { padding: 18px 16px; }
|
| 217 |
+
.workspace-wrapper { border-radius: 8px; }
|
| 218 |
+
#video-frame { max-height: 50vh; }
|
| 219 |
+
}
|
| 220 |
+
</style>
|
| 221 |
+
</head>
|
| 222 |
+
<body>
|
| 223 |
+
|
| 224 |
+
<div class="app-container">
|
| 225 |
+
<header>
|
| 226 |
+
<h1>Vid Enhancer & Watermark Remover</h1>
|
| 227 |
+
<p class="subtitle">AI-powered watermark & object removal</p>
|
| 228 |
+
</header>
|
| 229 |
+
|
| 230 |
+
<div class="stepper" id="stepper">
|
| 231 |
+
<div class="step active" id="step1">
|
| 232 |
+
<div class="step-circle">1</div>
|
| 233 |
+
<span class="step-label">Upload</span>
|
| 234 |
+
</div>
|
| 235 |
+
<div class="step" id="step2">
|
| 236 |
+
<div class="step-circle">2</div>
|
| 237 |
+
<span class="step-label">Mark</span>
|
| 238 |
+
</div>
|
| 239 |
+
<div class="step" id="step3">
|
| 240 |
+
<div class="step-circle">3</div>
|
| 241 |
+
<span class="step-label">Refine</span>
|
| 242 |
+
</div>
|
| 243 |
+
<div class="step" id="step4">
|
| 244 |
+
<div class="step-circle">4</div>
|
| 245 |
+
<span class="step-label">Done</span>
|
| 246 |
+
</div>
|
| 247 |
+
</div>
|
| 248 |
+
|
| 249 |
+
<!-- Upload Section -->
|
| 250 |
+
<div class="card active" id="section-upload">
|
| 251 |
+
<label class="upload-area" id="upload-dropzone">
|
| 252 |
+
<i>📥</i>
|
| 253 |
+
<h3 style="font-weight: 600; color: white;">Tap to select video</h3>
|
| 254 |
+
<p style="color: var(--text-muted); font-size: 0.9rem;">or drag and drop here</p>
|
| 255 |
+
<input type="file" id="video-upload" accept="video/*" multiple>
|
| 256 |
+
</label>
|
| 257 |
+
<button class="btn btn-primary" id="upload-btn">Upload & Continue</button>
|
| 258 |
+
</div>
|
| 259 |
+
|
| 260 |
+
<!-- Mark Section (Workspace) -->
|
| 261 |
+
<div class="card" id="section-mark">
|
| 262 |
+
<div class="tool-bar">
|
| 263 |
+
<div class="tool-btn active" data-tool="box"><span>🟥</span> Rectangle</div>
|
| 264 |
+
<div class="tool-btn" data-tool="brush"><span>🖌️</span> FreeBrush</div>
|
| 265 |
+
</div>
|
| 266 |
+
|
| 267 |
+
<div class="slider-container" id="brush-size-container">
|
| 268 |
+
<div class="slider-header">
|
| 269 |
+
<span>Brush Size</span>
|
| 270 |
+
<span id="brush-size-val">30px</span>
|
| 271 |
+
</div>
|
| 272 |
+
<input type="range" id="brush-size" min="10" max="80" value="30">
|
| 273 |
+
</div>
|
| 274 |
+
|
| 275 |
+
<div class="workspace-wrapper" id="workspace">
|
| 276 |
+
<div class="editor-container">
|
| 277 |
+
<img id="video-frame" src="" alt="Video Frame">
|
| 278 |
+
<canvas id="overlay-canvas"></canvas>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
|
| 282 |
+
<div style="display: flex; gap: 12px; margin-top: 8px;">
|
| 283 |
+
<button class="btn btn-secondary" id="clear-btn" style="flex: 1;">↺ Undo</button>
|
| 284 |
+
<button class="btn btn-primary" id="next-to-process" style="flex: 2;">Next ➞</button>
|
| 285 |
+
</div>
|
| 286 |
+
</div>
|
| 287 |
+
|
| 288 |
+
<!-- Process Options Section -->
|
| 289 |
+
<div class="card" id="section-process">
|
| 290 |
+
<h3 style="margin-bottom: 8px; color: white;">Processing Options</h3>
|
| 291 |
+
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px;">Choose how the marked area should be handled.</p>
|
| 292 |
+
|
| 293 |
+
<div class="form-group">
|
| 294 |
+
<label>Removal Method</label>
|
| 295 |
+
<select id="method-select">
|
| 296 |
+
<option value="blur_heavy">Heavy Blur (Best for text/faces)</option>
|
| 297 |
+
<option value="blur_light">Soft Frosted Blur (Subtle blend)</option>
|
| 298 |
+
<option value="pixelate">Mosaic / Pixelate (TV look)</option>
|
| 299 |
+
<option value="delogo">AI Interpolation (Best for see-through logos)</option>
|
| 300 |
+
<option value="black_box">Solid Black Box (Total redaction)</option>
|
| 301 |
+
</select>
|
| 302 |
+
</div>
|
| 303 |
+
|
| 304 |
+
<div class="form-group">
|
| 305 |
+
<label>Upscaling (Optional)</label>
|
| 306 |
+
<select id="upscale-select">
|
| 307 |
+
<option value="none">📐 No Upscale (Original Quality)</option>
|
| 308 |
+
<option value="1.5x">🔺 1.5× Upscale (Sharper)</option>
|
| 309 |
+
<option value="2x">🔺 2× Upscale (Double Resolution)</option>
|
| 310 |
+
<option value="4k">🎬 4K Upscale (3840×2160)</option>
|
| 311 |
+
</select>
|
| 312 |
+
</div>
|
| 313 |
+
|
| 314 |
+
<div style="display: flex; gap: 12px; margin-top: 12px;">
|
| 315 |
+
<button class="btn btn-secondary" id="back-to-mark" style="flex: 1;">⬅ Back</button>
|
| 316 |
+
<button class="btn btn-primary" id="process-btn" style="flex: 2;">⚡ Start Processing</button>
|
| 317 |
+
</div>
|
| 318 |
+
</div>
|
| 319 |
+
|
| 320 |
+
<!-- Download Section -->
|
| 321 |
+
<div class="card" id="section-download">
|
| 322 |
+
<div style="text-align: center; padding: 20px 0;">
|
| 323 |
+
<div style="font-size: 4rem; margin-bottom: 16px; animation: fadeInUp 0.5s ease 0.2s both;">🎉</div>
|
| 324 |
+
<h2 style="color: white; margin-bottom: 8px;">Processing Complete</h2>
|
| 325 |
+
<p style="color: var(--text-muted); margin-bottom: 24px;">Your video is ready for download.</p>
|
| 326 |
+
<a id="download-link" style="display: block; text-decoration: none;">
|
| 327 |
+
<button class="btn btn-success" style="font-size: 1.1rem; padding: 20px;">⬇ Download Clean Video</button>
|
| 328 |
+
</a>
|
| 329 |
+
<button class="btn btn-secondary" id="start-over-btn" style="margin-top: 16px;">Start Over with New Video</button>
|
| 330 |
+
</div>
|
| 331 |
+
</div>
|
| 332 |
+
|
| 333 |
+
</div>
|
| 334 |
+
|
| 335 |
+
<div class="toast-container" id="toast-container"></div>
|
| 336 |
+
|
| 337 |
+
<script>
|
| 338 |
+
// Elements
|
| 339 |
+
const fileInput = document.getElementById('video-upload');
|
| 340 |
+
const uploadArea = document.getElementById('upload-dropzone');
|
| 341 |
+
const uploadBtn = document.getElementById('upload-btn');
|
| 342 |
+
const sections = {
|
| 343 |
+
upload: document.getElementById('section-upload'),
|
| 344 |
+
mark: document.getElementById('section-mark'),
|
| 345 |
+
process: document.getElementById('section-process'),
|
| 346 |
+
download: document.getElementById('section-download')
|
| 347 |
+
};
|
| 348 |
+
const steps = [
|
| 349 |
+
document.getElementById('step1'), document.getElementById('step2'),
|
| 350 |
+
document.getElementById('step3'), document.getElementById('step4')
|
| 351 |
+
];
|
| 352 |
+
|
| 353 |
+
const img = document.getElementById('video-frame');
|
| 354 |
+
const canvas = document.getElementById('overlay-canvas');
|
| 355 |
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
| 356 |
+
|
| 357 |
+
const toolBtns = document.querySelectorAll('.tool-btn');
|
| 358 |
+
const brushSizeContainer = document.getElementById('brush-size-container');
|
| 359 |
+
const brushSize = document.getElementById('brush-size');
|
| 360 |
+
const brushSizeVal = document.getElementById('brush-size-val');
|
| 361 |
+
const clearBtn = document.getElementById('clear-btn');
|
| 362 |
+
const nextToProcessBtn = document.getElementById('next-to-process');
|
| 363 |
+
const backToMarkBtn = document.getElementById('back-to-mark');
|
| 364 |
+
const processBtn = document.getElementById('process-btn');
|
| 365 |
+
const downloadLink = document.getElementById('download-link');
|
| 366 |
+
const startOverBtn = document.getElementById('start-over-btn');
|
| 367 |
+
|
| 368 |
+
// State
|
| 369 |
+
let currentFilenames = [];
|
| 370 |
+
let origVideoW = 0, origVideoH = 0;
|
| 371 |
+
let isDrawing = false;
|
| 372 |
+
let startX = 0, startY = 0, rectW = 0, rectH = 0;
|
| 373 |
+
let currentTool = 'box';
|
| 374 |
+
let hasPainted = false;
|
| 375 |
+
let currentStepIndex = 0;
|
| 376 |
+
|
| 377 |
+
// --- Toast System ---
|
| 378 |
+
function showToast(msg, type = 'info') {
|
| 379 |
+
const container = document.getElementById('toast-container');
|
| 380 |
+
const toast = document.createElement('div');
|
| 381 |
+
toast.className = 'toast';
|
| 382 |
+
|
| 383 |
+
let icon = 'ℹ️';
|
| 384 |
+
if (type === 'success') icon = '✅';
|
| 385 |
+
if (type === 'error') icon = '❌';
|
| 386 |
+
if (type === 'loading') icon = '⏳';
|
| 387 |
+
|
| 388 |
+
toast.innerHTML = `<span class="toast-icon">${icon}</span><span class="toast-content">${msg}</span>`;
|
| 389 |
+
container.appendChild(toast);
|
| 390 |
+
|
| 391 |
+
// Haptic feedback if available
|
| 392 |
+
if (navigator.vibrate) {
|
| 393 |
+
if (type === 'error') navigator.vibrate([100, 50, 100]);
|
| 394 |
+
else if (type === 'success') navigator.vibrate(100);
|
| 395 |
+
else navigator.vibrate(50);
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
setTimeout(() => {
|
| 399 |
+
toast.classList.add('hiding');
|
| 400 |
+
toast.addEventListener('animationend', () => toast.remove());
|
| 401 |
+
}, 4000);
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
// --- Navigation System ---
|
| 405 |
+
function goToStep(stepKey, index) {
|
| 406 |
+
Object.values(sections).forEach(sec => sec.classList.remove('active'));
|
| 407 |
+
sections[stepKey].classList.add('active');
|
| 408 |
+
|
| 409 |
+
steps.forEach((st, i) => {
|
| 410 |
+
if (i < index) { st.classList.add('completed'); st.classList.remove('active'); }
|
| 411 |
+
else if (i === index) { st.classList.add('active'); st.classList.remove('completed'); }
|
| 412 |
+
else { st.classList.remove('active', 'completed'); }
|
| 413 |
+
});
|
| 414 |
+
currentStepIndex = index;
|
| 415 |
+
|
| 416 |
+
// Resize canvas if we enter mark step
|
| 417 |
+
if (stepKey === 'mark') setTimeout(resizeCanvas, 100);
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
startOverBtn.addEventListener('click', () => {
|
| 421 |
+
currentFilenames = []; fileInput.value = '';
|
| 422 |
+
clearCanvas(); goToStep('upload', 0);
|
| 423 |
+
});
|
| 424 |
+
|
| 425 |
+
nextToProcessBtn.addEventListener('click', () => {
|
| 426 |
+
const isBoxEmpty = (currentTool === 'box' && rectW === 0 && rectH === 0);
|
| 427 |
+
const isBrushEmpty = (currentTool === 'brush' && !hasPainted);
|
| 428 |
+
|
| 429 |
+
if (isBoxEmpty || isBrushEmpty) {
|
| 430 |
+
showToast('Please mark an area on the video first.', 'error');
|
| 431 |
+
return;
|
| 432 |
+
}
|
| 433 |
+
goToStep('process', 2);
|
| 434 |
+
});
|
| 435 |
+
backToMarkBtn.addEventListener('click', () => goToStep('mark', 1));
|
| 436 |
+
|
| 437 |
+
// --- Upload Logic ---
|
| 438 |
+
uploadArea.addEventListener('dragover', (e) => { e.preventDefault(); uploadArea.classList.add('dragover'); });
|
| 439 |
+
uploadArea.addEventListener('dragleave', () => uploadArea.classList.remove('dragover'));
|
| 440 |
+
uploadArea.addEventListener('drop', (e) => {
|
| 441 |
+
e.preventDefault(); uploadArea.classList.remove('dragover');
|
| 442 |
+
if (e.dataTransfer.files.length) { fileInput.files = e.dataTransfer.files; handleFiles(); }
|
| 443 |
+
});
|
| 444 |
+
fileInput.addEventListener('change', handleFiles);
|
| 445 |
+
|
| 446 |
+
function handleFiles() {
|
| 447 |
+
if (fileInput.files.length) {
|
| 448 |
+
uploadArea.querySelector('h3').innerText = `${fileInput.files.length} file(s) selected`;
|
| 449 |
+
uploadArea.style.borderColor = 'var(--success)';
|
| 450 |
+
uploadArea.style.background = 'rgba(16, 185, 129, 0.05)';
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
uploadBtn.addEventListener('click', async () => {
|
| 455 |
+
if (!fileInput.files.length) return showToast('Please select a video file first.', 'error');
|
| 456 |
+
|
| 457 |
+
const formData = new FormData();
|
| 458 |
+
for (let i = 0; i < fileInput.files.length; i++) formData.append('videos', fileInput.files[i]);
|
| 459 |
+
|
| 460 |
+
showToast('Uploading and analyzing...', 'loading');
|
| 461 |
+
uploadBtn.disabled = true; uploadBtn.innerText = 'Uploading...';
|
| 462 |
+
|
| 463 |
+
try {
|
| 464 |
+
const response = await fetch('/upload', { method: 'POST', body: formData });
|
| 465 |
+
const data = await response.json();
|
| 466 |
+
|
| 467 |
+
if (data.filenames) {
|
| 468 |
+
currentFilenames = data.filenames;
|
| 469 |
+
origVideoW = data.orig_w; origVideoH = data.orig_h;
|
| 470 |
+
|
| 471 |
+
img.onload = () => { goToStep('mark', 1); showToast('Video loaded! Draw over the watermark.', 'success'); };
|
| 472 |
+
img.src = data.frame_url;
|
| 473 |
+
} else {
|
| 474 |
+
throw new Error(data.error || 'Upload failed');
|
| 475 |
+
}
|
| 476 |
+
} catch (err) {
|
| 477 |
+
showToast(`Error: ${err.message}`, 'error');
|
| 478 |
+
} finally {
|
| 479 |
+
uploadBtn.disabled = false; uploadBtn.innerText = 'Upload & Continue';
|
| 480 |
+
}
|
| 481 |
+
});
|
| 482 |
+
|
| 483 |
+
// --- Workspace / Canvas Logic ---
|
| 484 |
+
function resizeCanvas() {
|
| 485 |
+
if (!img.clientWidth) return;
|
| 486 |
+
canvas.width = img.clientWidth; canvas.height = img.clientHeight;
|
| 487 |
+
clearCanvas();
|
| 488 |
+
}
|
| 489 |
+
window.addEventListener('resize', () => { if (currentStepIndex === 1) resizeCanvas(); });
|
| 490 |
+
|
| 491 |
+
// Tool toggle
|
| 492 |
+
toolBtns.forEach(btn => {
|
| 493 |
+
btn.addEventListener('click', () => {
|
| 494 |
+
toolBtns.forEach(b => b.classList.remove('active'));
|
| 495 |
+
btn.classList.add('active');
|
| 496 |
+
currentTool = btn.dataset.tool;
|
| 497 |
+
brushSizeContainer.style.display = currentTool === 'brush' ? 'flex' : 'none';
|
| 498 |
+
if(navigator.vibrate) navigator.vibrate(40);
|
| 499 |
+
|
| 500 |
+
// Re-apply box dimensions if returning to box
|
| 501 |
+
if (currentTool === 'box') {
|
| 502 |
+
handleBoxRedraw();
|
| 503 |
+
}
|
| 504 |
+
});
|
| 505 |
+
});
|
| 506 |
+
|
| 507 |
+
brushSize.addEventListener('input', (e) => { brushSizeVal.innerText = `${e.target.value}px`; });
|
| 508 |
+
clearBtn.addEventListener('click', clearCanvas);
|
| 509 |
+
|
| 510 |
+
function clearCanvas() { ctx.clearRect(0, 0, canvas.width, canvas.height); rectW = rectH = 0; hasPainted = false; }
|
| 511 |
+
|
| 512 |
+
function handleBoxRedraw() {
|
| 513 |
+
if (rectW !== 0 || rectH !== 0) {
|
| 514 |
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 515 |
+
ctx.fillStyle = 'rgba(99, 102, 241, 0.2)';
|
| 516 |
+
ctx.fillRect(startX, startY, rectW, rectH);
|
| 517 |
+
ctx.strokeStyle = '#6366f1'; ctx.lineWidth = 2;
|
| 518 |
+
ctx.strokeRect(startX, startY, rectW, rectH);
|
| 519 |
+
}
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
function getPos(e) {
|
| 523 |
+
const rect = canvas.getBoundingClientRect();
|
| 524 |
+
const clientX = e.clientX !== undefined ? e.clientX : (e.touches && e.touches.length > 0 ? e.touches[0].clientX : 0);
|
| 525 |
+
const clientY = e.clientY !== undefined ? e.clientY : (e.touches && e.touches.length > 0 ? e.touches[0].clientY : 0);
|
| 526 |
+
return { x: clientX - rect.left, y: clientY - rect.top };
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
function handleStart(e) {
|
| 530 |
+
if (e.type === 'touchstart' && e.touches.length > 1) return; // Allow pinch object
|
| 531 |
+
|
| 532 |
+
// Only prevent scroll inside canvas interaction (e.touches > 1 does not hit here)
|
| 533 |
+
if (e.cancelable) e.preventDefault();
|
| 534 |
+
|
| 535 |
+
isDrawing = true;
|
| 536 |
+
const pos = getPos(e);
|
| 537 |
+
|
| 538 |
+
if (currentTool === 'box') {
|
| 539 |
+
startX = pos.x; startY = pos.y;
|
| 540 |
+
rectW = 0; rectH = 0; // reset for new box
|
| 541 |
+
} else if (currentTool === 'brush') {
|
| 542 |
+
startX = pos.x; startY = pos.y;
|
| 543 |
+
ctx.beginPath();
|
| 544 |
+
ctx.moveTo(startX, startY);
|
| 545 |
+
ctx.lineCap = 'round'; ctx.lineJoin = 'round';
|
| 546 |
+
ctx.lineWidth = brushSize.value;
|
| 547 |
+
ctx.strokeStyle = 'rgba(99, 102, 241, 0.7)';
|
| 548 |
+
}
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
+
function handleMove(e) {
|
| 552 |
+
if (!isDrawing) return;
|
| 553 |
+
if (e.cancelable) e.preventDefault();
|
| 554 |
+
|
| 555 |
+
const { x: currentX, y: currentY } = getPos(e);
|
| 556 |
+
|
| 557 |
+
if (currentTool === 'box') {
|
| 558 |
+
rectW = currentX - startX; rectH = currentY - startY;
|
| 559 |
+
handleBoxRedraw();
|
| 560 |
+
} else if (currentTool === 'brush') {
|
| 561 |
+
ctx.lineTo(currentX, currentY);
|
| 562 |
+
ctx.stroke();
|
| 563 |
+
hasPainted = true;
|
| 564 |
+
}
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
function handleEnd() { isDrawing = false; }
|
| 568 |
+
|
| 569 |
+
canvas.addEventListener('mousedown', handleStart);
|
| 570 |
+
canvas.addEventListener('mousemove', handleMove);
|
| 571 |
+
window.addEventListener('mouseup', handleEnd);
|
| 572 |
+
|
| 573 |
+
canvas.addEventListener('touchstart', handleStart, {passive: false});
|
| 574 |
+
canvas.addEventListener('touchmove', handleMove, {passive: false});
|
| 575 |
+
window.addEventListener('touchend', handleEnd);
|
| 576 |
+
|
| 577 |
+
// --- Processing Logic ---
|
| 578 |
+
processBtn.addEventListener('click', async () => {
|
| 579 |
+
let x = startX, y = startY, rW = rectW, rH = rectH;
|
| 580 |
+
|
| 581 |
+
// Normalize box coordinates handles drag-up-left
|
| 582 |
+
if (rW < 0) { x = startX + rW; rW = Math.abs(rW); }
|
| 583 |
+
if (rH < 0) { y = startY + rH; rH = Math.abs(rH); }
|
| 584 |
+
|
| 585 |
+
const payload = {
|
| 586 |
+
filenames: currentFilenames,
|
| 587 |
+
method: document.getElementById('method-select').value,
|
| 588 |
+
tool: currentTool,
|
| 589 |
+
upscale: document.getElementById('upscale-select').value,
|
| 590 |
+
orig_w: origVideoW, orig_h: origVideoH,
|
| 591 |
+
px: x / canvas.width, py: y / canvas.height,
|
| 592 |
+
pw: Math.abs(rW) / canvas.width, ph: Math.abs(rH) / canvas.height,
|
| 593 |
+
mask_b64: currentTool === 'brush' ? canvas.toDataURL('image/png') : ''
|
| 594 |
+
};
|
| 595 |
+
|
| 596 |
+
showToast('Rendering video... this won\'t take long! 🚀', 'loading');
|
| 597 |
+
processBtn.disabled = true; processBtn.innerHTML = '⚡ Processing...';
|
| 598 |
+
|
| 599 |
+
try {
|
| 600 |
+
const response = await fetch('/process', {
|
| 601 |
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
| 602 |
+
body: JSON.stringify(payload)
|
| 603 |
+
});
|
| 604 |
+
const data = await response.json();
|
| 605 |
+
|
| 606 |
+
if (data.download_url) {
|
| 607 |
+
const name = data.download_name || '';
|
| 608 |
+
downloadLink.href = data.download_url + (name ? '?name=' + encodeURIComponent(name) : '');
|
| 609 |
+
goToStep('download', 3);
|
| 610 |
+
showToast('Success! Video is ready.', 'success');
|
| 611 |
+
if(navigator.vibrate) navigator.vibrate([100,50,100,50,200]);
|
| 612 |
+
} else {
|
| 613 |
+
throw new Error(data.error || 'Unknown error');
|
| 614 |
+
}
|
| 615 |
+
} catch (err) {
|
| 616 |
+
showToast(`Processing failed: ${err.message}`, 'error');
|
| 617 |
+
} finally {
|
| 618 |
+
processBtn.disabled = false; processBtn.innerHTML = '⚡ Start Processing';
|
| 619 |
+
}
|
| 620 |
+
});
|
| 621 |
+
|
| 622 |
+
</script>
|
| 623 |
+
</body>
|
| 624 |
+
</html>
|