Skip to content

AutoShorts is a local-first desktop application for turning long-form video or audio recordings into high-impact, vertical short-form clip candidates (9:16 portrait) with AI-powered viral moment ranking.

Rust

feat: implement configurable caption rendering with fallback logic and database support for caption styles

JayWebtechdb816b6466c4
diff --git a/README.md b/README.md
index 352d175..a817229 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,11 @@ To run or build the application from source:
```bash
brew install ffmpeg
```
+ *Note: To ensure full captions rendering support (specifically the `drawtext` and `subtitles` filter dependencies), it is recommended to use a complete, full-featured FFmpeg build. If you encounter any filter issues, tap and install the `homebrew-ffmpeg` formula:*
+ ```bash
+ brew tap homebrew-ffmpeg/ffmpeg
+ brew install homebrew-ffmpeg/ffmpeg/ffmpeg
+ ```
---
diff --git a/src-tauri/src/db.rs b/src-tauri/src/db.rs
index a7be564..c487928 100644
--- a/src-tauri/src/db.rs
+++ b/src-tauri/src/db.rs
@@ -98,6 +98,7 @@ impl Database {
",
)?;
let _ = conn.execute("ALTER TABLE projects ADD COLUMN name TEXT", []);
+ let _ = conn.execute("ALTER TABLE projects ADD COLUMN caption_style TEXT", []);
Ok(())
}
@@ -105,6 +106,7 @@ impl Database {
&self,
source_path: &str,
transcription_mode: &str,
+ caption_style: &str,
source_duration: Option<f64>,
) -> Result<Project> {
let now = Utc::now().to_rfc3339();
@@ -115,14 +117,15 @@ impl Database {
source_duration,
status: "ingest".to_string(),
transcription_mode: transcription_mode.to_string(),
+ caption_style: Some(caption_style.to_string()),
created_at: now.clone(),
updated_at: now,
};
let conn = self.conn.lock().expect("database mutex poisoned");
conn.execute(
- "INSERT INTO projects (id, name, source_path, source_duration, status, transcription_mode, created_at, updated_at)
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)",
+ "INSERT INTO projects (id, name, source_path, source_duration, status, transcription_mode, caption_style, created_at, updated_at)
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
params![
project.id,
project.name,
@@ -130,6 +133,7 @@ impl Database {
project.source_duration,
project.status,
project.transcription_mode,
+ project.caption_style,
project.created_at,
project.updated_at
],
@@ -141,7 +145,7 @@ impl Database {
pub fn list_projects(&self) -> Result<Vec<Project>> {
let conn = self.conn.lock().expect("database mutex poisoned");
let mut stmt = conn.prepare(
- "SELECT id, name, source_path, source_duration, status, transcription_mode, created_at, updated_at
+ "SELECT id, name, source_path, source_duration, status, transcription_mode, created_at, updated_at, caption_style
FROM projects ORDER BY updated_at DESC",
)?;
@@ -153,7 +157,7 @@ impl Database {
pub fn get_project(&self, project_id: &str) -> Result<Project> {
let conn = self.conn.lock().expect("database mutex poisoned");
conn.query_row(
- "SELECT id, name, source_path, source_duration, status, transcription_mode, created_at, updated_at
+ "SELECT id, name, source_path, source_duration, status, transcription_mode, created_at, updated_at, caption_style
FROM projects WHERE id = ?1",
params![project_id],
project_from_row,
@@ -321,7 +325,7 @@ impl Database {
candidates.id, candidates.project_id, candidates.start_sec, candidates.end_sec,
candidates.score, candidates.hook, candidates.rationale, candidates.rank, candidates.selected,
projects.id, projects.name, projects.source_path, projects.source_duration, projects.status,
- projects.transcription_mode, projects.created_at, projects.updated_at
+ projects.transcription_mode, projects.created_at, projects.updated_at, projects.caption_style
FROM candidates
INNER JOIN projects ON projects.id = candidates.project_id
WHERE candidates.id = ?1",
@@ -348,6 +352,7 @@ impl Database {
transcription_mode: row.get(14)?,
created_at: row.get(15)?,
updated_at: row.get(16)?,
+ caption_style: row.get(17)?,
};
Ok((candidate, project))
},
@@ -360,14 +365,18 @@ impl Database {
candidate_id: &str,
status: &str,
output_path: Option<&str>,
+ caption_ass_path: Option<&str>,
render_log: Option<&str>,
) -> Result<()> {
let conn = self.conn.lock().expect("database mutex poisoned");
conn.execute(
"UPDATE clips
- SET status = ?1, output_path = COALESCE(?2, output_path), render_log = COALESCE(?3, render_log)
- WHERE candidate_id = ?4",
- params![status, output_path, render_log, candidate_id],
+ SET status = ?1,
+ output_path = COALESCE(?2, output_path),
+ caption_ass_path = COALESCE(?3, caption_ass_path),
+ render_log = COALESCE(?4, render_log)
+ WHERE candidate_id = ?5",
+ params![status, output_path, caption_ass_path, render_log, candidate_id],
)?;
Ok(())
}
@@ -460,6 +469,7 @@ fn project_from_row(row: &rusqlite::Row<'_>) -> rusqlite::Result<Project> {
transcription_mode: row.get(5)?,
created_at: row.get(6)?,
updated_at: row.get(7)?,
+ caption_style: row.get(8)?,
})
}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 58dc7e8..89ab860 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -42,6 +42,7 @@ fn create_project_from_path(
state: tauri::State<'_, AppState>,
path: String,
transcription_mode: String,
+ caption_style: String,
) -> Result<Project, String> {
validate_media_extension(&path).map_err(to_command_error)?;
let probe = media::probe_media(&path).ok();
@@ -51,6 +52,7 @@ fn create_project_from_path(
.create_project(
&path,
&transcription_mode,
+ &caption_style,
probe.and_then(|probe| probe.duration_sec),
)
.map_err(to_command_error)
@@ -244,34 +246,107 @@ fn render_flat_clip_for_candidate(
.map_err(to_command_error)?;
state
.db
- .update_clip_for_candidate(&candidate_id, "cutting", None, None)
+ .update_clip_for_candidate(&candidate_id, "cutting", None, None, None)
.map_err(to_command_error)?;
let output_path = documents_project_dir(&project)?
.join("clips")
.join(format!("clip-{:02}_flat.mp4", candidate.rank));
+ let mut srt_path = None;
+ let mut drawtext_filters = None;
+
+ let probe = media::probe_media(&project.source_path).ok();
+ let cropped_width = if let Some(p) = &probe {
+ let iw = p.width.unwrap_or(1920) as f64;
+ let ih = p.height.unwrap_or(1080) as f64;
+ let w = (iw.min(ih * 9.0 / 16.0) / 2.0).floor() * 2.0;
+ w as i64
+ } else {
+ 1080
+ };
+
+ if let Ok(Some(transcript_record)) = state.db.latest_transcript(&project.id) {
+ if let Ok(normalized) = serde_json::from_str::<NormalizedTranscript>(&transcript_record.raw_json) {
+ let srt_content = generate_srt(&normalized.words, candidate.start_sec, candidate.end_sec);
+ let clip_srt_path = project_dir(&state, &project.id).join(format!("clip-{}.srt", candidate.id));
+ if std::fs::write(&clip_srt_path, srt_content).is_ok() {
+ srt_path = Some(clip_srt_path);
+ }
+ let style = project.caption_style.as_deref().unwrap_or("modern-box");
+ let drawtext = build_drawtext_filters(
+ &normalized.words,
+ candidate.start_sec,
+ candidate.end_sec,
+ cropped_width,
+ style,
+ );
+ if !drawtext.is_empty() {
+ drawtext_filters = Some(drawtext);
+ }
+ }
+ }
+
match media::render_flat_clip(
&project.source_path,
candidate.start_sec,
candidate.end_sec,
&output_path,
+ drawtext_filters.as_deref(),
) {
Ok(path) => {
let path_string = path.to_string_lossy().to_string();
+ let srt_string = srt_path.map(|p| p.to_string_lossy().to_string());
state
.db
- .update_clip_for_candidate(&candidate_id, "done", Some(&path_string), None)
+ .update_clip_for_candidate(
+ &candidate_id,
+ "done",
+ Some(&path_string),
+ srt_string.as_deref(),
+ None,
+ )
.map_err(to_command_error)?;
Ok(path_string)
}
Err(error) => {
- let message = error.to_string();
- state
- .db
- .update_clip_for_candidate(&candidate_id, "error", None, Some(&message))
- .map_err(to_command_error)?;
- Err(message)
+ let err_msg = error.to_string();
+ // Fallback retry rendering without captions overlay on any error
+ match media::render_flat_clip(
+ &project.source_path,
+ candidate.start_sec,
+ candidate.end_sec,
+ &output_path,
+ None,
+ ) {
+ Ok(path) => {
+ let path_string = path.to_string_lossy().to_string();
+ let srt_string = srt_path.map(|p| p.to_string_lossy().to_string());
+ let warning_msg = format!(
+ "Clip rendered successfully, but captions were skipped. Error: {}",
+ err_msg
+ );
+ state
+ .db
+ .update_clip_for_candidate(
+ &candidate_id,
+ "done",
+ Some(&path_string),
+ srt_string.as_deref(),
+ Some(&warning_msg),
+ )
+ .map_err(to_command_error)?;
+ Ok(path_string)
+ }
+ Err(retry_err) => {
+ let message = retry_err.to_string();
+ state
+ .db
+ .update_clip_for_candidate(&candidate_id, "error", None, None, Some(&message))
+ .map_err(to_command_error)?;
+ Err(message)
+ }
+ }
}
}
}
@@ -422,3 +497,170 @@ fn demo_transcript() -> NormalizedTranscript {
fn to_command_error(error: impl std::fmt::Display) -> String {
error.to_string()
}
+
+fn generate_srt(words: &[TranscriptWord], start_sec: f64, end_sec: f64) -> String {
+ let mut srt = String::new();
+ let mut index = 1;
+
+ let candidate_words: Vec<&TranscriptWord> = words
+ .iter()
+ .filter(|w| w.end > start_sec && w.start < end_sec)
+ .collect();
+
+ for chunk in candidate_words.chunks(3) {
+ if chunk.is_empty() {
+ continue;
+ }
+ let first = chunk[0];
+ let last = chunk[chunk.len() - 1];
+
+ let start_rel = (first.start - start_sec).max(0.0);
+ let end_rel = (last.end - start_sec).min(end_sec - start_sec).max(0.0);
+
+ let text = chunk
+ .iter()
+ .map(|w| w.text.as_str())
+ .collect::<Vec<_>>()
+ .join(" ");
+
+ srt.push_str(&format!("{index}\n"));
+ srt.push_str(&format!(
+ "{}\n",
+ format_srt_time(start_rel, end_rel)
+ ));
+ srt.push_str(&format!("{text}\n\n"));
+ index += 1;
+ }
+
+ srt
+}
+
+fn format_srt_time(start: f64, end: f64) -> String {
+ let format_time = |secs: f64| {
+ let hours = (secs / 3600.0) as u32;
+ let mins = ((secs % 3600.0) / 60.0) as u32;
+ let secs_only = (secs % 60.0) as u32;
+ let ms = ((secs.fract()) * 1000.0) as u32;
+ format!("{hours:02}:{mins:02}:{secs_only:02},{ms:03}")
+ };
+ format!("{} --> {}", format_time(start), format_time(end))
+}
+
+fn build_drawtext_filters(
+ words: &[TranscriptWord],
+ start_sec: f64,
+ end_sec: f64,
+ cropped_width: i64,
+ caption_style: &str,
+) -> String {
+ let mut drawtext_filters = Vec::new();
+
+ let candidate_words: Vec<&TranscriptWord> = words
+ .iter()
+ .filter(|w| w.end > start_sec && w.start < end_sec)
+ .collect();
+
+ // Group into chunks of 2 words for fast-paced style captions
+ for chunk in candidate_words.chunks(2) {
+ if chunk.is_empty() {
+ continue;
+ }
+ let first = chunk[0];
+ let last = chunk[chunk.len() - 1];
+
+ // Absolute timestamps for FFmpeg filter graph (due to output seeking keeping original PTS)
+ let start_rel = first.start;
+ let end_rel = last.end;
+ if end_rel <= start_rel {
+ continue;
+ }
+
+ let text = chunk
+ .iter()
+ .map(|w| w.text.to_uppercase())
+ .collect::<Vec<_>>()
+ .join(" ");
+
+ // Clean text to avoid breaking filter parameters
+ let clean_text: String = text.chars()
+ .filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '!' || *c == '?')
+ .collect();
+
+ // Responsive font size and padding box
+ let fontsize = ((cropped_width as f64) * 0.075).clamp(16.0, 80.0).round() as i64;
+ let padding = ((fontsize as f64) * 0.3).clamp(4.0, 24.0).round() as i64;
+
+ // Premium system font hierarchy
+ let font_paths = [
+ "/System/Library/Fonts/Supplemental/Futura.ttc",
+ "/System/Library/Fonts/Avenir Next.ttc",
+ "/System/Library/Fonts/Supplemental/Arial Bold.ttf",
+ "/System/Library/Fonts/Helvetica.ttc",
+ ];
+ let mut font_option = String::new();
+ for path in &font_paths {
+ if std::path::Path::new(path).exists() {
+ font_option = format!("fontfile='{}':", path);
+ break;
+ }
+ }
+
+ let drawtext = match caption_style {
+ "classic-outline" => {
+ // Classic yellow text with a bold outline (CapCut style)
+ let borderw = ((fontsize as f64) * 0.1).clamp(2.0, 8.0).round() as i64;
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.65:fontsize={}:fontcolor=yellow:borderw={}:bordercolor=black:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, borderw, start_rel, end_rel
+ )
+ }
+ "minimal-shadow" => {
+ // Sleek white text with a soft drop shadow (Minimalist)
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.7:fontsize={}:fontcolor=white:[email protected]:shadowx=2:shadowy=2:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, start_rel, end_rel
+ )
+ }
+ "vibrant-cyan" => {
+ // Modern Avenir Next look with clean cyan color and thin shadow
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.7:fontsize={}:fontcolor=0x00FFFF:[email protected]:shadowx=2:shadowy=2:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, start_rel, end_rel
+ )
+ }
+ "vibrant-yellow-box" => {
+ // Vibrant black text inside a solid yellow background box (Motivational/TikTok style)
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.72:fontsize={}:fontcolor=black:box=1:boxcolor=0xffff00e0:boxborderw={}:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, padding, start_rel, end_rel
+ )
+ }
+ "vibrant-green" => {
+ // High-energy neon green text with outline & drop shadow (Hormozi style)
+ let borderw = ((fontsize as f64) * 0.08).clamp(1.5, 6.0).round() as i64;
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.7:fontsize={}:fontcolor=0x39FF14:borderw={}:bordercolor=black:[email protected]:shadowx=2:shadowy=2:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, borderw, start_rel, end_rel
+ )
+ }
+ "vibrant-red" => {
+ // Dramatic red text with outline & drop shadow (Gaming/Drama style)
+ let borderw = ((fontsize as f64) * 0.08).clamp(1.5, 6.0).round() as i64;
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.7:fontsize={}:fontcolor=0xFF3B30:borderw={}:bordercolor=black:[email protected]:shadowx=2:shadowy=2:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, borderw, start_rel, end_rel
+ )
+ }
+ _ => {
+ // modern-box (Default): white text with clean box background
+ format!(
+ "drawtext={}text='{}':x=(w-text_w)/2:y=h*0.72:fontsize={}:fontcolor=white:box=1:boxcolor=0x000000b0:boxborderw={}:enable='between(t,{:.3},{:.3})'",
+ font_option, clean_text, fontsize, padding, start_rel, end_rel
+ )
+ }
+ };
+ drawtext_filters.push(drawtext);
+ }
+
+ drawtext_filters.join(",")
+}
diff --git a/src-tauri/src/media.rs b/src-tauri/src/media.rs
index 2393efb..00170ad 100644
--- a/src-tauri/src/media.rs
+++ b/src-tauri/src/media.rs
@@ -106,6 +106,7 @@ pub fn render_flat_clip(
start_sec: f64,
end_sec: f64,
output_path: &Path,
+ drawtext_filters: Option<&str>,
) -> Result<PathBuf> {
if !command_exists("ffmpeg") {
return Err(anyhow!("ffmpeg is not installed or not available on PATH"));
@@ -125,11 +126,13 @@ pub fn render_flat_clip(
cmd.args(["-y", "-i", source_path, "-ss", &start, "-to", &end]);
if has_video {
- // Crop video to 9:16 portrait/vertical format while ensuring dimensions are even
- cmd.args([
- "-vf",
- "crop=w='2*trunc(min(iw,ih*9/16)/2)':h='2*trunc(min(ih,iw*16/9)/2)'",
- ]);
+ let mut filter = "crop=w='2*trunc(min(iw,ih*9/16)/2)':h='2*trunc(min(ih,iw*16/9)/2)'".to_string();
+ if let Some(drawtext) = drawtext_filters {
+ if !drawtext.is_empty() {
+ filter = format!("{},{}", filter, drawtext);
+ }
+ }
+ cmd.args(["-vf", &filter]);
cmd.args(["-c:v", "libx264", "-preset", "fast", "-crf", "18", "-pix_fmt", "yuv420p"]);
} else {
cmd.arg("-vn");
diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs
index 1650375..c4e2fd0 100644
--- a/src-tauri/src/models.rs
+++ b/src-tauri/src/models.rs
@@ -32,6 +32,7 @@ pub struct Project {
pub source_duration: Option<f64>,
pub status: String,
pub transcription_mode: String,
+ pub caption_style: Option<String>,
pub created_at: String,
pub updated_at: String,
}
diff --git a/src/main.tsx b/src/main.tsx
index b0e1eea..12c8ab0 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -38,6 +38,7 @@ type Project = {
sourceDuration: number | null;
status: string;
transcriptionMode: string;
+ captionStyle?: string | null;
createdAt: string;
updatedAt: string;
};
@@ -111,6 +112,10 @@ function App() {
const [anthropicKey, setAnthropicKey] = useState("");
const [deepseekKey, setDeepseekKey] = useState("");
const [showSettings, setShowSettings] = useState(false);
+ const [renderingCandidateId, setRenderingCandidateId] = useState<string | null>(null);
+ const [showStyleModal, setShowStyleModal] = useState(false);
+ const [selectedStyle, setSelectedStyle] = useState("modern-box");
+ const [mediaPathToImport, setMediaPathToImport] = useState<string | null>(null);
const transcript = useMemo(() => {
if (!detail?.transcript) return null;
@@ -130,6 +135,10 @@ function App() {
const clip = clipByCandidate.get(candidate.id);
return clip?.status === "done" && Boolean(clip.outputPath);
}).length;
+ const selectedCaptionsCount = selectedCandidates.filter((candidate) => {
+ const clip = clipByCandidate.get(candidate.id);
+ return clip?.status === "done" && Boolean(clip.captionAssPath);
+ }).length;
const canUseCloudKey = environment?.hasDeepgramKey || deepgramKey.trim().length > 0;
const canUseClaude = environment?.hasAnthropicKey || anthropicKey.trim().length > 0;
const canUseDeepseek = environment?.hasDeepseekKey || deepseekKey.trim().length > 0;
@@ -171,21 +180,32 @@ function App() {
}
async function importMedia() {
+ const selected = await open({
+ multiple: false,
+ filters: [
+ {
+ name: "Media",
+ extensions: ["mp4", "mov", "mp3", "wav", "m4a"],
+ },
+ ],
+ });
+ if (typeof selected !== "string") return;
+ setMediaPathToImport(selected);
+ setShowStyleModal(true);
+ }
+
+ async function confirmImport(style: string) {
+ if (!mediaPathToImport) return;
+ const selected = mediaPathToImport;
+ setMediaPathToImport(null);
+ setShowStyleModal(false);
+
let newProjectId: string | null = null;
await run("import", async () => {
- const selected = await open({
- multiple: false,
- filters: [
- {
- name: "Media",
- extensions: ["mp4", "mov", "mp3", "wav", "m4a"],
- },
- ],
- });
- if (typeof selected !== "string") return;
const project = await invoke<Project>("create_project_from_path", {
path: selected,
transcriptionMode: "cloud",
+ captionStyle: style,
});
newProjectId = project.id;
await refresh(project.id);
@@ -325,20 +345,36 @@ function App() {
async function cutCandidate(candidateId: string) {
if (!detail) return;
- await run("cut", async () => {
+ setRenderingCandidateId(candidateId);
+ setBusy("cut");
+ setError(null);
+ try {
await invoke<string>("render_flat_clip_for_candidate", { candidateId });
+ } catch (err) {
+ setError(err instanceof Error ? err.message : String(err));
+ } finally {
+ setRenderingCandidateId(null);
+ setBusy("idle");
await refresh(detail.project.id);
- });
+ }
}
async function cutSelected() {
if (!detail) return;
- await run("cut", async () => {
+ setBusy("cut");
+ setError(null);
+ try {
for (const candidate of selectedCandidates) {
+ setRenderingCandidateId(candidate.id);
await invoke<string>("render_flat_clip_for_candidate", { candidateId: candidate.id });
}
+ } catch (err) {
+ setError(err instanceof Error ? err.message : String(err));
+ } finally {
+ setRenderingCandidateId(null);
+ setBusy("idle");
await refresh(detail.project.id);
- });
+ }
}
return (
@@ -456,8 +492,8 @@ function App() {
<PipelineStep icon={<AudioLines size={16} />} label="Transcript" done={Boolean(detail.transcript)} />
<PipelineStep icon={<Sparkles size={16} />} label="Moments" done={detail.candidates.length > 0} />
<PipelineStep icon={<Scissors size={16} />} label="Cut" done={selectedCount > 0 && selectedCutCount === selectedCount} />
- <PipelineStep icon={<Captions size={16} />} label="Captions" done={false} />
- <PipelineStep icon={<Download size={16} />} label="Export" done={false} />
+ <PipelineStep icon={<Captions size={16} />} label="Captions" done={selectedCount > 0 && selectedCaptionsCount === selectedCount} />
+ <PipelineStep icon={<Download size={16} />} label="Export" done={selectedCount > 0 && selectedCutCount === selectedCount} />
</div>
<div className="work-grid">
@@ -571,11 +607,20 @@ function App() {
onClick={() => void cutCandidate(candidate.id)}
disabled={busy !== "idle" || !environment?.hasFfmpeg}
>
- {busy === "cut" ? <Loader2 className="spin" size={14} /> : <Scissors size={14} />}
- {isCut ? "Re-cut" : "Cut"}
+ {renderingCandidateId === candidate.id ? (
+ <Loader2 className="spin" size={14} />
+ ) : (
+ <Scissors size={14} />
+ )}
+ {renderingCandidateId === candidate.id ? "Cutting..." : isCut ? "Re-cut" : "Cut"}
</button>
</div>
{clip?.outputPath && <div className="output-path">{clip.outputPath}</div>}
+ {clip?.captionAssPath && (
+ <div className="output-path" style={{ background: "rgba(142, 230, 199, 0.05)", borderColor: "var(--accent-primary)", color: "var(--accent-primary)", marginTop: "4px" }}>
+ Subtitles: {clip.captionAssPath}
+ </div>
+ )}
{clip?.renderLog && <div className="render-log">{clip.renderLog}</div>}
</div>
</article>
@@ -655,6 +700,105 @@ function App() {
</div>
</div>
</footer>
+
+ {showStyleModal && (
+ <div className="style-modal-overlay">
+ <div className="style-modal">
+ <div className="style-modal-header">
+ <h3>Choose Caption Style</h3>
+ <p>Select how your automated captions should look on the portrait short-form video clips.</p>
+ </div>
+
+ <div className="style-grid">
+ <div
+ className={`style-card ${selectedStyle === "modern-box" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("modern-box")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-box">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Modern Box</div>
+ <div className="style-card-desc">Sleek white text inside a semi-transparent black background padding box. Highly readable.</div>
+ </div>
+
+ <div
+ className={`style-card ${selectedStyle === "classic-outline" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("classic-outline")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-outline">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Classic Outline</div>
+ <div className="style-card-desc">Vibrant bold yellow text with a clean black outline. High-energy CapCut formatting.</div>
+ </div>
+
+ <div
+ className={`style-card ${selectedStyle === "minimal-shadow" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("minimal-shadow")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-shadow">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Minimal Shadow</div>
+ <div className="style-card-desc">Pure white text with a soft, elegant drop shadow. Unobtrusive and modern.</div>
+ </div>
+
+ <div
+ className={`style-card ${selectedStyle === "vibrant-cyan" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("vibrant-cyan")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-cyan">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Vibrant Cyan</div>
+ <div className="style-card-desc">Vibrant tech cyan text with a black drop shadow for a clean look.</div>
+ </div>
+
+ <div
+ className={`style-card ${selectedStyle === "vibrant-yellow-box" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("vibrant-yellow-box")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-yellow-box">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Vibrant Yellow Box</div>
+ <div className="style-card-desc">Bold black text inside a solid yellow padding box. Punchy and high visibility.</div>
+ </div>
+
+ <div
+ className={`style-card ${selectedStyle === "vibrant-green" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("vibrant-green")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-green">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Vibrant Green</div>
+ <div className="style-card-desc">High-energy neon green text with black borders and a drop shadow (Hormozi style).</div>
+ </div>
+
+ <div
+ className={`style-card ${selectedStyle === "vibrant-red" ? "selected" : ""}`}
+ onClick={() => setSelectedStyle("vibrant-red")}
+ >
+ <div className="style-preview-box">
+ <span className="preview-text-red">BRAINFOOD BECAUSE</span>
+ </div>
+ <div className="style-card-title">Vibrant Red</div>
+ <div className="style-card-desc">Dramatic neon crimson text with outline and drop shadow (gaming/action style).</div>
+ </div>
+ </div>
+
+ <div className="style-modal-actions">
+ <button className="btn-cancel" onClick={() => { setShowStyleModal(false); setMediaPathToImport(null); }}>
+ Cancel
+ </button>
+ <button className="btn-confirm" onClick={() => confirmImport(selectedStyle)}>
+ Confirm & Import
+ </button>
+ </div>
+ </div>
+ </div>
+ )}
</div>
);
}
diff --git a/src/styles.css b/src/styles.css
index b42e2e1..cae9fd3 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -1045,3 +1045,235 @@ button:disabled {
.api-warning strong {
color: #ffffff;
}
+
+/* Caption Style Selection Modal */
+.style-modal-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(6, 8, 12, 0.85);
+ backdrop-filter: blur(8px);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 1000;
+ animation: fadeIn 0.2s ease-out;
+}
+
+.style-modal {
+ width: 580px;
+ background: var(--bg-sidebar);
+ border: 1px solid var(--border-color);
+ border-radius: 16px;
+ padding: 24px;
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
+ animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
+ display: flex;
+ flex-direction: column;
+ gap: 18px;
+}
+
+.style-modal-header h3 {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 800;
+ letter-spacing: -0.3px;
+ color: var(--text-primary);
+}
+
+.style-modal-header p {
+ margin: 6px 0 0 0;
+ font-size: 13px;
+ color: var(--text-secondary);
+}
+
+.style-grid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 12px;
+ max-height: 380px;
+ overflow-y: auto;
+ padding-right: 4px;
+}
+
+.style-card {
+ background: var(--bg-panel);
+ border: 1px solid var(--border-color);
+ border-radius: 10px;
+ padding: 12px;
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
+}
+
+.style-card:hover {
+ border-color: rgba(255, 255, 255, 0.16);
+ background: rgba(255, 255, 255, 0.01);
+}
+
+.style-card.selected {
+ border-color: var(--accent-primary);
+ background: rgba(142, 230, 199, 0.02);
+}
+
+.style-card-title {
+ font-size: 13px;
+ font-weight: 700;
+ color: var(--text-primary);
+}
+
+.style-card-desc {
+ font-size: 11px;
+ color: var(--text-muted);
+ line-height: 1.35;
+ flex: 1;
+}
+
+/* Simulated caption video previews */
+.style-preview-box {
+ height: 60px;
+ background: #0f1015;
+ border: 1px solid rgba(255, 255, 255, 0.05);
+ border-radius: 6px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ overflow: hidden;
+ position: relative;
+}
+
+/* Style 1 Preview: Modern Box */
+.preview-text-box {
+ font-family: 'Impact', 'Avenir Next', 'Arial Black', sans-serif;
+ font-size: 12px;
+ font-weight: bold;
+ color: #ffffff;
+ background: rgba(0, 0, 0, 0.7);
+ padding: 3px 6px;
+ border-radius: 2px;
+ letter-spacing: 0.5px;
+}
+
+/* Style 2 Preview: Classic Outline */
+.preview-text-outline {
+ font-family: 'Impact', 'Avenir Next', 'Arial Black', sans-serif;
+ font-size: 13px;
+ font-weight: bold;
+ color: #ffff00;
+ text-shadow:
+ -1px -1px 0 #000,
+ 1px -1px 0 #000,
+ -1px 1px 0 #000,
+ 1px 1px 0 #000;
+ letter-spacing: 0.5px;
+}
+
+/* Style 3 Preview: Minimal Shadow */
+.preview-text-shadow {
+ font-family: 'Avenir Next', 'Helvetica Neue', sans-serif;
+ font-size: 13px;
+ font-weight: 800;
+ color: #ffffff;
+ text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
+}
+
+/* Style 4 Preview: Vibrant Cyan */
+.preview-text-cyan {
+ font-family: 'Avenir Next', 'Helvetica Neue', sans-serif;
+ font-size: 13px;
+ font-weight: 800;
+ color: #00ffff;
+ text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.6);
+}
+
+/* Style 5 Preview: Vibrant Yellow Box */
+.preview-text-yellow-box {
+ font-family: 'Impact', 'Avenir Next', 'Arial Black', sans-serif;
+ font-size: 12px;
+ font-weight: bold;
+ color: #000000;
+ background: #ffff00;
+ padding: 3px 6px;
+ border-radius: 2px;
+ letter-spacing: 0.5px;
+}
+
+/* Style 6 Preview: Vibrant Green */
+.preview-text-green {
+ font-family: 'Impact', 'Avenir Next', 'Arial Black', sans-serif;
+ font-size: 13px;
+ font-weight: bold;
+ color: #39FF14;
+ text-shadow:
+ -1px -1px 0 #000,
+ 1px -1px 0 #000,
+ -1px 1px 0 #000,
+ 1px 1px 0 #000,
+ 2px 2px 3px rgba(0,0,0,0.6);
+ letter-spacing: 0.5px;
+}
+
+/* Style 7 Preview: Vibrant Red */
+.preview-text-red {
+ font-family: 'Impact', 'Avenir Next', 'Arial Black', sans-serif;
+ font-size: 13px;
+ font-weight: bold;
+ color: #FF3B30;
+ text-shadow:
+ -1px -1px 0 #000,
+ 1px -1px 0 #000,
+ -1px 1px 0 #000,
+ 1px 1px 0 #000,
+ 2px 2px 3px rgba(0,0,0,0.6);
+ letter-spacing: 0.5px;
+}
+
+.style-modal-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+ margin-top: 8px;
+}
+
+.style-modal-actions button {
+ min-height: 36px;
+ padding: 0 16px;
+ font-weight: 700;
+ font-size: 13px;
+ border-radius: 8px;
+}
+
+.style-modal-actions .btn-cancel {
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid var(--border-color);
+ color: var(--text-secondary);
+}
+
+.style-modal-actions .btn-cancel:hover {
+ background: rgba(255, 255, 255, 0.08);
+ color: var(--text-primary);
+}
+
+.style-modal-actions .btn-confirm {
+ background: var(--accent-primary);
+ color: var(--accent-text);
+}
+
+.style-modal-actions .btn-confirm:hover {
+ background: var(--accent-primary-hover);
+}
+
+@keyframes fadeIn {
+ from { opacity: 0; }
+ to { opacity: 1; }
+}
+
+@keyframes scaleIn {
+ from { transform: scale(0.96); opacity: 0; }
+ to { transform: scale(1); opacity: 1; }
+}
+