|  | @@ -38,6 +38,8 @@ public class VcDeviceServiceImpl extends AbstractCrudService<VcDeviceMapper, VcD
 | 
	
		
			
				|  |  |      @Value("${vc.rtmp-ip}")
 | 
	
		
			
				|  |  |      private String rtmpIp;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    Process process = null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<VcDevice> VcDeviceList(Integer groupId){
 | 
	
		
			
				|  |  |          LambdaQueryWrapper<VcDevice> queryWrapper = Wrappers.lambdaQuery();
 | 
	
	
		
			
				|  | @@ -73,9 +75,9 @@ public class VcDeviceServiceImpl extends AbstractCrudService<VcDeviceMapper, VcD
 | 
	
		
			
				|  |  |          String videoPassword = one.getVideoPassword();
 | 
	
		
			
				|  |  |          String videoIp = one.getVideoIp();
 | 
	
		
			
				|  |  |          String videoPort = one.getVideoPort().toString();
 | 
	
		
			
				|  |  | -        String command = "ffmpeg -i rtsp://"+accountNumber+":"+videoPassword+"@"+videoIp+":"+videoPort+" -vcodec copy -acodec aac -ar 44100 -c:v libx264 -strict -2 -ac 1 -f flv -r 30 -s 1920x1080 -q 10 -f flv rtmp://"+rtmpIp+":1935/hls/"+deviceUuid;
 | 
	
		
			
				|  |  | +        String command = "ffmpeg -i rtsp://"+accountNumber+":"+videoPassword+"@"+videoIp+":"+videoPort+" -vcodec copy -acodec aac -ar 44100 -c:v libx264 -strict -2 -ac 1 -r 30 -s 1920x1080 -q 10 -f flv rtmp://"+rtmpIp+":1935/hls/"+deviceUuid;
 | 
	
		
			
				|  |  |          System.out.println(command);
 | 
	
		
			
				|  |  | -        Process process = null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              log.info("【begin】实时拉取摄像头数据流 "+command);
 | 
	
		
			
				|  |  |              // 创建 ProcessBuilder 实例
 | 
	
	
		
			
				|  | @@ -83,26 +85,22 @@ public class VcDeviceServiceImpl extends AbstractCrudService<VcDeviceMapper, VcD
 | 
	
		
			
				|  |  |              // 启动进程
 | 
	
		
			
				|  |  |              process = processBuilder.start();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            // 获取进程的输入流
 | 
	
		
			
				|  |  | -//            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
 | 
	
		
			
				|  |  | -//            String line;
 | 
	
		
			
				|  |  | -//            while ((line = reader.readLine()) != null) {
 | 
	
		
			
				|  |  | -//                System.out.println(line);
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            // 等待进程执行完成并获取退出码
 | 
	
		
			
				|  |  | -            int exitCode = process.waitFor();
 | 
	
		
			
				|  |  | -            log.info("【end】实时拉取摄像头数据流 "+command+ "命令执行完成,退出码: " + exitCode);
 | 
	
		
			
				|  |  | -            if (exitCode == 0) {
 | 
	
		
			
				|  |  | -                System.out.println("FFmpeg 命令执行成功");
 | 
	
		
			
				|  |  | -                String repDeviceVideo = rtmpIp+":80/hls/"+deviceUuid+".m3u8";
 | 
	
		
			
				|  |  | -                return repDeviceVideo;
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                System.out.println("FFmpeg 命令执行失败,退出码: " + exitCode);
 | 
	
		
			
				|  |  | -                return null;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            new Thread(() -> {
 | 
	
		
			
				|  |  | +                try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
 | 
	
		
			
				|  |  | +                    String line;
 | 
	
		
			
				|  |  | +                    while ((line = reader.readLine()) != null) {
 | 
	
		
			
				|  |  | +                        System.out.println(line);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } catch (IOException e) {
 | 
	
		
			
				|  |  | +                    e.printStackTrace();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }).start();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            String repDeviceVideo = rtmpIp+":80/hls/"+deviceUuid+".m3u8";
 | 
	
		
			
				|  |  | +            return repDeviceVideo;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        } catch (IOException | InterruptedException e) {
 | 
	
		
			
				|  |  | +        } catch (IOException e) {
 | 
	
		
			
				|  |  |              e.printStackTrace();
 | 
	
		
			
				|  |  |              return null;
 | 
	
		
			
				|  |  |          } finally {
 | 
	
	
		
			
				|  | @@ -111,8 +109,18 @@ public class VcDeviceServiceImpl extends AbstractCrudService<VcDeviceMapper, VcD
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void stopDeviceVideo() {
 | 
	
		
			
				|  |  | +        if (process != null && process.isAlive()) {
 | 
	
		
			
				|  |  | +            process.destroy();
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                process.waitFor();
 | 
	
		
			
				|  |  | +            } catch (InterruptedException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 |