0

入力でビデオを指定すると、秒単位で画像のセットを生成するJava関数を作成しようとしています。これまでのところ、これは私が持っているものです:

public static void decodeAndCaptureFrames(String inputfilename, String outputfolder, int width, int height, double seconds) スロー InputFormatException, EncoderException { double duration = getVideoLenght(inputfilename); int インデックス = 0;

    Runtime runtime = Runtime.getRuntime();
    for(double s = 0; s < duration; s+= seconds)
    {
        String outString = outputfolder + File.separator + index + ".png";
        String cmd = "ffmpeg.exe -i "+ inputfilename +" -f image2 -t 0.001 -ss "+ s +" -s "+ width +"x"+ height +" "+outString;

        try {
            Process p = runtime.exec(cmd);
            p.waitFor()
        } catch (IOException e) {
            System.out.println("problema nell'esecuzione del runtime.exec");
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println(cmd);
        index++;
    }   
}

ただし、コードは非常に遅く、さらに画像を印刷しても最初の 2 つの画像しか変換されません。この外部 exe を使用しているので、ランタイムとプロセスに問題があるかどうか誰か教えてもらえますか? ありがとう。

4

0 に答える 0