abc01230123abc
2015-03-03 11:45:41
完
java使用mencoder转码视频为什么失败?
在linux中敲入命令
mencoder 1.rmvb -o 2.avi -vf scale=320:240 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500
能够转码成功
这是java代码
String toAvi = "mencoder " + originPath + "-o " + aviPath + "-vf scale=320:240 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500"; try { // Process p = Runtime.getRuntime().exec(toAvi); Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(toAvi); InputStream is = proc.getInputStream(); final BufferedReader stdout = new BufferedReader( new InputStreamReader(is)); is = proc.getErrorStream(); final BufferedReader stderr = new BufferedReader( new InputStreamReader(is)); final Vector outputLines = new Vector(); // this deals with the output from the process in it's own thread Thread stdoutThread = new Thread() { public void run() { try { PrintWriter writer = new PrintWriter(new FileWriter( "log.txt")); int l; String line; for (l = 0; (line = stdout.readLine()) != null;) { if (line.length() > 0) { l++; outputLines.appendElement(line); // if (line.matches("Starting playback...")) } } System.out.println("\nRead " + l + " lines from stdout."); stdout.close(); writer.close(); } catch (IOException ie) { System.out.println("IO exception on stdout: " + ie); } } }; stdoutThread.start(); Thread stderrThread = new Thread() { public void run() { try { int l; String line; for (l = 0; (line = stderr.readLine()) != null;) { if (line.length() > 0) l++; System.out.print(","); } System.out.println("\nRead " + l + " lines from stderr."); stderr.close(); } catch (IOException ie) { System.out.println("IO exception on stderr: " + ie); } } }; stderrThread.start(); System.out.println("About to waitfor"); try { int exitVal = proc.waitFor(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Done."); } catch (IOException e) { e.printStackTrace(); System.out.println("Exec failed. Exiting"); System.exit(0); return false; } return true;
执行后,linux输出
[2015-03-03 11:14:20] [INFO] [System.out] [creat folder:/app/tongweb02/deployment/modules/cms-web/static/upload/video/origin/2015/03/03/1.rmvb] [2015-03-03 11:14:20] [INFO] [System.out] [creat folder:/app/tongweb02/deployment/modules/cms-web/static/upload/video/flv/2015/03/03/1425352460609.flv] [2015-03-03 11:14:20] [INFO] [System.out] [creat folder:/app/tongweb02/deployment/modules/cms-web/static/upload/video/videoTemp] [2015-03-03 11:14:20] [INFO] [System.out] [originVideo:/app/tongweb02/deployment/modules/cms-web/static/upload/video/origin/2015/03/03/1.rmvb] [2015-03-03 11:14:20] [INFO] [System.out] [transform video:/app/tongweb02/deployment/modules/cms-web/static/upload/video/videoTemp/1425352460776.avi] [2015-03-03 11:14:20] [INFO] [System.out] [About to waitfor] [2015-03-03 11:14:20] [INFO] [System.out] [ Read 0 lines from stderr.] [2015-03-03 11:14:20] [INFO] [System.out] [ Read 2 lines from stdout.] [2015-03-03 11:14:20] [INFO] [System.out] [Done.] [2015-03-03 11:14:20] [INFO] [System.out] [rmvb to avi true]
并没有成功转码,在文件夹中没有视频文件,求一段java转码代码,使用mencoder的
评论

abc01230123abc LV6
2015年3月3日
String getter = null; String toAvi = "mencoder " + originPath + " -o " + aviPath + " -vf scale=320:240 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500"; try{ Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(toAvi); BufferedReader stdout = new BufferedReader( new InputStreamReader(proc.getInputStream())); String line; while ((line = stdout.readLine()) != null) { getter += line + ","; if( getter != null ) System.out.println(line); } proc.waitFor(); stdout.close(); } catch (Exception e) { e.printStackTrace(); return false; } return true;
评论(0)
最佳答案
- 等 最代码怎么获取牛币啊?
- 完 谁来告诉我最代码上线的时间,答对者给5牛币,先来先得
- 等 牛友们,大家好,你们做程序员多久了?现在还好吗?
- 完 在微信打开的页面里进行app下载
- 等 最代码2014年欢乐聚声会
- 完 mysql如何查询表数据并且对3个字段降序的SQL?
- 完 最代码牛币机制改革
- 完 成功的在bae上使用了自定义运行环境 jetty+nginx的组合,大家对jetty+nginx优化有哪些心得?
- 完 进来分享一下各位牛牛是如何加入最代码大家庭的?
- 等 为什么java BufferedImage类处理大图直接抛出内存溢出的异常?
- 等 最代码是否开发手机app客户端?
- 完 java程序员学习哪些java的技术?java有哪些框架?都能做哪方面的开发?
- 等 php格式网页文件怎么运行?
- 等 Java volatile值获取的问题
- 等 前端vue,拦截了登录后台后,返回的token,requests拦截token,但是发送请求的时候,就出现跨越异常
- 等 大专本科计算机科班怎么找到Java工作?
- 等 eclipse怎么把三个java swing游戏项目合成一个项目?
- 完 伙伴们,大家都有什么好的解压方式么,分享一下~
- 完 三四线城市,6、7k,运维工作,索然无味,想去辞职上培训,各位牛牛有什么建议嘛
- 等 jsp页面输入中文变成问号
- 等 JPA在线上运行一段时间后报错Caused by: java.lang.IncompatibleClassChangeError: null
- 等 PHP 这个规则用preg_match_all怎么写
- 等 大佬们,有没有知道Alfresco如何配置LDAP登录呢?
- 等 php的install目录是框架带的吗?

mutouershu LV1
2018年1月12日
zephyry LV3
2015年3月12日
shengke LV17
2015年3月4日
562909048 LV10
2015年3月4日
cyzyimao LV8
2015年3月4日
mj19910923 LV14
2015年3月4日
wfghefg LV6
2015年3月4日
雨、小雨 LV8
2015年3月4日
lg906321 LV9
2015年3月4日
cwk1 LV1
2015年3月3日