Java FFmpeg no output



我遇到了问题。我想使用 ffmpeg 转换视频,但它没有给我输出

public void convert(String inputFile, String outputFile, String ... optionalParams) {
    ProcessBuilder processBuilder = new ProcessBuilder("ffmpeg", "-i", """ + inputFile.trim() +""", """+ outputFile.trim() + """);
    DownloadRecord downloadRecord = table.getItems().get(0);
    downloadRecord.setStatus("Downloading");
       // Try to execute process
       try {
           // Set the working directory
           processBuilder.directory(new File(workingDirectory));
           //Start the process
           Process process = processBuilder.start();
           // Read the output from cmd
           BufferedReader r = new BufferedReader(new InputStreamReader(process.getInputStream()));
           BufferedReader ra = new BufferedReader(new InputStreamReader(process.getErrorStream()));
           String line;
           String errline;
           while ((line = r.readLine()) != null) {
                System.out.println(line);
           }
           while ((errline = ra.readLine()) != null) {
                System.out.println(errline);
           }
           process.waitFor();
           System.out.println("the end");
       } catch(IOException | InterruptedException e) {
           System.out.println(e.toString());
       }
}

我一直在搜索堆栈溢出并找到一些解决方案,但没有一个奏效。到目前为止我尝试并弄清楚了什么

  • 无输出或错误输出
  • 我试图从进程生成器中删除反斜杠,它也没有给我输出
  • 我试图让程序运行,但它从未完成
  • 我尝试使用ffmpeg的完整路径,没有变化
  • 我尝试运行视频,没有错误
  • 我正在使用Netbeans IDE,所以我尝试了清理和重建项目,没有变化
  • 过程也永远不会完成

我想从中输出。有人知道我在这里做错了什么吗?

我通过重新安装ffmpeg来修复它。刚刚去了ffmpeg网站下载了最新版本,替换了文件夹中的文件,它可以工作

编辑:由于某种原因,它仅适用于少于 2 分钟的文件,超过 2 分钟的文件的行为是这样的我开始转换,直到程序运行它才会完全转换。退出程序后,它将完成。这是奇怪的行为。

最新更新