Update detect_crop_video.py
Browse files- detect_crop_video.py +11 -7
detect_crop_video.py
CHANGED
|
@@ -237,7 +237,7 @@ def check_nvenc_support():
|
|
| 237 |
return False
|
| 238 |
|
| 239 |
|
| 240 |
-
def detect_and_crop_video(video_path, output_video_path):
|
| 241 |
"""
|
| 242 |
Detecta a região com movimento no vídeo e gera um vídeo cropado.
|
| 243 |
Retorna True se o crop foi realizado, False caso contrário.
|
|
@@ -380,13 +380,17 @@ def detect_and_crop_video(video_path, output_video_path):
|
|
| 380 |
return False
|
| 381 |
|
| 382 |
if crop_success:
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 387 |
shutil.move(tmp_output_path, output_video_path)
|
| 388 |
-
elif os.path.exists(tmp_output_path):
|
| 389 |
-
os.remove(tmp_output_path)
|
| 390 |
return True
|
| 391 |
|
| 392 |
return False
|
|
|
|
| 237 |
return False
|
| 238 |
|
| 239 |
|
| 240 |
+
def detect_and_crop_video(video_path, output_video_path, text_cut=True):
|
| 241 |
"""
|
| 242 |
Detecta a região com movimento no vídeo e gera um vídeo cropado.
|
| 243 |
Retorna True se o crop foi realizado, False caso contrário.
|
|
|
|
| 380 |
return False
|
| 381 |
|
| 382 |
if crop_success:
|
| 383 |
+
if text_cut:
|
| 384 |
+
# Pass 2: Text crop
|
| 385 |
+
print("🔄 Iniciando verificação de texto para segundo crop...")
|
| 386 |
+
text_cropped = detect_and_crop_text(tmp_output_path, output_video_path)
|
| 387 |
+
if not text_cropped:
|
| 388 |
+
shutil.move(tmp_output_path, output_video_path)
|
| 389 |
+
elif os.path.exists(tmp_output_path):
|
| 390 |
+
os.remove(tmp_output_path)
|
| 391 |
+
else:
|
| 392 |
+
print("⏩ Pulando verificação OCR por configuração do usuário (text_cut=False).")
|
| 393 |
shutil.move(tmp_output_path, output_video_path)
|
|
|
|
|
|
|
| 394 |
return True
|
| 395 |
|
| 396 |
return False
|