java SSM框架使用WebSocket推送视频流

依赖


    org.springframework
    spring-websocket
    5.2.5.RELEASE
    compile

1.视频工具类

import org.apache.log4j.Logger;
import org.springframework.web.socket.BinaryMessage;
import org.springframework.web.socket.WebSocketSession;

import java.io.InputStream;
import java.util.List;


/**
 * 
 * TODO:视频工具类
 * 
* * @author zhangjunchao * @date 2019/8/19 */ public class VideoUtils { private final static Logger logger = Logger.getLogger(VideoUtils.class); // 声明的ffmpeg.exe固定路径变量 public String FFMPEG_PATH = "D:/ffmpeg/bin/ffmpeg.exe"; public String channel = ""; public WebSocketSession webSocketSession = null; private Process process; public VideoUtils(String channel, WebSocketSession webSocketSession) { // ffmpeg路径需要更换自己的 FFMPEG_PATH = "D:\\developsoftware\\wisdom_screen_ds1200\\server\\ETCMornitoring\\src\\main\\resources" + "\\export_template" + "\\ffmpeg.exe"; this.channel = channel; this.webSocketSession = webSocketSession; } /** * 视频转换 * * @param video_path */ public void convertCommand() { String channel = this.channel; WebSocketSession webSocketSession = this.webSocketSession; System.out.println("start"); System.out.println(FFMPEG_PATH); InputStream errorStream = null; InputStream inputStream = null; try { List commands = new java.util.ArrayList(); commands.add(FFMPEG_PATH); commands.add("-rtsp_transport"); commands.add("tcp"); commands.add("-i"); commands.add(channel); commands.add("-vcodec"); co

你可能感兴趣的:(ssm,websocket,视频处理)