8

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.

cprakashagr
  • 751
  • 11
  • 28
user2136160
  • 235
  • 2
  • 5
  • 13

1 Answers1

21

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.
Community
  • 1
  • 1
cprakashagr
  • 751
  • 11
  • 28