-1

我正在创建应用程序来更改 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){}
4

1 回答 1

0

您可以查看exoplayer,它允许您自定义音频输入流和视频输入流。它由谷歌开源,you-tube 和 google play 电影等应用程序使用它。

于 2016-03-21T08:53:05.890 回答