Skip to content

Commit

Permalink
修复 因为indexOf造成无法正确处理多英文句号文件名的问题
Browse files Browse the repository at this point in the history
优化 提取获取无扩展名的文件名的方法进Utils,方便调用
修复 调用ffmpeg切割视频被PotPlayer识别为音频的问题,相对兼容,遂版本号升至1.1.0
优化 将时间戳转换为秒的方法转移到Utils下,方便调用,符合规范
优化 去除无用的import
更新 发布1.1.0
  • Loading branch information
Aric-Sun committed Oct 8, 2020
1 parent 055c1cb commit 1b074c2
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 32 deletions.
10 changes: 5 additions & 5 deletions InnoSetupConfig.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "FirstKeyFrameFilter"
#define MyAppVersion "1.0.1-20.10.4"
#define MyAppVersion "1.1.0-20.10.8"
#define MyAppPublisher "zsunqian69@gmail.com"
#define MyAppURL "https://github.com/Aric-Sun/FirstKeyFrameFilter"
#define MyAppExeName "FirstKeyFrameFilter.exe"
Expand All @@ -25,8 +25,8 @@ AllowNoIcons=yes
; 移除以下行,以在管理安装模式下运行(为所有用户安装)。
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=commandline
OutputDir=D:\Downloads\FirstKeyFrameFilter\out\artifacts\FirstKeyFrameFilter_jar
OutputBaseFilename=FirstKeyFrameFilter1.0.1-20.10.4_Setup
OutputDir=E:\Aric Sun\自学技术\FirstKeyFrameFilter\out\artifacts\FirstKeyFrameFilter_jar
OutputBaseFilename=FirstKeyFrameFilter1.1.0-20.10.8_Setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern
Expand All @@ -35,8 +35,8 @@ WizardStyle=modern
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Files]
Source: "D:\Downloads\FirstKeyFrameFilter\out\artifacts\FirstKeyFrameFilter_jar\FirstKeyFrameFilter\FirstKeyFrameFilter.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\Downloads\FirstKeyFrameFilter\out\artifacts\FirstKeyFrameFilter_jar\FirstKeyFrameFilter\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "E:\Aric Sun\自学技术\FirstKeyFrameFilter\out\artifacts\FirstKeyFrameFilter_jar\FirstKeyFrameFilter\FirstKeyFrameFilter.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "E:\Aric Sun\自学技术\FirstKeyFrameFilter\out\artifacts\FirstKeyFrameFilter_jar\FirstKeyFrameFilter\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]
Expand Down
8 changes: 4 additions & 4 deletions exe4jConfigFile.exe4j
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<exe4j version="7.0" transformSequenceNumber="3">
<directoryPresets config="./lib-apps" />
<application name="FirstKeyFrameFilter" distributionSourceDir="D:/Downloads/FirstKeyFrameFilter/out/artifacts/FirstKeyFrameFilter_jar" />
<directoryPresets config="E:/Aric Sun/自学技术/FirstKeyFrameFilter/out/artifacts" />
<application name="FirstKeyFrameFilter" distributionSourceDir="E:/Aric Sun/自学技术/FirstKeyFrameFilter/out/artifacts/FirstKeyFrameFilter_jar" />
<executable name="FirstKeyFrameFilter" wrapperType="embed" executableDir="." executableMode="console" singleInstance="true">
<versionInfo include="true" fileDescription="缺帧flv处理程序" legalCopyright="zsunqian69@gmail.com" companyName="Avengers" productVersion="1.0.1-20.10.4" />
<versionInfo include="true" fileDescription="缺帧flv处理程序" legalCopyright="zsunqian69@gmail.com" companyName="Avengers" productVersion="1.1.0-20.10.8" />
</executable>
<java mainClass="Main" minVersion="1.6" maxVersion="1.8">
<java mainClass="Main" minVersion="1.6" maxVersion="1.8" allowBetaVM="true">
<searchSequence>
<directory location="./jre1.8.0_161" />
<registry />
Expand Down
7 changes: 4 additions & 3 deletions src/FLVCutter/FastForwardMpeg.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package FLVCutter;

import Utils.FileUtils.FilenameUtils;
import Utils.RuntimeUtils.LocalCmdExecutor;

import java.io.*;
Expand Down Expand Up @@ -32,9 +33,8 @@ public String cutFlvWithSSTime(String flvPath, double ssTime){
return "-23";
}
// 最终生成的文件
String flvPathCut = flvPath.substring(
0, flvPath.indexOf(".")
) + "-cut_" + ssTime + "-end.flv";
String flvPathCut = FilenameUtils.getFilenameWithoutExtension(flvPath)
+ "-cut_" + ssTime + "-end.flv";

//判断目标生成文件是否存在,询问是否覆盖
Path FLVPathCut = Paths.get(flvPathCut);
Expand All @@ -57,6 +57,7 @@ public String cutFlvWithSSTime(String flvPath, double ssTime){
"-i", flvPath,
"-ss", String.valueOf(ssTime),
"-c", "copy",
"-copyts", // keep the original timestamps
flvPathCut};

