How to join one audio and video file — Xuggler

后端 未结 3 2053
后悔当初
后悔当初 2020-12-17 08:07

I want to combine a video file (flv) with no audio with an audio file (mp3) using Xuggler. At the moment I have taken two streams and combined the

3条回答
  •  一生所求
    2020-12-17 08:44

    I know this thread is very old but the provided solution did not work for me and I figured I'd share my solution here...

    I added the following dependencies to my pom.xml

    
       
           org.bytedeco
           ffmpeg
           RELEASE
       
    
       
       
           org.bytedeco
           javacv-platform
           RELEASE
       
    
       
       
           org.bytedeco
           javacpp
           RELEASE
       
    

    Then I use ProcessBuilder to execute FFMPEG commands. To merge audio and video, I use the following command:

    String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
        try {
            ProcessBuilder pb = new ProcessBuilder(
                    ffmpeg,
                    "-i",
                    [PATH TO AUDIO FILE],
                    "-i",
                    [PATH TO VIDEO FILE],
                    "-acodec",
                    "copy",
                    "-vcodec",
                    "copy",
                    [PATH TO OUTPUT FILE]
            );
            
            pb.redirectErrorStream(true);
            Process process = pb.start();
            process.waitFor();
    
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        } 
    

提交回复
热议问题