Boas, estou a tentar fazer um método que corte um certo pedaço do video.
Tentei fazer desta forma:
public void cortar(File file, int segundos) throws FileNotFoundException, IOException, InterruptedException {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(file);
os = new FileOutputStream(new File("..."));
byte[] buffer = new byte[1024];
int length;
int total = 0;
while ((length = is.read(buffer)) > 0 && total < is.available() / 2) {
os.write(buffer, 0, length);
total += length;
}
} finally {
is.close();
os.close();
}
}
Porém o ficheiro gerado continua a mostrar o tamanho total do video, mas termina na metade, como se o video tivesse corrompido. Se tentar cortar o video pelo inicio (exemplo começar no segundo 2), o video fica inteiramente corrompido.
Existe alguma forma melhor de fazer isso?