// 执行命令
Expand Down
18 changes: 18 additions & 0 deletions src/Utils/DataTypeConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package Utils;

/**
* 数据类型转换工具类
* @author AricSun
* @date 2020.10.07 23:02
*/
public class DataTypeConverter{
/*
* function: 将timestamp的PTxx.xxS通过正则匹配出浮点型数据
* @Param: [timeStamp时间戳]
* @Return: java.lang.Double
*/
public static Double TimeStamp2Double(String timeStamp){
return Double.parseDouble(timeStamp.replaceAll("[^\\d.]", ""));
}

}
24 changes: 24 additions & 0 deletions src/Utils/FileUtils/FilenameUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Utils.FileUtils;

/**
* 文件名工具类
* @author AricSun
* @date 2020.10.07 22:36
*/
public class FilenameUtils {
/*
* function: 获取不带扩展名的文件名
* @Param [filename文件名]
* @Return java.lang.String
* from: https://my.oschina.net/liting/blog/535479
*/
public static String getFilenameWithoutExtension(String filename){
if ((filename != null) && (filename.length() > 0)){
int dot = filename.lastIndexOf('.');
if ((dot > -1) && (dot < filename.length())){
return filename.substring(0,dot);
}
}
return filename;
}
}
8 changes: 4 additions & 4 deletions src/XMLGenerator/FlvInteractiveRebase.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package XMLGenerator;

import Utils.RuntimeUtils.LocalCmdExecutor;
import Utils.RuntimeUtils.ResourcesRelease;

import java.io.*;
import java.nio.file.Files;
Expand All @@ -12,6 +11,8 @@
import java.util.Scanner;
import java.util.stream.Stream;

import Utils.FileUtils.FilenameUtils;

/**
* 调用fib读取flv
* errorCodePrefix 1
Expand All @@ -37,9 +38,8 @@ public String parseFlvWithFib(String flvPath) {
// Path flvFileName = flvPath.getFileName(); // flv文件名,带后缀,不带路径
// Path flvFolderPath = flvPath.getParent(); // flv所在目录路径
// String flvPathStr = String.valueOf(flvPath);
String xmlPath = flvPath.substring(0,
flvPath.lastIndexOf(".")
).concat(".xml"); // 生成xml的绝对路径
String xmlPath = FilenameUtils.getFilenameWithoutExtension(flvPath)
.concat(".xml"); // 生成xml的绝对路径

//判断目标生成文件是否存在,询问是否覆盖
Path XMLPath = Paths.get(xmlPath);
Expand Down
12 changes: 2 additions & 10 deletions src/XMLParsing/DOM/XMLReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package XMLParsing.DOM;

import Utils.DataTypeConverter;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -86,21 +87,12 @@ public static void main(String[] args) {
此处因废用而不再修复
*/
if (CntKeyFrame == 3){
System.out.println(TimeStamp2Double(timeStamp));
System.out.println(DataTypeConverter.TimeStamp2Double(timeStamp));
break;
}
}
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}
}

/*
* function: 将timestamp的PTxx.xxS通过正则匹配出浮点型数据
* @Param: [timeStamp时间戳]
* @Return: java.lang.Double
*/
public static Double TimeStamp2Double(String timeStamp){
return Double.parseDouble(timeStamp.replaceAll("[^\\d.]", ""));
}
}
2 changes: 1 addition & 1 deletion src/XMLParsing/SAX/XMLReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void main(String[] args) {
SAXParser saxParser = saxParserFactory.newSAXParser();
saxParser.parse(new File("xml/352-TypicalCase.xml"),frameHandler);
List<Frame> frameList = frameHandler.getFrameList();
// System.out.println(frameList);
System.out.println(frameList);
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}
Expand Down
9 changes: 4 additions & 5 deletions src/XMLParsing/StAX/ParserXML.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package XMLParsing.StAX;

import Utils.DataTypeConverter;
import dto.Frame;

import javax.xml.stream.XMLInputFactory;
Expand All @@ -12,8 +13,6 @@
import java.util.ArrayList;
import java.util.List;

import static XMLParsing.DOM.XMLReader.TimeStamp2Double;

/**
* StAX解析XML
* StAX与SAX一样是基于XML事件的解析方式,
Expand Down Expand Up @@ -42,9 +41,9 @@
public class ParserXML {
private Frame frame;

public List<Frame> getFrameList() {
/*public List<Frame> getFrameList() {
return frameList;
}
}*/

private List<Frame> frameList;

Expand Down Expand Up @@ -180,7 +179,7 @@ public double readXMLByCursor(String XMLFilePath){
* */
int cntKeyFrame = frameList.size();
if (cntKeyFrame >= 2){
double secondKeyFrameTime = TimeStamp2Double(
double secondKeyFrameTime = DataTypeConverter.TimeStamp2Double(
frameList.get(cntKeyFrame-1).getTimeStamp()
);
/* 2020年10月4日
Expand Down

0 comments on commit 1b074c2

Please sign in to comment.