Added some robustness to RTSP recorder
This commit is contained in:
parent
6b92172d74
commit
53e9f08272
1 changed files with 68 additions and 59 deletions
|
|
@ -43,6 +43,7 @@ public class RTSPCameraRecorder implements Runnable {
|
|||
public void run() {
|
||||
logger.info("Starting up RTSP Stream recording thread for: " + camera.getRtspUrl());
|
||||
|
||||
while (camera != null) {
|
||||
try {
|
||||
new File(storagePath).mkdirs();
|
||||
|
||||
|
|
@ -52,7 +53,6 @@ public class RTSPCameraRecorder implements Runnable {
|
|||
|
||||
FFmpegInput ffmpegInput = new FFmpegInput(camera.getRtspUrl());
|
||||
|
||||
//FFmpegOutput ffmpegOutput = new FFmpegOutput(storagePath + File.separator + "stream.mp4");
|
||||
FFmpegOutput ffmpegOutput = new FFmpegOutput(new File(storagePath, "stream_%v/stream.m3u8").getPath());
|
||||
/*ffmpegOutput.addAdditionalArg("-filter_complex \"[0:v]split=3[v1][v2][v3]; [v1]copy[v1out]; [v2]scale=w=1280:h=720[v2out]; [v3]scale=w=640:h=360[v3out]\"",
|
||||
"-map [v1out] -c:v:0 libx264 -x264-params \"nal-hrd=cbr:force-cfr=1\" -b:v:0 5M -maxrate:v:0 5M -minrate:v:0 5M -bufsize:v:0 10M -preset veryfast -g 25 -sc_threshold 0",
|
||||
|
|
@ -113,11 +113,20 @@ public class RTSPCameraRecorder implements Runnable {
|
|||
} finally {
|
||||
logger.info("Shutting down RTSP Stream recording thread for: " + camera.getRtspUrl());
|
||||
}
|
||||
|
||||
if (camera != null) {
|
||||
try {
|
||||
logger.info("Restarting RTSP thread in 3 seconds.");
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (process != null) {
|
||||
logger.info("Killing ffmpeg instance.");
|
||||
camera = null;
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue