我正在编写以下用于视频转换的代码,但是输出视频中没有音频。
public static void convert(File file) {
FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(file.getAbsolutePath());
IplImage captured_frame = null;
FFmpegFrameRecorder recorder = null;
recorder = new FFmpegFrameRecorder(file.getAbsolutePath().replace(".mp4", "_edited.mp4"), FFMPEGRecorderActivity.VIDEO_WIDTH, FFMPEGRecorderActivity.VIDEO_HEIGHT);
recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
recorder.setFormat("mp4");
recorder.setFrameRate(FFMPEGRecorderActivity.VIDEO_FRAME_RATE);
recorder.setAudioChannels(frameGrabber.getAudioChannels());
recorder.setSampleRate(FFMPEGRecorderActivity.AUDIO_SAMPLE_RATE_HZ);
try {
recorder.start();
frameGrabber.start();
while (true) {
try {
captured_frame = frameGrabber.grab();
if (captured_frame == null) {
System.out.println("!!! Failed cvQueryFrame");
break;
}
recorder.setTimestamp(frameGrabber.getTimestamp());
recorder.record(captured_frame);
} catch (Exception e) {
}
}
recorder.stop();
recorder.release();
} catch (Exception e) {
e.printStackTrace();
}
}
如何从输入文件中获取音频并使用输出文件进行放置。