cmd 退出码是啥?还有,执行情况有 log 输出,最好追踪一下
解决方案 »
- 求servlet学习视屏。。。
- 用frameset还是其他技术
- Service注入到Strut2中,注入失败......在线等大家的解答..谢谢
- 关于项目国际化的奇怪问题。
- 关于JSF中分页显示
- 请问怎么抓取登录后才能看到的网页?
- Hot deploy,能解释一下么?
- 使用webservice(soap)的两种方式,请大家来指导我一些概念问题!!
- 连接数据库总是出现如下错误,不知是什么错误,请指点,谢谢
- 所有的jsp网页都打不开,提示500 Internal Server Error
- 一个简单问题?@Transient 位置为题
- 跪求啊 时间戳在jsp页面上怎么转换为yyyy-MM-dd HH:mm:ss
public String stoprecord(HttpServletRequest req, Model model, HttpServletResponse res) throws IOException {
logger.info("execute VdProgramScheduleController.remove()");
logger.info( "视频直播停止录制中...");
/**
* 关闭进程
*/
Process listprocess;
String programName= "ffmpeg.exe";
try {
listprocess = Runtime.getRuntime().exec("cmd.exe /c tasklist");
InputStream is = listprocess.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(is));
//StringBuffer sb = new StringBuffer();
String str = null;
while ((str = r.readLine()) != null) {
String id = null;
Matcher matcher = Pattern.compile(programName + "[ ]*([0-9]*)").matcher(str);
while (matcher.find()) {
if (matcher.groupCount() >= 1) {
id = matcher.group(1);
if (id != null) {
Integer pid = null;
try {
pid = Integer.parseInt(id);
} catch (NumberFormatException e) {
e.printStackTrace();
}
if (pid != null) {
//windows 关闭进程的代码
Runtime.getRuntime().exec("cmd.exe /c taskkill /f /pid " + pid);
// unix/linux下
// Runtime.getRuntime().exec("abc=`ps -ef|grep $LOGNAME|grep 要终止的进程名称|grep -v grep |cut -c 10-16`;kill -9 $abc");
//System.out.println("kill progress"+pid);
}
}
}
}
}
}
catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* @param p
* @return
*/
protected int doWaitFor2(Process p) {
int exitValue = -1; // returned to caller when p is finished
try {
InputStream in = p.getInputStream();
InputStream err = p.getErrorStream();
boolean finished = false; // Set to true when p is finished while (!finished) {
try {
StringBuilder inSb = new StringBuilder();
while (in.available() > 0) {
// Print the output of our system call
Character c = new Character((char) in.read());
inSb.append(c);
}
logger.debug(inSb.toString());
StringBuilder errSb = new StringBuilder();
while (err.available() > 0) {
Character c = new Character((char) err.read());
errSb.append(c);
}
logger.debug(errSb.toString());
// Ask the process for its exitValue. If the process
// is not finished an IllegalThreadStateException
// is thrown. If it is finished we fall through and
// the variable finished is set to true.
exitValue = p.exitValue();
finished = true; } catch (IllegalThreadStateException e) {
// Process is not finished yet;
// Sleep a little to save on CPU cycles
//e.printStackTrace();
TimeUnit.MILLISECONDS.sleep(500L);
}
}
} catch (Exception e) {
// unexpected exception! print it out for debugging...
e.printStackTrace();
} // return completion status to caller
return exitValue;
}
/**
* author zy
* @param p
* @return
*/
protected int doWaitFor3(Process p) {
int exitValue = 0; // returned to caller when p is finished
// return completion status to caller
return exitValue;
}
d:\share\var\converttools\ffmpeg.exe -y -i rtmp://192.168.1.145/live/livestream1 live=1 -vcodec copy -acodec copy -b 128k -s 320*240 -f flv d:\test.flv
d:\share\var\converttools\ffmpeg.exe -y -i rtmp://192.168.1.145/live/livestream1 live=1 -vcodec copy -acodec copy -b 128k -s 320*240 -f flv d:\test.flv
已解决