我正在尝试合并音频和视频文件。音频和视频文件的长度相同,但在输出视频文件音频完成合并过程后仅播放3-4秒,而音频和视频文件长度为14秒。请帮我解释为什么音频不能在输出文件中完全播放。
String OutputPath = path + outputVideo;
try {
FrameGrabber grabber1 = new FFmpegFrameGrabber(videoFile);
FrameGrabber grabber2 = new FFmpegFrameGrabber(audioFile);
grabber1.start();
grabber2.start();
FrameRecorder recorder = new FFmpegFrameRecorder(OutputPath,
grabber1.getImageWidth(), grabber1.getImageHeight(),2);
recorder.setFormat(grabber1.getFormat());
recorder.setVideoQuality(1);
recorder.setFrameRate(grabber1.getFrameRate());
recorder.setSampleRate(grabber2.getSampleRate());
recorder.start();
Frame frame1, frame2;
while ((frame1 = grabber1.grabFrame()) != null &&
(frame2 = grabber2.grabFrame()) != null) {
recorder.record(frame1);
recorder.record(frame2);
}
recorder.stop();
grabber1.stop();
grabber2.stop();
} catch (FrameGrabber.Exception e) {
e.printStackTrace();
} catch (FrameRecorder.Exception e) {
e.printStackTrace();
}