1

私はバーハンです。ビデオを ffmpg でフレームに分割しようとしましたが、問題が発生しました。アプリケーションを閉じる前に、画像がフォルダに表示されませんでした。これは私のコードです:

public void SplitVideo(String lokasi) {
try {
    //excecute cmd
    String cmd = "c:\\ff\\bin\\ffmpeg.exe -i " + lokasi + " -y -f image2 c:\\vid\\img-%07d.jpg";
    Process jalan = Runtime.getRuntime().exec(cmd);
    // Get output stream to write from it
    OutputStream keluaran = jalan.getOutputStream();
    System.out.println(keluaran);
} catch (IOException e) {
    System.out.println(e);
}}

私はJavaを使用しています。私の問題について教えてください。

4

2 に答える 2

0

出力ストリームをフラッシュ/クローズするようにしてください。それは動作するはずです:

public void SplitVideo(String lokasi) {
try {
    //excecute cmd
    String cmd = "c:\\ff\\bin\\ffmpeg.exe -i " + lokasi + " -y -f image2 c:\\vid\\img-%07d.jpg";
    Process jalan = Runtime.getRuntime().exec(cmd);
    // Get output stream to write from it
    OutputStream keluaran = jalan.getOutputStream();
    System.out.println(keluaran);
    keluaran.flush();
   keluaran.close(); 
} catch (IOException e) {
    System.out.println(e);
}

}

Flush は基本的にこの出力ストリームをフラッシュし、バッファリングされた出力バイトを強制的に書き出させます。ここでもっと読む:

http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html#flush()

于 2013-06-23T00:24:52.330 に答える