How can I merge .webm (Audio) file and a .mp4 (Video) file using java?

14,860

This could be achieved by using ffmpeg C library via JNI or via executing ffmpeg command line binaries.

Here are the steps for command line execution:

  1. Download FFmpeg: http://ffmpeg.org/download.html . You Can download the source from the repository and build them as per your machine architecture.

  2. Extract downloaded file to specific folder, say c:\ffmpeffolder Using cmd move to specific folder c:\ffmpeffolder\bin

  3. Run following command: $ ffmpeg -i audioInput.webm -i videoInput.mp4 -acodec copy -vcodec copy outputFile.avi

Command line Execution from Java: https://stackoverflow.com/a/8496537/2900034

This is it. outputFile.avi will be the resulting file.

Or if you want to work around ffmpeg C libraries

Here are some good starts.

  1. JNI.
  2. ffmpeg api example.
Share:
14,860
user2136160
Author by

user2136160

Updated on July 28, 2022

Comments

  • user2136160
    user2136160 almost 2 years

    I have two files one is a .webm audio file and the other one is a .mp4 video file Is there a way to combine these two files together using java?

    Thanks in advance.