gpt4 book ai didi

java - 如何将多个视频文件一起写入以创建一个视频文件

转载 作者:行者123 更新时间:2023-12-01 04:37:41 25 4
gpt4 key购买 nike

我正在尝试在 Android 中构建一个基本的视频编辑器,它将获取多个视频文件,然后将它们一个接一个地写入一个视频文件,我尝试创建一个循环来获取所有较小的剪辑并将它们写入一个大文件,但这只会给我一个损坏的文件,而不是按照我希望的方式将所有文件写入更大的视频,我怎样才能实现这一点?下面是我为此编写的代码,任何帮助都会有很大帮助,谢谢

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();
}

}

最佳答案

您无法粘合期望生成单个工作视频的视频文件。尝试使用视频操作库,例如本问题中提到的库:Libraries / tutorials for manipulating video in java

关于java - 如何将多个视频文件一起写入以创建一个视频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17098810/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com