linuxmencoder

mencoder :java.io.IOException: error=2, No such file or directory


i want to tansform 1.rmvb to avi with mencoder;

and the folder of /app/tongweb02/deployment/modules/cms-web/static/upload/video/origin/2015/03/03/ and /app/tongweb02/deployment/modules/cms-web/static/upload/video/flv/2015/03/03/ already exited,

java code

String getter = null;
String toAvi = "mencoder "
        + originPath
        + " -o "
        + aviPath
        + " -vf scale=320:240 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500";
try{
    ProcessBuilder builder = new ProcessBuilder();
    builder.command(toAvi);  
    builder.redirectErrorStream(true);  
    Process proc = builder.start();  
    BufferedReader stdout = new BufferedReader(  
            new InputStreamReader(proc.getInputStream()));  
    String line;  
    while ((line = stdout.readLine()) != null) { 
        getter += line + ",";
        if( getter != null )  
            System.out.println(line);  
    }  
    proc.waitFor();   
    stdout.close();  
}
catch (Exception e) {
    e.printStackTrace();
    return false;
}

It gives me following error:

[2015-03-03 15:23:37] [WARNING] [System.out] [java.io.IOException: Cannot run program "mencoder /app/tongweb02/deployment/modules/cms-web/static/upload/video/origin/2015/03/03/1.rmvb -o /app/tongweb02/deployment/modules/cms-web/static/upload/video/videoTemp/1425367417356.avi -vf scale=320:240 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500": java.io.IOException: error=2, No such file or directory]

Can anyone help me to solve the issue.


Solution

  • String getter = null;
                    String toAvi = "mencoder "
                            + originPath
                            + " -o "
                            + aviPath
                            + " -vf scale=320:240 -oac pcm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=500";
                    try{
                        Runtime rt = Runtime.getRuntime();
                        Process proc = rt.exec(toAvi);
                        BufferedReader stdout = new BufferedReader(  
                                new InputStreamReader(proc.getInputStream()));  
                        String line;  
                        while ((line = stdout.readLine()) != null) { 
                            getter += line + ",";
                            if( getter != null )  
                                System.out.println(line);  
                        }  
                        proc.waitFor();   
                        stdout.close();  
                    }
                    catch (Exception e) {
                        e.printStackTrace();
                        return false;
                    }
                    return true;