FFMpeg 元数据问题

FFMpeg 元数据问题

每当我运行时ffmpeg -i filename它都会返回如下内容:

  Metadata:
major_brand     : mp42
minor_version   : 0
compatible_brands: isommp42
creation_time   : 2010-07-16 18:33:45
Duration: 00:00:24.00, start: 0.000000, bitrate: 2443 kb/s
Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s
Metadata:
  creation_time   : 2010-07-16 18:33:45
  handler_name    : Mainconcept MP4 Sound Media Handler
Stream #0:1(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 2311 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc
Metadata:
  creation_time   : 2010-07-16 18:33:46
  handler_name    : Mainconcept MP4 Video Media Handler

除非我使用以下命令从 Java 运行它:

ProcessBuilder pb = new ProcessBuilder(execS);
    pb.redirectErrorStream(true);
    try{
        Process p = pb.start();

        BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String bs = "";
        while(br.readLine() != null){
            bs += br.readLine();
            bs += "\n";
        }
        return bs;
    }catch(IOException e){
        e.printStackTrace();
    }

它给了我这个:

      built on Jun 17 2013 23:20:06 with gcc 4.6 (GCC)
  Metadata:
    minor_version   : 0
    creation_time   : 2010-07-16 18:33:45
    Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s
      creation_time   : 2010-07-16 18:33:45
    Stream #0:1(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 2311 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc
      creation_time   : 2010-07-16 18:33:46
At least one output file must be specified

谁能告诉我我做错了什么?

答案1

您没有向程序提供正确的命令行选项。

ProcessBuilder采用字符串列表,因此您需要将它们分离出来:

new ProcessBuilder("ffmpeg", "-i", "filename");

答案2

尝试创建一个新线程并同时处理Process的错误流;p.getErrorStream()

FFMPEG 将大量数据发送到错误流;如果不处理这些数据,错误 InputStream 缓冲区就会被填满,从而挂起 FFMPEG 进程直到读取为止。

相关内容