0

我有以下代码:

ProcessBuilder builder = new ProcessBuilder("C:\\file\\ffmpeg.exe", "-i", src);
builder.redirectErrorStream(true);
Process process = builder.start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
try {
   while ((br.readLine()) != null) {
      System.out.println(br.readLine() + "\n");
   }
} catch (IOException e) {
   e.printStackTrace();
}

现在这是输出:

使用 gcc 4.7.2 (GCC) 于 2013 年 3 月 22 日 08:56:38 构建

libavutil 52. 22.101 / 52. 22.101

libavformat 55. 0.100 / 55. 0.100

libavfilter 3. 48.100 / 3. 48.100

libswresample 0. 17.102 / 0. 17.102

输入 #0,avi,来自 'C:\Users\Olle\Desktop\file.avi':

编码器:Lavf52.104.0

流 #0:0:视频:mpeg4(简单配置文件)(DX50 / 0x30355844)、yuv420p、720x408 [SAR 1:1 DAR 30:17]、29.97 fps、29.97 tbr、29.97 tbn、30001 tbc

必须至少指定一个输出文件

当它应该输出更多(在常规命令行中输出更多)。

I don't understand what is going on. The weird thing is that when I compile the above code on Mac, it works fine. It's only in Windows I have this issue.

Even with:

String line = null;                     
try {
    while ((line = br.readLine()) != null) {
    line = br.readLine() + "\n";                            
    }

Same issue...

4

3 回答 3

5

with the br.readLine() in the while you skip every second line!

the code should be

String line = null; 
while ((line = br.readLine()) != null)
{
   System.out.println(line + "\n");
}
于 2013-04-07T19:30:02.490 回答
2

By making 2 calls to br.readLine() you can skipping one line. You need to assign value of br.readLine() to a string and print it.

于 2013-04-07T19:32:09.083 回答
0

Isn't the answer the output of your command?

At least one output file must be specified

According to this, you need to specify an output file as well.

于 2013-04-07T19:30:28.207 回答