It's possible to use org.bytedeco wrappers for FFmpeg and FFplay.
Add the dependency for the core artifact and also for your target operating system (supported OSes can be seen here):
// The main artifact
implementation("org.bytedeco:ffmpeg:7.1-1.5.11")
// The Jar artifact with FFmpeg and FFprobe executables for the desired OS
implementation("org.bytedeco:ffmpeg:7.1-1.5.11:windows-x86_64-gpl")
Then, to execute FFmpeg in Java:
import org.bytedeco.ffmpeg.ffmpeg;
import org.bytedeco.javacpp.Loader;
public class Test {
private final String ffmpegPath = Loader.load(ffmpeg.class);
public void exampleFFmpeg() throws IOException {
var ffmpegProcess = new ProcessBuilder()
.command(
ffmpegPath,
// OR any options you would pass to FFmpeg CLI
"-i", "/absolute/path/to/a/video.mp4"
)
.start();
}
}
To execute FFmpeg in Kotlin:
import org.bytedeco.ffmpeg.ffmpeg
import org.bytedeco.javacpp.Loader
class Test() {
private val ffmpegPath = Loader.load(ffmpeg::class.java)
fun exampleFFmpeg() {
ProcessBuilder()
.command(ffmpegPath, "-i", "/absolute/path/to/video.mp4")
.runCatching { start() }
.onFailure { println("Starting the FFmpeg process failed") }
}
}