diff --git a/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java b/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java index d563b2e..a6d863e 100644 --- a/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java +++ b/src/main/java/com/yutou/bilibili/Controllers/VideoFileController.java @@ -109,6 +109,6 @@ public class VideoFileController { @RequestMapping("/video/play") @ResponseBody public JSONObject getVideoUrl(String roomId, String videoId) { - return ResultData.success("/play/"+videoService.getVideoPlay(roomId, videoId)); + return ResultData.success("/live/"+videoService.getVideoPlay(roomId, videoId)); } } diff --git a/src/main/java/com/yutou/bilibili/services/LiveVideoDownloadService.java b/src/main/java/com/yutou/bilibili/services/LiveVideoDownloadService.java index c2feccc..f963f10 100644 --- a/src/main/java/com/yutou/bilibili/services/LiveVideoDownloadService.java +++ b/src/main/java/com/yutou/bilibili/services/LiveVideoDownloadService.java @@ -134,10 +134,10 @@ public class LiveVideoDownloadService { public void run() { if (roomInfo.getLiveStatus() == 1) { String time = DateUtils.format(new Date().getTime(), DATE_FORMAT_10_DASH); - rootPath = new File(bean.getRecordPath() + File.separator + bean.getAnchorName() + File.separator + time + File.separator + roomInfo.getTitle()); - savePath = rootPath.getAbsolutePath() + File.separator + "[" + + rootPath = new File(bean.getRecordPath() + File.separator + bean.getAnchorName() + File.separator + time + File.separator + "[" + DateUtils.format(new Date(), - "yyyy-MM-dd HH-mm-ss") + "]" + roomInfo.getTitle() + ".flv"; + "yyyy-MM-dd HH-mm-ss") + "]" + roomInfo.getTitle()); + savePath = rootPath.getAbsolutePath() + File.separator + roomInfo.getTitle() + "-%04d.ts"; if (!rootPath.exists()) { rootPath.mkdirs(); } @@ -220,7 +220,7 @@ public class LiveVideoDownloadService { String url = urlInfo.getHost() + codec.getBaseUrl() + urlInfo.getExtra(); - Log.i("下载直播",rawResponse,codec.toString(),urlInfo.toString(),"URL:"+url); + Log.i("下载直播", rawResponse, codec.toString(), urlInfo.toString(), "URL:" + url); if (bean.getRecordLiveModel() == 1) { javaRecord(url, response); @@ -286,7 +286,11 @@ public class LiveVideoDownloadService { // .withNotSymbolParam("-progress", "-") // .withNotSymbolParam("-fflags", "+genpts") .withNotSymbolParam("-threads", "8") - .withNotSymbolParam("-bufsize", "10M") +// .withNotSymbolParam("-bufsize", "10M") + .withNotSymbolParam("-f", "segment") + .withNotSymbolParam("-segment_time", "60") + .withNotSymbolParam("-segment_format", "flv") + .withParam("-segment_list", rootPath + File.separator + roomInfo.getTitle() + ".m3u8") .withNotSymbolParam("-c", "copy") .withNotSymbolParam("-bsf:a", "aac_adtstoasc") // .withNotSymbolParam("-loglevel", "debug") @@ -423,9 +427,11 @@ public class LiveVideoDownloadService { } liveDatabase.close(); if (videoInfo != null) { - File videoFile = new File(videoInfo.getPath().replace(".flv", ".mp4")); + File videoFile = new File(videoInfo.getPath().replace("-%04d.ts", ".m3u8")); if (!videoFile.exists()) { videoFile = new File(videoInfo.getPath()); + }else{ + return videoInfo.getPath().replace(new File("live").getAbsolutePath(),"").replace(File.separator,"/").replace("-%04d.ts", ".m3u8"); } FFmpegUtils ffmpeg = FFmpegUtils.segment(videoId, ffmpegPath, videoFile, ConfigTools.load(ConfigTools.CONFIG, "outVideoPath", String.class)); System.out.println(ffmpeg.getCommandDecode());