首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过java got错误执行mp4box cmd

通过java got错误执行mp4box cmd
EN

Stack Overflow用户
提问于 2015-11-01 10:38:37
回答 1查看 418关注 0票数 0

对不起,当我标记ffmpeg时,因为我不能标记MP4Box.But,所以我也通过javacode执行了ffmpeg。我在How to execute cmd commands via Java读书,但找不到我的问题。

我在cmd中测试了命令,很好:

MP4Box -dash 10000 -dash-profile活动段-名称输出- seg -rap -bs-没有交换input.mp4

但是,当我通过java代码执行cmd时,我得到了错误:

错误-只有一个输入文件作为参数,请检查使用情况。

下面是我的代码,有什么问题吗?

代码语言:javascript
复制
package com.uit.reformatvideo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Logger;

public class ExecuteComandToFormatVideo {

    public final static String LINK_MP4BOX = "C:/MP4Box/Tools/MP4Box.exe";
    public final static String CREATE_MPD_ECLIPSE = "mp4box -dash 10000 -frag 1000 -rap -bs-switching no";
    public final static String CREATE_MPD_IE = "MP4Box -dash 10000 -dash-profile live -segment-name output-seg -rap -bs-switching no";
    private static final Logger log = Logger.getLogger(ExecuteComandToFormatVideo.class.getName());


    public static void main(String[] args) throws IOException, InterruptedException {
          String s = null;

            try {

            // run the Unix "ps -ef" command
                // using the Runtime exec method:
                String lsCmd[] = new String [2];
                lsCmd[0] = LINK_MP4BOX;
                lsCmd[1] = "MP4Box -dash 10000 -dash-profile live -segment-name output-seg -rap -bs-switching no input.mp4";
                Process p = Runtime.getRuntime().exec(lsCmd);
                p.waitFor();
                BufferedReader stdInput = new BufferedReader(new
                     InputStreamReader(p.getInputStream()));

                BufferedReader stdError = new BufferedReader(new
                     InputStreamReader(p.getErrorStream()));

                // read the output from the command
                System.out.println("Here is the standard output of the command:\n");
                while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
                }

                // read any errors from the attempted command
                System.out.println("Here is the standard error of the command (if any):\n");
                while ((s = stdError.readLine()) != null) {
                    System.out.println(s);
                }

                System.exit(0);
            }
            catch (IOException e) {
                System.out.println("exception happened - here's what I know: ");
                e.printStackTrace();
                System.exit(-1);
            }
    }

}

这里被发布了:

下面是命令的标准输出: 下面是命令的标准(如果有的话):Error -只有一个输入文件作为参数,请检查使用情况

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-06 10:09:06

对不起,因为我的英语很差。我创建了一个bat文件,其中包括命令,比如CMD,然后我使用Runtime.getRuntime().exec(url+name+".bat");来执行bat文件。这是我的解决方案。我的蝙蝠档案:

代码语言:javascript
复制
cd C:/MP4Box/Tools/
MP4Box
MP4Box -dash 10000 -dash-profile live -segment-name output-seg -rap -bs-switching no "C:\Users\ducth\Desktop\New folder (2)\SharingVideo\src\main\webapp\resources\video\output.mp4"
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33461300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档