我正在创建应用程序来更改 android 中视频文件的音频。我尝试了下面的代码。感谢你的帮助。
try {
FrameGrabber grabber1 = new FFmpegFrameGrabber(videoPath);
FrameGrabber grabber2 = new FFmpegFrameGrabber(audioPath);
grabber1.start();
grabber2.start();
FrameRecorder recorder = new FFmpegFrameRecorder(OutputPath,
grabber1.getImageWidth(), grabber1.getImageHeight(), 2);
recorder.setFormat("mp4");
recorder.setVideoQuality(1);
recorder.setFrameRate(grabber1.getFrameRate());
recorder.setSampleRate(grabber2.getSampleRate());
recorder.start();
Frame frame1, frame2 = null;
long timestamp = -2;
int count = 0;
boolean isFirstTime = false;
boolean isFirstCheck = true;
while ((frame1 = grabber1.grabFrame())!=null) {
//frame1 = grabber1.grabFrame();
frame2 = grabber2.grabFrame();
recorder.record(frame1);
recorder.record(frame2);
}
recorder.stop();
grabber1.stop();
grabber2.stop();
}catch(Exception e){}