mirror of
https://github.com/YaoFANGUK/video-subtitle-remover.git
synced 2026-02-17 06:00:34 +08:00
新增进度条
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore")
|
||||
import os
|
||||
import torch
|
||||
import logging
|
||||
|
||||
from fsplit.filesplit import Filesplit
|
||||
|
||||
logging.disable(logging.DEBUG) # 关闭DEBUG日志的打印
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import config
|
||||
import os
|
||||
from pathlib import Path
|
||||
import threading
|
||||
import cv2
|
||||
import sys
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
import importlib
|
||||
import config
|
||||
import numpy as np
|
||||
from tqdm import tqdm
|
||||
from tools.infer import utility
|
||||
from tools.infer.predict_det import TextDetector
|
||||
from inpaint.lama_inpaint import inpaint_img_with_lama
|
||||
@@ -56,6 +57,7 @@ class SubtitleDetect:
|
||||
def find_subtitle_frame_no(self):
|
||||
video_cap = cv2.VideoCapture(self.video_path)
|
||||
frame_count = video_cap.get(cv2.CAP_PROP_FRAME_COUNT)
|
||||
tbar = tqdm(total=int(frame_count), unit='f', position=0, file=sys.__stdout__, desc='字幕查找')
|
||||
current_frame_no = 0
|
||||
subtitle_frame_no_list = {}
|
||||
|
||||
@@ -81,7 +83,7 @@ class SubtitleDetect:
|
||||
else:
|
||||
temp_list.append((xmin, xmax, ymin, ymax))
|
||||
subtitle_frame_no_list[current_frame_no] = temp_list
|
||||
print(f'[字幕查找]{current_frame_no}/{int(frame_count)}')
|
||||
tbar.update(1)
|
||||
return subtitle_frame_no_list
|
||||
|
||||
|
||||
@@ -137,6 +139,7 @@ class SubtitleRemover:
|
||||
# 寻找字幕帧
|
||||
sub_list = self.sub_detector.find_subtitle_frame_no()
|
||||
index = 0
|
||||
tbar = tqdm(total=int(self.frame_count), unit='f', position=0, file=sys.__stdout__, desc='字幕去除')
|
||||
while True:
|
||||
ret, frame = self.video_cap.read()
|
||||
if not ret:
|
||||
@@ -146,7 +149,7 @@ class SubtitleRemover:
|
||||
masks = self.create_mask(frame, sub_list[index])
|
||||
frame = self.inpaint_frame(frame, masks)
|
||||
self.video_writer.write(frame)
|
||||
print(f'[字幕去除]{index}/{int(self.frame_count)}')
|
||||
tbar.update(1)
|
||||
self.video_cap.release()
|
||||
self.video_writer.release()
|
||||
|
||||
@@ -175,11 +178,10 @@ class SubtitleRemover:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 开始提取字幕
|
||||
v_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'test', 'test_en.mp4')
|
||||
print(v_path)
|
||||
# 提示用户输入视频路径
|
||||
video_path = input(f"请输入视频文件路径: ").strip()
|
||||
# 新建字幕提取对象
|
||||
sd = SubtitleRemover(v_path)
|
||||
sd = SubtitleRemover(video_path)
|
||||
sd.run()
|
||||
|
||||
|
||||
|
||||
162
requirements.txt
162
requirements.txt
@@ -1,154 +1,20 @@
|
||||
absl-py==2.0.0
|
||||
aiohttp==3.8.6
|
||||
aiosignal==1.3.1
|
||||
albumentations==0.5.2
|
||||
antlr4-python3-runtime==4.8
|
||||
astor==0.8.1
|
||||
astunparse==1.6.3
|
||||
async-timeout==4.0.3
|
||||
attrdict==2.0.1
|
||||
attrs==23.1.0
|
||||
Babel==2.13.0
|
||||
bce-python-sdk==0.8.90
|
||||
beautifulsoup4==4.12.2
|
||||
blinker==1.6.3
|
||||
braceexpand==0.1.7
|
||||
cachetools==5.3.1
|
||||
certifi==2023.7.22
|
||||
cffi==1.16.0
|
||||
charset-normalizer==3.3.0
|
||||
click==8.1.7
|
||||
cmake==3.25.0
|
||||
contourpy==1.1.1
|
||||
cssselect==1.2.0
|
||||
cssutils==2.7.1
|
||||
cycler==0.12.1
|
||||
Cython==3.0.3
|
||||
decorator==5.1.1
|
||||
easydict==1.9
|
||||
et-xmlfile==1.1.0
|
||||
filelock==3.12.4
|
||||
filesplit==3.0.2
|
||||
fire==0.5.0
|
||||
Flask==3.0.0
|
||||
flask-babel==4.0.0
|
||||
flatbuffers==23.5.26
|
||||
fonttools==4.43.1
|
||||
frozenlist==1.4.0
|
||||
fsspec==2023.9.2
|
||||
future==0.18.3
|
||||
gast==0.4.0
|
||||
google-auth==2.23.3
|
||||
google-auth-oauthlib==1.0.0
|
||||
google-pasta==0.2.0
|
||||
grpcio==1.59.0
|
||||
h5py==3.10.0
|
||||
huggingface-hub==0.18.0
|
||||
hydra-core==1.1.0
|
||||
idna==3.4
|
||||
imageio==2.31.5
|
||||
imageio-ffmpeg==0.4.9
|
||||
imgaug==0.4.0
|
||||
importlib-metadata==6.8.0
|
||||
importlib-resources==6.1.0
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
joblib==1.3.2
|
||||
jpeg4py==0.1.4
|
||||
keras==2.13.1
|
||||
kiwisolver==1.4.5
|
||||
kornia==0.5.0
|
||||
libclang==16.0.6
|
||||
lit==15.0.7
|
||||
lmdb==1.4.1
|
||||
lxml==4.9.3
|
||||
Markdown==3.5
|
||||
MarkupSafe==2.1.3
|
||||
matplotlib==3.7.3
|
||||
mpmath==1.3.0
|
||||
multidict==6.0.4
|
||||
networkx==3.1
|
||||
numpy==1.22.0
|
||||
nvidia-cublas-cu12==12.1.3.1
|
||||
nvidia-cuda-cupti-cu12==12.1.105
|
||||
nvidia-cuda-nvrtc-cu12==12.1.105
|
||||
nvidia-cuda-runtime-cu12==12.1.105
|
||||
nvidia-cudnn-cu12==8.9.2.26
|
||||
nvidia-cufft-cu12==11.0.2.54
|
||||
nvidia-curand-cu12==10.3.2.106
|
||||
nvidia-cusolver-cu12==11.4.5.107
|
||||
nvidia-cusparse-cu12==12.1.0.106
|
||||
nvidia-nccl-cu12==2.18.1
|
||||
nvidia-nvjitlink-cu12==12.2.140
|
||||
nvidia-nvtx-cu12==12.1.105
|
||||
oauthlib==3.2.2
|
||||
omegaconf==2.1.2
|
||||
opencv-contrib-python==4.6.0.66
|
||||
opencv-python==4.8.1.78
|
||||
opencv-python-headless==4.8.1.78
|
||||
openpyxl==3.1.2
|
||||
opt-einsum==3.3.0
|
||||
packaging==23.2
|
||||
paddle-bfloat==0.1.7
|
||||
paddleocr==2.7.0.3
|
||||
paddlepaddle-gpu==2.4.2.post117
|
||||
pandas==2.0.3
|
||||
pdf2docx==0.5.6
|
||||
Pillow==10.0.1
|
||||
premailer==3.10.0
|
||||
protobuf==3.20.0
|
||||
psutil==5.9.5
|
||||
pyasn1==0.5.0
|
||||
pyasn1-modules==0.3.0
|
||||
pyclipper==1.3.0.post5
|
||||
pycparser==2.21
|
||||
pycryptodome==3.19.0
|
||||
PyMuPDF==1.20.2
|
||||
pyparsing==3.1.1
|
||||
PySimpleGUI==4.60.5
|
||||
python-dateutil==2.8.2
|
||||
python-docx==1.0.0
|
||||
python-Levenshtein-wheels==0.13.2
|
||||
pytorch-lightning==1.2.9
|
||||
pytz==2023.3.post1
|
||||
PyWavelets==1.4.1
|
||||
PyYAML==6.0.1
|
||||
rapidfuzz==3.4.0
|
||||
rarfile==4.1
|
||||
requests==2.31.0
|
||||
requests-oauthlib==1.3.1
|
||||
rsa==4.9
|
||||
safetensors==0.4.0
|
||||
torch==2.0.1
|
||||
torchvision==0.15.2
|
||||
scikit-image==0.17.2
|
||||
scikit-learn==0.24.2
|
||||
scipy==1.10.1
|
||||
shapely==2.0.1
|
||||
six==1.16.0
|
||||
soupsieve==2.5
|
||||
sympy==1.12
|
||||
tabulate==0.9.0
|
||||
tensorboard==2.13.0
|
||||
tensorboard-data-server==0.7.1
|
||||
tensorflow==2.13.1
|
||||
tensorflow-estimator==2.13.0
|
||||
tensorflow-io-gcs-filesystem==0.34.0
|
||||
termcolor==2.3.0
|
||||
threadpoolctl==3.2.0
|
||||
tifffile==2023.7.10
|
||||
timm==0.9.7
|
||||
torch==2.0.1+cu117
|
||||
torchaudio==2.0.2+cu117
|
||||
torchmetrics==0.2.0
|
||||
torchvision==0.15.2+cu117
|
||||
imgaug==0.4.0
|
||||
kornia==0.5.0
|
||||
pyclipper==1.3.0.post5
|
||||
lmdb==1.4.1
|
||||
PyYAML==6.0.1
|
||||
omegaconf==2.1.2
|
||||
tqdm==4.66.1
|
||||
triton==2.0.0
|
||||
typing_extensions==4.5.0
|
||||
tzdata==2023.3
|
||||
urllib3==2.0.6
|
||||
visualdl==2.5.3
|
||||
easydict==1.9
|
||||
scikit-learn==0.24.2
|
||||
pandas==2.0.3
|
||||
webdataset==0.2.57
|
||||
Werkzeug==3.0.0
|
||||
wldhx.yadisk-direct==0.0.6
|
||||
wrapt==1.15.0
|
||||
yarl==1.9.2
|
||||
zipp==3.17.0
|
||||
pytorch-lightning==1.2.9
|
||||
numpy==1.23.1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user