Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

whenever I run ffmpeg -i filename it returns something like this:

  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

Except when I run it from java using:

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();
    }

it gives me this:

      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

Can anybody tell me what I am doing wrong?

share|improve this question

2 Answers 2

You are not giving the right command line options to the program.

ProcessBuilder takes a list of strings, so you need to split them out:

new ProcessBuilder("ffmpeg", "-i", "filename");
share|improve this answer
    
execS is a String[] containing: "ffmpeg", "-i", "filename". –  AUser Oct 16 '13 at 21:30

Try to create a new thread and process the error stream of the Process simultaneously; p.getErrorStream()

FFMPEG sends a lot of its data to the error stream; and by not processing it the error InputStream buffer fills up there, which then hangs the FFMPEG process until its read.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.