如何通过命令行参数使用Java将-movflag选项传递给xuggler API?

时间:2014-05-19 12:22:26

标签: java xuggler

我正在使用xuggler API来压缩视频文件。我可以使用以下代码成功压缩视频文件:

//These are the arguments to pass to the converter object.
//For H264 transcoding, the -vpreset option is very
//important. Here, presetsFile is a File object corresponding
//to a libx264 video presets file. These are in the
// /usr/local/share/ffmpeg directory.
String[] arguments = {
    inputFile.getAbsolutePath(),
    "-acodec", "libfaac",
    "-asamplerate", "44100",
    "-vcodec", "libx264",
    "-vpreset", presetsFile.getAbsolutePath(),
    inputFile.getParent() + "/" + inputFile.getName() + ".mp4"
}

try {
    //Finally, we run the transcoder with the options we provided.
    converter.run(
        converter.parseOptions(
             converter.defineOptions(), arguments)
    );
} catch (Exception e) {
    e.printStackTrace();
}

但是根据要求我需要传递-movflag选项和上面的参数,如下所示:

String[] arguments = { 
    inputFile.getAbsolutePath(),
    "-acodec", "libvo_aacenc",
    "-asamplerate", "44100",
    "-vcodec", "libx264",
    "-movflags","faststart",
    "-vpreset", 
    presetsFile.getAbsolutePath(),
    inputFile.getParent() + "/" 
        + inputFile.getName() +"aaa.mp4"
};

但它给了我以下错误:

org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -movflags
  at org.apache.commons.cli.Parser.processOption(Parser.java:379)
  at org.apache.commons.cli.Parser.parse(Parser.java:193)
  at org.apache.commons.cli.Parser.parse(Parser.java:71)
  at com.nfl.mobile.VideoCompress.Converter.parseOptions(Converter.java:334)
  at com.nfl.mobile.xoggler.Simpleh264Transcoder.transcode(Simpleh264Transcoder.java:39)
  at com.nfl.mobile.xoggler.Simpleh264Transcoder.main(Simpleh264Transcoder.java:24)

我做错了什么?

0 个答案:

没有答案