mirror of
https://github.com/YaoFANGUK/video-subtitle-remover.git
synced 2026-05-23 06:37:30 +08:00
支持不同任务使用不同选区
This commit is contained in:
@@ -59,7 +59,7 @@ OpenVideoFirst = 请先打开视频
|
||||
VideoPreview = 视频预览
|
||||
InterfaceLanguage = 界面语言
|
||||
InpaintMode = 处理模型
|
||||
SelectSubtitleArea = 请在视频预览中框选处理区域
|
||||
SelectSubtitleArea = 请在视频预览中框选处理区域: {}
|
||||
InpaintModeDesc = STTN智能擦除, 对于真人视频效果较好,速度快, 智能擦除(最低4GB显存)
|
||||
STTN字幕检测 带字幕检测版, 无智能擦除(最低4GB显存)
|
||||
LAMA: 对于动画类视频效果好,速度一般(显存要求较低)
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenVideoFirst = 請先開啟影片
|
||||
VideoPreview = 影片預覽
|
||||
InterfaceLanguage = 介面語言
|
||||
InpaintMode = 處理模型
|
||||
SelectSubtitleArea = 請在影片預覽中框選處理區域
|
||||
SelectSubtitleArea = 請在影片預覽中框選處理區域: {}
|
||||
InpaintModeDesc = STTN智能擦除,對於真人視頻效果較好,速度快,智能擦除(最低4GB顯存)
|
||||
STTN字幕檢測 帶字幕檢測版,無智能擦除(最低4GB顯存)
|
||||
LAMA:對於動畫類視頻效果好,速度一般(顯存要求較低)
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenVideoFirst = Please open a video first
|
||||
VideoPreview = Video Preview
|
||||
InterfaceLanguage = Interface Language
|
||||
InpaintMode = Processing Model
|
||||
SelectSubtitleArea = Select processing area in video preview
|
||||
SelectSubtitleArea = Select processing area in video preview: {}
|
||||
InpaintModeDesc = STTN Smart Inpainting: Best for real-person videos, fast speed, smart inpainting (minimum 4GB VRAM)
|
||||
STTN Subtitle Detection: With subtitle detection, no smart inpainting (minimum 4GB VRAM)
|
||||
LAMA: Good for animation videos, moderate speed (low VRAM requirement)
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenVideoFirst = Abre un video primero
|
||||
VideoPreview = Vista previa
|
||||
InterfaceLanguage = Idioma de interfaz
|
||||
InpaintMode = Modelo de procesamiento
|
||||
SelectSubtitleArea = Selecciona área en vista previa
|
||||
SelectSubtitleArea = Selecciona área en vista previa: {}
|
||||
InpaintModeDesc = STTN Borrado inteligente: Mejor para videos de personas reales, velocidad rápida, borrado inteligente (mínimo 4GB de VRAM)
|
||||
STTN Detección de subtítulos: Con detección de subtítulos, sin borrado inteligente (mínimo 4GB de VRAM)
|
||||
LAMA: Bueno para videos animados, velocidad media (bajo requerimiento de VRAM)
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenVideoFirst = 動画を先に開いてください
|
||||
VideoPreview = 動画プレビュー
|
||||
InterfaceLanguage = インターフェース言語
|
||||
InpaintMode = 処理モデル
|
||||
SelectSubtitleArea = プレビューで処理領域を選択
|
||||
SelectSubtitleArea = プレビューで処理領域を選択: {}
|
||||
InpaintModeDesc = STTNスマート消去:実写動画に最適、高速、スマート消去(最低4GB VRAM)
|
||||
STTN字幕検出:字幕検出付き、スマート消去なし(最低4GB VRAM)
|
||||
LAMA:アニメ動画に最適、速度は普通(VRAM要件低め)
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenVideoFirst = 동영상을 먼저 열어주세요
|
||||
VideoPreview = 동영상 미리보기
|
||||
InterfaceLanguage = 인터페이스 언어
|
||||
InpaintMode = 처리 모델
|
||||
SelectSubtitleArea = 미리보기에서 처리 영역 선택
|
||||
SelectSubtitleArea = 미리보기에서 처리 영역 선택: {}
|
||||
InpaintModeDesc = STTN 스마트 지우기: 실제 인물 영상에 적합, 빠른 속도, 스마트 지우기(최소 4GB VRAM)
|
||||
STTN 자막 감지: 자막 감지 버전, 스마트 지우기 없음(최소 4GB VRAM)
|
||||
LAMA: 애니메이션 영상에 적합, 보통 속도(VRAM 요구량 낮음)
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenVideoFirst = Vui lòng mở video trước
|
||||
VideoPreview = Xem trước video
|
||||
InterfaceLanguage = Ngôn ngữ giao diện
|
||||
InpaintMode = Chế độ xử lý
|
||||
SelectSubtitleArea = Chọn vùng xử lý trong preview
|
||||
SelectSubtitleArea = Chọn vùng xử lý trong preview: {}
|
||||
InpaintModeDesc = STTN Xóa thông minh: Phù hợp cho video người thật, tốc độ nhanh, xóa thông minh (tối thiểu 4GB VRAM)
|
||||
STTN Phát hiện phụ đề: Có phát hiện phụ đề, không xóa thông minh (tối thiểu 4GB VRAM)
|
||||
LAMA: Phù hợp cho video hoạt hình, tốc độ trung bình (yêu cầu VRAM thấp)
|
||||
|
||||
@@ -24,20 +24,18 @@ from backend.tools.inpaint_tools import create_mask, batch_generator, expand_fra
|
||||
from backend.tools.model_config import ModelConfig
|
||||
from backend.tools.ffmpeg_cli import FFmpegCLI
|
||||
from backend.tools.subtitle_detect import SubtitleDetect
|
||||
import platform
|
||||
import tempfile
|
||||
import multiprocessing
|
||||
from shapely.geometry import Polygon
|
||||
import time
|
||||
from tqdm import tqdm
|
||||
import numpy as np
|
||||
|
||||
class SubtitleRemover:
|
||||
def __init__(self, vd_path, sub_areas=[], gui_mode=False):
|
||||
def __init__(self, vd_path, gui_mode=False):
|
||||
# 线程锁
|
||||
self.lock = threading.RLock()
|
||||
# 用户指定的字幕区域位置
|
||||
self.sub_areas = sub_areas
|
||||
self.sub_areas = []
|
||||
# 是否为gui运行,gui运行需要显示预览
|
||||
self.gui_mode = gui_mode
|
||||
self.hardware_accelerator = HardwareAccelerator.instance()
|
||||
@@ -67,9 +65,6 @@ class SubtitleRemover:
|
||||
self.video_out_path = os.path.abspath(os.path.join(os.path.dirname(self.video_path), f'{self.vd_name}_no_sub.mp4'))
|
||||
self.propainter_inpaint = None
|
||||
self.ext = os.path.splitext(vd_path)[-1]
|
||||
if len(self.sub_areas) == 0:
|
||||
self.append_output(tr['Main']['FullScreenProcessingNote'])
|
||||
self.sub_areas.append((0, self.frame_height, 0, self.frame_width))
|
||||
if self.is_picture:
|
||||
pic_dir = os.path.join(os.path.dirname(self.video_path), 'no_sub')
|
||||
if not os.path.exists(pic_dir):
|
||||
@@ -331,6 +326,10 @@ class SubtitleRemover:
|
||||
def run(self):
|
||||
# 记录开始时间
|
||||
start_time = time.time()
|
||||
if len(self.sub_areas) == 0:
|
||||
self.append_output(tr['Main']['FullScreenProcessingNote'])
|
||||
self.sub_areas.append((0, self.frame_height, 0, self.frame_width))
|
||||
self.append_output(tr['Main']['SubtitleArea'].format(self.sub_areas))
|
||||
self.append_output(tr['Main']['ABSection'].format(str(self.ab_sections).replace("range", "") if self.ab_sections is not None and len(self.ab_sections) > 0 else tr['Main']['ABSectionAll']))
|
||||
# 如果使用GPU加速,则打印GPU加速提示
|
||||
if self.hardware_accelerator.has_accelerator():
|
||||
@@ -466,11 +465,11 @@ if __name__ == '__main__':
|
||||
config.set(config.interface, 'en')
|
||||
TRANSLATION_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'interface', f"{config.interface.value}.ini")
|
||||
tr.read(TRANSLATION_FILE, encoding='utf-8')
|
||||
print('Subtitle Area:', 'fullscreen' if len(args.subtitle_area_coords) <= 0 else args.subtitle_area_coords)
|
||||
sr = SubtitleRemover(args.input, sub_areas=args.subtitle_area_coords)
|
||||
sr = SubtitleRemover(args.input)
|
||||
if not is_video_or_image(args.input):
|
||||
sr.append_output(f'Error: {video_path} is not supported not corrupted.')
|
||||
exit(-1)
|
||||
sr.sub_areas = args.subtitle_area_coords
|
||||
sr.video_out_path = args.output
|
||||
config.inpaintMode.value = args.inpaint_mode
|
||||
sr.run()
|
||||
|
||||
Reference in New Issue
Block a user