-
安装使用VideoSubFinder软件
- 下载地址:Windows & Linux (videosubfinder官网 / QQ群(706807542)共享文件) | Mac版
- 使用教程:VideoSubFinder提取字幕关键帧教程
- 最终生成的
RGBImages
和TXTImages
目录一般会在软件安装目录下 - ✧ 推荐用
RGBImages
目录中图像(感谢小伙伴dyphire在#21的反馈)
-
安装rapid_videocr
pip install rapid_videocr
-
脚本运行:
- Only OCR:
from rapid_videocr import RapidVideOCR # RapidVideOCR有两个初始化参数 # is_concat_rec: 是否用单张图识别,默认是False,也就是默认用单图识别 # concat_batch: 叠图识别的图像张数,默认10,可自行调节 # out_format: 输出格式选择,[srt, txt, all], 默认是 all # is_print_console: 是否打印结果,[0, 1], 默认是0,不打印 extractor = RapidVideOCR(is_concat=False, out_format='all', is_print_console=False) # Windows端,需要这样写: rgb_dir = r'G:\ProgramFiles\_self\RapidVideOCR\test_files\RGBImages' # Linux / Mac 下面这样写 rgb_dir = 'test_files/TXTImages' save_dir = 'result' extractor(rgb_dir, save_dir)
- Extract + OCR:
from rapid_videocr import RapidVideoSubFinderOCR vsf_exe = r"G:\ProgramFiles\VideoSubFinder_6.10_x64\Release_x64\VideoSubFinderWXW.exe" extractor = RapidVideoSubFinderOCR(vsf_exe_path=vsf_exe, is_concat_rec=True) # video_path can be directory path or video full path. video_path = 'test_files/tiny/2.mp4' save_dir = 'outputs' extractor(video_path, save_dir)
- Only OCR:
-
命令行运行:
- Usage:
$ rapid_videocr -h usage: rapid_videocr [-h] [-vsf VSF_EXE_PATH] [-video_dir VIDEO_DIR] [-i IMG_DIR] [-s SAVE_DIR] [-o {srt,txt,all}] [-m {single,concat}] [-b CONCAT_BATCH] [-p {0,1}] options: -h, --help show this help message and exit -vsf VSF_EXE_PATH, --vsf_exe_path VSF_EXE_PATH The full path of VideoSubFinderWXW.exe. -video_dir VIDEO_DIR, --video_dir VIDEO_DIR The full path of video or the path of video directory. -i IMG_DIR, --img_dir IMG_DIR The full path of RGBImages or TXTImages. -s SAVE_DIR, --save_dir SAVE_DIR The path of saving the recognition result. Default is "outputs" under the current directory. -o {srt,txt,all}, --out_format {srt,txt,all} Output file format. Default is "all". -m {single,concat}, --mode {single,concat} Which mode to run (concat recognition or single recognition). Default is "single". -b CONCAT_BATCH, --concat_batch CONCAT_BATCH The batch of concating image nums in concat recognition mode. Default is 10. -p {0,1}, --print_console {0,1} Whether to print the subtitle results to console. 1 means to print results to console. Default is 0.
- Example:
- Only OCR:
$ rapid_videocr -i RGBImages
- Extract + OCR:
$ rapid_videocr -vsf G:\ProgramFiles\VideoSubFinder_6.10_x64\Release_x64\VideoSubFinderWXW.exe -video_dir G:\ProgramFiles\RapidVideOCR\test_files\tiny
- Only OCR:
- Usage:
-
查看结果
- 前往
save_dir
目录下即可查看结果。 - 值得注意的是,如果想要让视频播放软件自动挂载srt文件,需要更改srt文件名字为视频文件名字,且放到同一目录下,亦或者手动指定加载。
- 前往
PS: 详情参见RapidVideOCR