1.最近找这方面的博客比较少,然后就写个java参考代码,注意,换行一定要使用分号
/** * 执行Linux命令工具方法 * * @return 命令执行完之后返回值 * @throws IOException * @throws InterruptedException */ public static boolean execCommand(String url) { boolean isCope = false; try { String[] command = {"/bin/sh","-c","cd "+ url + ";ffmpeg -i input.ts -vcodec libx264 -acodec copy -max_muxing_queue_size 1024 -r 30 -crf 23 -preset veryfast index.mp4;"}; Runtime.getRuntime().exec(command).waitFor(); isCope = true; } catch (Exception e) { isCope = false; System.out.println("转MP4格式出错"); } return isCope; }