调整FFmpeg参数

This commit is contained in:
zlzw 2024-11-22 17:27:29 +08:00
parent a466ddfb68
commit 41d3dec536
3 changed files with 24 additions and 12 deletions

View File

@ -120,6 +120,9 @@ public class LiveService {
long videoTime = FFmpegUtils.getVideoTime(videoFile); long videoTime = FFmpegUtils.getVideoTime(videoFile);
long startTime = Long.parseLong(videoId); long startTime = Long.parseLong(videoId);
long endTime = Long.parseLong(videoId) + videoTime; long endTime = Long.parseLong(videoId) + videoTime;
if(endTime==0){
endTime=System.currentTimeMillis();
}
return database.getGiftInfo(startTime, endTime); return database.getGiftInfo(startTime, endTime);
} }

View File

@ -258,7 +258,15 @@ public class LiveVideoDownloadService {
.withNotSymbolParam("-threads", "8") .withNotSymbolParam("-threads", "8")
.withNotSymbolParam("-c:v", "copy") .withNotSymbolParam("-c:v", "copy")
.withNotSymbolParam("-fflags", "+genpts") .withNotSymbolParam("-fflags", "+genpts")
.withNotSymbolParam("-y", ""); .withNotSymbolParam("-y", "")
//-reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2
.withNotSymbolParam("-reconnect", "1")
.withNotSymbolParam("-reconnect_at_eof", "1")
.withNotSymbolParam("-reconnect_streamed", "1")
.withNotSymbolParam("-reconnect_delay_max", "2")
.withNotSymbolParam("-loglevel", "error")
// .withNotSymbolParam("-progress",new File("cache",config.getRoomId()+".txt").getAbsolutePath()); //输出进度日志,暂时没啥用
;
if (ck != null) { if (ck != null) {
builder = builder.withParam("-cookies", cookie); builder = builder.withParam("-cookies", cookie);
} }

View File

@ -155,6 +155,7 @@ public class FFmpegUtils extends AbsVideoRecord {
* @param video 视频文件 * @param video 视频文件
* @return 毫秒 * @return 毫秒
*/ */
@Deprecated
public static long getVideoTime(File video) { public static long getVideoTime(File video) {
String ffprobe = ConfigTools.load(ConfigTools.CONFIG, "ffprobe", String.class); String ffprobe = ConfigTools.load(ConfigTools.CONFIG, "ffprobe", String.class);
String exec = ffprobe + " -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"" + video.getAbsolutePath() + "\""; String exec = ffprobe + " -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"" + video.getAbsolutePath() + "\"";
@ -172,7 +173,7 @@ public class FFmpegUtils extends AbsVideoRecord {
return (long) (Double.parseDouble(data) * 1000); return (long) (Double.parseDouble(data) * 1000);
} catch (Exception e) { } catch (Exception e) {
Log.e(e); Log.e(e);
throw new RuntimeException(e); return 0;
} }
} }