Reputation: 50298
I'm writing a Java program that will be used on both Windows and Mac. In the program, I'm using FFMPEG to convert a MOV file to an FLV. On Windows, it's no problem -- simply call the command. But on Mac, I'm not quite sure what to do. Does the user really have to install FFMPEG on their machine, or can it somehow be included in the Java application?
Thanks for any help/guidance!
Upvotes: 2
Views: 2087
Reputation: 31
I know this thread is very old but I figured I'd share my solution here in case anyone is still looking...
I added the following dependencies to my pom.xml
<!-- https://mvnrepository.com/artifact/org.bytedeco/ffmpeg -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg</artifactId>
<version>RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv-platform -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bytedeco/javacpp -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>RELEASE</version>
</dependency>
Then I use ProcessBuilder to execute FFMPEG commands. To merge audio and video, I use the following command:
String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
try {
ProcessBuilder pb = new ProcessBuilder(
ffmpeg,
"-i",
[PATH TO AUDIO FILE],
"-i",
[PATH TO VIDEO FILE],
"-acodec",
"copy",
"-vcodec",
"copy",
[PATH TO OUTPUT FILE]
);
pb.redirectErrorStream(true);
Process process = pb.start();
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
Upvotes: 2
Reputation: 1
I got the solution of this library and now it is working for both windows and Mac environment.
You need not to install any extra library of ffmpeg for mac this jar contains this. You can find the jar by dropping a mail to - [email protected].
Upvotes: 0
Reputation: 2505
You could also check out Xuggler, a Java wrapper for FFmpeg that works on Windows, Mac and Linux.
Upvotes: 2
Reputation: 494
If you are using the Java Media Framework (JMF), Fobs4JMF is a Java wrapper for FFMPEG that works as a JMF plugin.
Upvotes: 1
Reputation: 14159
Haven't played with it yet, but isn't FFMPEG availabe as a library? Then you could simply call it via JNI or better JNA. This should work on both platforms.
Upvotes: 1