Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.wpzwmcom:JavaAV:'
}
dependencies {
implementation("com.github.wpzwmcom:JavaAV:")
}
<dependency>
<groupId>com.github.wpzwmcom</groupId>
<artifactId>JavaAV</artifactId>
<version></version>
</dependency>
libraryDependencies += "com.github.wpzwmcom" % "JavaAV" % ""
:dependencies [[com.github.wpzwmcom/JavaAV ""]]
The aim of this project is to provide an easy to use interface to FFmpeg. This project is not command line based like many others do. In addition JavaAV is easily maintainable. First, the native FFmpeg library is accessed through JNI. There is no other extra layer of native code like in Xuggler. Second, all the JNI classes are automatically generated with JavaCPP. Even the compilation into native code is controlled by JavaCPP. This way there is less effort to react to new FFmpeg updates. To improve JavaAV or fix bugs you do not need to touch the native code.
Below some code snippets are shown to demonstrate the API usage. For more complete code see the examples section.
Enumerate installed codecs (each string contains name, type and description):
String[] codecs = Codec.getInstalledCodecs();
Create and use a real-time video encoder:
Options options = new Options();
options.put("tune", "zerolatency");
options.put("preset", "ultrafast");
Encoder encoder = new Encoder(CodecID.H264);
encoder.setPixelFormat(PixelFormat.YUV420P);
encoder.setImageWidth(1280);
encoder.setImageHeight(720);
encoder.setGOPSize(25);
encoder.setBitrate(2000000);
encoder.setFramerate(25);
encoder.open(options);
BufferedImage image = ...;
VideoFrame frame = VideoFrame.create(image);
MediaPacket packet = encoder.encodeVideo(frame);
... send packet over a network, write it to a file or whatever
encoder.close();
Below is the list of some basic examples. All examples can be found in the projects src/examples folder.
For those who use Maven may include this project as dependency:
<dependency>
<groupId>com.github.hoary</groupId>
<artifactId>JavaAV</artifactId>
<version>0.5</version>
</dependency>
You can also download JavaAV manually. In doing so, JavaAV and the necessary dependencies must be added to the classpath.