如何使用 java 合并 .webm(音频)文件和 .mp4(视频)文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35939131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I merge .webm (Audio) file and a .mp4 (Video) file using java?
提问by user2136160
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?
我有两个文件,一个是 .webm 音频文件,另一个是 .mp4 视频文件有没有办法使用 java 将这两个文件组合在一起?
Thanks in advance.
提前致谢。
回答by cprakashagr
This could be achieved by using ffmpeg
C
library via JNI
or via executing ffmpeg
command line binaries.
这可以通过使用ffmpeg
C
库通过JNI
或通过执行ffmpeg
命令行二进制文件来实现。
Here are the steps for command line execution:
以下是命令行执行的步骤:
Download FFmpeg: http://ffmpeg.org/download.html. You Can download the source from the repositoryand build them as per your machine architecture.
Extract downloaded file to specific folder, say c:\ffmpeffolder Using cmd move to specific folder c:\ffmpeffolder\bin
- Run following command:
$ ffmpeg -i audioInput.webm -i videoInput.mp4 -acodec copy -vcodec copy outputFile.avi
下载 FFmpeg:http: //ffmpeg.org/download.html。您可以从存储库下载源代码并根据您的机器架构构建它们。
将下载的文件解压到特定文件夹,比如 c:\ffmpeffolder 使用 cmd 移动到特定文件夹 c:\ffmpeffolder\bin
- 运行以下命令:
$ ffmpeg -i audioInput.webm -i videoInput.mp4 -acodec copy -vcodec copy outputFile.avi
Command line Execution from Java: https://stackoverflow.com/a/8496537/2900034
Java 命令行执行:https: //stackoverflow.com/a/8496537/2900034
This is it. outputFile.avi will be the resulting file.
就是这个。outputFile.avi 将是结果文件。
Or if you want to work around ffmpeg C libraries
或者,如果您想解决 ffmpeg C 库
Here are some good starts.
这里有一些好的开始。