Java FFMPEG-Process Builder格式

时间:2019-04-26 14:37:13

标签: java ffmpeg process builder

我需要使用Java Process Builder执行ffmpeg命令,我发现this对格式化的某些部分有所帮助,但现在需要能够解决这一问题:

ffmpeg -i in.mp4 -af astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level:file=log.txt -f null -

我希望它将采用以下形式:

 "-i", inputFile, "-ss", String.valueOf(peakVolPoint(logLocation)), "-vframes", "1", outputFile

,看起来可能与此类似:

"-i", inputFile ,"-af", "astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level:file=C:\\newlog.txt" ,"-f", "null", "-"

但需要帮助。

这是我的代码:

主要:

ffmpeg(ffmpeg_path, "-i", inputFile ,"-af", "astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level:file=C:\\newlog.txt" ,"-f", "null", "-");

功能:

    public static String ffmpeg(String... strings) throws IOException {
        List<String> params = Arrays.asList(strings);

        Process processDuration = new ProcessBuilder(params).redirectErrorStream(true).start();
        StringBuilder strBuild = new StringBuilder();
        try (BufferedReader processOutputReader = new BufferedReader(
                new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()));) {
            String line;
            while ((line = processOutputReader.readLine()) != null) {
                strBuild.append(line + System.lineSeparator());
            }
            try {
                processDuration.waitFor();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        String outputJson = strBuild.toString().trim();
        System.out.println(outputJson);
        return outputJson;

谢谢!

0 个答案:

没有答案