How to merge audio and video in Java

kashif181 picture kashif181 · Aug 4, 2012 · Viewed 8.2k times · Source

We have created an application that records web camera streams using Xuggler, but video and audio are separated.

We need to merge, not concatenate, these two files.

How can this be done in Java?

Answer

arslaan ejaz picture arslaan ejaz · Aug 6, 2012

If you have audio and video file then you can merge them to a single audio video file using FFmpeg:

  1. Download FFmpeg: http://ffmpeg.zeranoe.com/builds/
  2. Extract downloaded file to specific folder, say c:\ffmpeffolder
  3. Using cmd move to specific folder c:\ffmpeffolder\bin
  4. Run following command: $ ffmpeg -i audioInput.mp3 -i videoInput.avi -acodec copy -vcodec copy outputFile.avi This is it. outputFile.avi will be the resulting file.