视频硬字幕提取方法(可完全离线),开发个小工具辅助一下

您所在的位置:网站首页 final导出srt字幕 视频硬字幕提取方法(可完全离线),开发个小工具辅助一下

视频硬字幕提取方法(可完全离线),开发个小工具辅助一下

2023-06-05 07:01| 来源: 网络整理| 查看: 265

最近博主闲下来了,思考人生接下来的方向,无聊时帮别人做了点小东西,贡献出来:

jre-17.0.7_win-x64的生成方式:

以管理员方式运行PowerShell执行命令:

cd $env:JAVA_HOME

jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.xml,java.desktop,jdk.management.agent --output E:\jre-17.0.7_win-x64

内部参数:

java -Dfile.encoding=UTF-8 -jar single-subtitle-text-1.0.0.jar

使用教程:

注意该图片的两个文件夹,都在下面这个软件的安装目录中。

VideoSubFinderWXW 拿来做字幕图片截取捕获,这是下载地址:

VideoSubFinder download | SourceForge.net

下载安装完成后,步骤:打开视频框选字幕位置,清空所有图片(之前识别的图片),开始识别。

捕获完在安装目录图片所示的第一个文件夹RGBImages中,PearOCR可以安装成浏览器应用可以离线识别,pearOCR官网如下:

PearOCR,在线图片转文字,免费OCR,在线图片文字提取,本地运算,无上传

上传RGBImages所有图片识别完后导出为txt。(如果后续出现问题,文件路径及文件名不建议带有中文)

接下来是我开发的小工具(代码已开源到github上),下载地址如下,

Release single-subtitle-text · LCJamI/single-subtitle-text (github.com)

下载single-subtitle-text_win-x64.zip解压,看到single-subtitle-text_win-x64.exe。

安全无毒,下面是代码:

package pers.lcj.tool; import lombok.extern.log4j.Log4j2; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Created by Aaron on 2023/4/28 0:29 */ @Log4j2 public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in, "GBK"); System.out.println("请输入导入文件路径:"); Path inputPath = getPath(scanner, "导入文件"); System.out.println("请输入导出目录路径:"); Path outputPath = getPath(scanner, "导出目录"); Map result = readFile(inputPath.toString()); writeOutputFiles(outputPath, result); } public static Path getPath(Scanner sc, String pathType) { Path path; do { String inputPath = sc.nextLine().replaceAll("^\"+|\"+$", ""); path = Paths.get(inputPath); if (pathType.equals("导入文件") && !Files.isRegularFile(path)) { System.out.println("输入路径不是一个有效文件路径,请重新输入:"); path = null; } else if (pathType.equals("导出目录") && !Files.isDirectory(path)) { System.out.println("输入路径不是一个有效文件路径,请重新输入:"); path = null; } } while (path == null); return path; } private static final int BUFFER_SIZE = 8192; private static final Pattern REGEX_PATTERN = Pattern.compile("(?


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3