Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 947
user2136160 Avatar asked Mar 11 '16 11:03

user2136160


1 Answers

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.
like image 71
cprakashagr Avatar answered Oct 18 '22 09:10

cprakashagr