mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-12 01:36:54 +02:00
fix(ffmpeg): use subtitles filter exclusively and fix SRT generation nameerror
This commit is contained in:
1 parent
c6bb589b09
commit
16435d499a
2 files changed
+19
-9
No files matched your search
+13
-9
@@ -85,7 +85,7 @@ def clean_text_for_tts(text: str) -> str:
|
||||
|
||||
|
||||
async def generate_tts_with_subs(
|
||||
text: str, voice: str, audio_path: Path, vtt_path: Path
|
||||
text: str, voice: str, audio_path: Path, srt_path: Path
|
||||
):
|
||||
"""Generate TTS audio with subtitles, with retry and fallback voices."""
|
||||
import asyncio
|
||||
@@ -126,9 +126,8 @@ async def generate_tts_with_subs(
|
||||
if audio_path.exists() and audio_path.stat().st_size > 0:
|
||||
print(f"✅ TTS audio saved: {audio_path.stat().st_size} bytes")
|
||||
|
||||
# Generate a simple VTT file with the full text
|
||||
# (word-by-word sync would require working SubMaker)
|
||||
generate_simple_vtt(text, vtt_path)
|
||||
# Generate a simple SRT file with the full text
|
||||
generate_simple_srt(text, srt_path)
|
||||
|
||||
print(f"✅ TTS success with voice: {attempt_voice}")
|
||||
return # Success!
|
||||
@@ -446,17 +445,22 @@ async def process_reel(request: ReelRequest, x_api_key: str = Header(None)):
|
||||
if request.text and request.draw_text:
|
||||
text_filter = ""
|
||||
if has_tts:
|
||||
# Subtitles (TikTok style) using SRT
|
||||
# Subtitles (TikTok style) using SRT (already generated in TTS block)
|
||||
# Force style to look like TikTok/Reels text
|
||||
# We use DejaVu Sans exactly as listed in fc-list
|
||||
style = f"FontName=DejaVu Sans,FontSize={request.font_size},PrimaryColour=&H00FFFFFF,OutlineColour=&H00000000,BorderStyle=1,Outline=3,Shadow=0,Bold=1,Alignment=2,MarginV=300"
|
||||
srt_path_str = str(tts_srt_path).replace("\\", "/").replace(":", "\\:")
|
||||
text_filter = f"subtitles='{srt_path_str}':force_style='{style}'"
|
||||
else:
|
||||
# Standard Drawtext
|
||||
# Ensure font path is valid (using FONT_PATH detected earlier)
|
||||
sanitized_text = request.text.replace("'", "").replace(":", "\\:")
|
||||
text_filter = f"drawtext=fontfile='{FONT_PATH}':text='{sanitized_text}':fontcolor=white:fontsize={request.font_size}:borderw=3:bordercolor=black:x=(w-text_w)/2:y=h-text_h-300"
|
||||
# Standard Text (without TTS)
|
||||
# We use subtitles filter here too because drawtext filter was reported missing
|
||||
print("📝 Using subtitles filter for standard text overlay (fallback from drawtext)")
|
||||
std_srt_path = job_dir / "std_text.srt"
|
||||
generate_simple_srt(request.text, std_srt_path)
|
||||
|
||||
style = f"FontName=DejaVu Sans,FontSize={request.font_size},PrimaryColour=&H00FFFFFF,OutlineColour=&H00000000,BorderStyle=1,Outline=3,Shadow=0,Bold=1,Alignment=2,MarginV=300"
|
||||
srt_path_str = str(std_srt_path).replace("\\", "/").replace(":", "\\:")
|
||||
text_filter = f"subtitles='{srt_path_str}':force_style='{style}'"
|
||||
|
||||
# Combine formatting + text
|
||||
video_filters_str += f",{text_filter}"
|
||||
|
||||
@@ -116,6 +116,12 @@ Ajout d'une fonctionnalité complète de création de Reels Facebook permettant
|
||||
- [x] Ajouter l'attribut `multiple` à l'input file pour forcer l'envoi du fichier original (Bypass Safari downscaling)
|
||||
- [x] Mettre à jour les MIME types pour inclure `video/quicktime` (iPhone natif)
|
||||
- [x] Documenter que la stabilisation native dépend des réglages iOS de l'utilisateur
|
||||
- [x] **Fix Build Failure** : Correction syntaxe `useDropzone` et JSX dans `new-reel.tsx`.
|
||||
- [x] **Fix Mobile Overlay** : Force `drawText: true` sur le client mobile.
|
||||
- [x] **Fix Font Issue** : Ajout de `fontconfig`, `fc-cache`, et utilisation de police générique "Sans".
|
||||
- [x] **Refactor FFmpeg** : Passage à un pipeline `filter_complex` unifié pour éviter les conflits et garantir l'overlay.
|
||||
- [x] **Fix Indentation** : Correction de l'erreur de syntaxe Python introduite.
|
||||
- [x] **Fix F-String Syntax** : Correction de l'erreur `f-string expression part cannot include a backslash`.
|
||||
|
||||
## Progress Log
|
||||
|
||||
|
||||
Reference in new issue
Block a user