How to merge two videos in java(怎么用java合并两个视频文件)?

marttinli 2015-09-30 09:44:16
我的代码如下,合并后出现问题描述:
合并了三个12M的文件,合并完了后大小为40M,但是呢,视频内容完全是第二个视频的内容,并没有达到合并的效果,望高手指点:

	@SuppressWarnings("unused")
public void union(String path, String newString) throws Exception {
File file = new File(path);
if (file!=null) {
File list[] = file.listFiles();
File newFile = new File(newString);
if(newFile!=null ){
if (newFile.delete()) {
newFile = new File(newString);
System.out.println("删除源文件成功");
}
}
byte buffer[] = new byte[1024];
int readcount;
if (!newFile.getParentFile().exists())
throw new Exception("你合并的文件夹的不存在...");
FileOutputStream writer = new FileOutputStream(newString);

for (File f : list) {
FileInputStream reader = new FileInputStream(f);
while ((readcount = reader.read(buffer)) != -1) {
writer.write(buffer);
}
System.out.println("count "+f.getName());
reader.close();
}
writer.close();
}else {
throw new Exception("file null");
}
}
...全文
157 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony4geek 2015-09-30
  • 打赏
  • 举报
回复
media-for-mobile 这个是手机的可以参考 http://stackoverflow.com/questions/26401514/merge-multiple-video-file-in-a-file
tony4geek 2015-09-30
  • 打赏
  • 举报
回复
mp4parser 吧 在墙外

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