-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
keep the vsf results under the output directory. Fixed #34
- Loading branch information
Showing
3 changed files
with
23 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,16 @@ | |
# @Author: SWHL | ||
# @Contact: [email protected] | ||
import argparse | ||
import tempfile | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from .rapid_videocr import RapidVideOCR | ||
from .utils import get_logger | ||
from .video_sub_finder import VideoSubFinder | ||
|
||
|
||
class RapidVideoSubFinderOCR: | ||
def __init__(self, vsf_exe_path: str = None, **ocr_params) -> None: | ||
def __init__(self, vsf_exe_path: Optional[str] = None, **ocr_params) -> None: | ||
if vsf_exe_path is None: | ||
raise ValueError("vsf_exe_path must not be None.") | ||
|
||
|
@@ -37,25 +37,24 @@ def __call__(self, video_path: str, output_dir: str = "outputs"): | |
self.logger.info( | ||
f"[{i+1}/{video_num}] Starting to extract {one_video} key frame" | ||
) | ||
with tempfile.TemporaryDirectory() as tmp_dir: | ||
try: | ||
self.vsf(str(one_video), tmp_dir) | ||
except Exception as e: | ||
self.logger.error(f"Extract {one_video} error, {e}, skip") | ||
continue | ||
|
||
self.logger.info(f"[{i+1}/{video_num}] Starting to run {one_video} ocr") | ||
|
||
rgb_dir = Path(tmp_dir) / "RGBImages" | ||
if not list(rgb_dir.iterdir()): | ||
self.logger.warning( | ||
f"Extracting frames from {one_video} is 0, skip" | ||
) | ||
continue | ||
|
||
save_name = Path(one_video).stem | ||
save_srt_dir = Path(output_dir) / save_name | ||
self.video_ocr(rgb_dir, save_srt_dir, save_name=save_name) | ||
|
||
save_name = Path(one_video).stem | ||
save_dir = Path(output_dir) / save_name | ||
save_vsf_dir = save_dir / "VSF_Results" | ||
|
||
try: | ||
self.vsf(str(one_video), str(save_vsf_dir)) | ||
except Exception as e: | ||
self.logger.error(f"Extract {one_video} error, {e}, skip") | ||
continue | ||
|
||
self.logger.info(f"[{i+1}/{video_num}] Starting to run {one_video} ocr") | ||
|
||
rgb_dir = Path(save_vsf_dir) / "RGBImages" | ||
if not list(rgb_dir.iterdir()): | ||
self.logger.warning(f"Extracting frames from {one_video} is 0, skip") | ||
continue | ||
self.video_ocr(rgb_dir, save_dir, save_name=save_name) | ||
|
||
|
||
def main() -> None: | ||
|