|
|
@@ -26,12 +26,13 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String ffmpegHts(String pathMp4) {
|
|
|
- pathMp4= getFilePath(pathMp4);
|
|
|
+ public String ffmpegHts(String path) {
|
|
|
+ String pathMp4= getFilePath(path);
|
|
|
String filePathName = pathMp4.substring(0, pathMp4.lastIndexOf("."));
|
|
|
String fileName = filePathName.substring(filePathName.lastIndexOf("/"));
|
|
|
String pathM3u8 = filePathName + fileName;
|
|
|
String pathM3u8Name = pathM3u8 + ".m3u8";
|
|
|
+ new File(filePathName).mkdirs();
|
|
|
try {
|
|
|
System.out.println("PATH环境变量: " + System.getenv("PATH"));
|
|
|
// 构建FFmpeg命令进行HLS切片
|
|
|
@@ -39,7 +40,7 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
|
|
|
"ffmpeg", "-i", pathMp4,
|
|
|
"-c:v", "h264", "-c:a", "aac",
|
|
|
"-hls_time", "10", "-hls_list_size", "0",
|
|
|
- "-hls_segment_filename", filePathName + "_%03d.ts",
|
|
|
+ "-hls_segment_filename", pathM3u8 + "_%03d.ts",
|
|
|
pathM3u8Name
|
|
|
);
|
|
|
|
|
|
@@ -61,9 +62,10 @@ public class LocalFileClient extends AbstractFileClient<LocalFileClientConfig> {
|
|
|
// 等待进程执行完成
|
|
|
int exitCode = process.waitFor();
|
|
|
if (exitCode == 0) {
|
|
|
- pathM3u8 = pathM3u8.substring(pathM3u8.lastIndexOf(File.separator)+1);
|
|
|
- System.out.println("视频切片成功,m3u8路径: " + pathM3u8);
|
|
|
- return super.formatFileUrl(config.getDomain(), pathM3u8);
|
|
|
+ String dateStr = path.substring(0, 8);
|
|
|
+ pathM3u8Name = pathM3u8Name.substring(pathM3u8Name.lastIndexOf(dateStr));
|
|
|
+ System.out.println("视频切片成功,m3u8路径: " + pathM3u8Name);
|
|
|
+ return super.formatFileUrl(config.getDomain(), pathM3u8Name);
|
|
|
} else {
|
|
|
System.err.println("FFmpeg执行失败,退出码: " + exitCode);
|
|
|
return null;
|