Android で基本的なビデオ エディターを構築しようとしています。これは、複数のビデオ ファイルを取得し、それらを 1 つのビデオ ファイルに次々と書き込むだけです。小さなクリップをすべて取得して書き込むループを作成しようとしました。 1つの大きなファイルに変換しますが、これにより、すべてのファイルを大きなビデオに書き込む代わりに、破損したファイルが1つしか得られません。どうすればこれを実現できますか? 以下は私がこれを行うために書いた私のコードです。
File[] files = tempDirectory.listFiles();
if (files != null) {
try {
for (File f : files) {
FileOutputStream fileOutput = new FileOutputStream(assembleFile);
InputStream is = new FileInputStream(f);
byte[] buffer = new byte[1024];
int bufferLength = 0;
while ((bufferLength = is.read(buffer)) > 0) {
// add the data in the buffer to the file in the file
// output
// stream (the file on the sd card
fileOutput.write(buffer, 0, bufferLength);
}
// close the output stream when done
fileOutput.close();
is.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}