我正在使用JavaCV Api的ffmpegFrameRecorder将几个mp4视频合并为一个。这是我的代码:
FrameGrabber grabberlist[] = new FFmpegFrameGrabber[filenamelist
.size()];
for (int i = 0; i < grabberlist.length; i++) {
System.out.println("FILES" + filenamelist.get(i));
grabberlist[i] = new FFmpegFrameGrabber(filenamelist.get(i));
grabberlist[i].start();
}
FrameRecorder recorder = new FFmpegFrameRecorder(
Environment.getExternalStorageDirectory()
+ "/Apptavia/output.mp4",
grabberlist[0].getImageWidth(),
grabberlist[0].getImageHeight(), 1);
recorder.start();
for (int i = 0; i < grabberlist.length; i++) {
Frame frame;
while ((frame = grabberlist[i].grabFrame()) != null) {
recorder.record(frame);
}
}
for (int i = 0; i < audioList.size(); i++) {
recorder.record(audioList.get(i));
}
recorder.stop();
for (int i = 0; i < grabberlist.length; i++) {
grabberlist[i].stop();
}
}
创建输出视频但视频长度较短。我调试了.grab()方法的帧数小于总帧数。什么可以解决这个问题。请帮忙。