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.0zi:jcodec:0.2.0-vg4'
}
dependencies {
implementation("com.github.0zi:jcodec:0.2.0-vg4")
}
<dependency>
<groupId>com.github.0zi</groupId>
<artifactId>jcodec</artifactId>
<version>0.2.0-vg4</version>
</dependency>
libraryDependencies += "com.github.0zi" % "jcodec" % "0.2.0-vg4"
:dependencies [[com.github.0zi/jcodec "0.2.0-vg4"]]
The intention behind this is the need of the bleeding edge build, because it seems like vg4 is not edgy enough for me(56 commits behind), please don't rely on this fork, there no guarantee that it would be stable, it's been forked just for my purposes
The SequenceEncoder8Bit does not give the correct output, consider using version 0.1.9
Add to your root build.gradle:
allprojects {
repositories {
// ...
maven { url "https://jitpack.io" }
}
}
In the app level build.gradle add the following dependency:
dependencies {
compile 'com.github.0zi:jcodec:0.2.0-c'
}
Note: The letter "C" in the version name stands for the word "Current"
jcodec - a pure java implementation of video/audio codecs.
JCodec is a library implementing a set of popular video and audio codecs. Currently JCodec supports:
Video
Audio
Wrappers ( muxers, demuxers, formats ):
JCodec is free software distributed under FreeBSD License.
Those are just some of the things JCodec dev team is planning to work on:
Build from the source and include both JARs (jcodec.jar and jcodec-javase.jar) in your projects. Alternatively, obsolete versions can be included automatically with maven. For this just add below snippet to your pom.xml-
<dependency>
<groupId>org.jcodec</groupId>
<artifactId>jcodec-javase</artifactId>
<version>0.1.9</version>
</dependency>
OR download it from here (you will need both jars):
There is virtually no documentation right now but the plan is to catch up on this so stay tuned. stackoverflow.com contains quite a bit information at this point. Also check the 'samples' subfolder. It's a maven project, and it contains some code samples for the popular use-cases:
Getting a single frame from a movie ( supports only AVC, H.264 in MP4, ISO BMF, Quicktime container ):
int frameNumber = 150;
BufferedImage frame = AWTFrameGrab8Bit.getFrame(new File("filename.mp4"), frameNumber);
ImageIO.write(frame, "png", new File("frame_150.png"));
Getting a sequence of frames from a movie ( supports only AVC, H.264 in MP4, ISO BMF, Quicktime container ):
double startSec = 51.632;
int frameCount = 10;
FileChannelWrapper ch = null;
try {
ch = NIOUtils.readableChannel(new File("filename.mp4"));
AWTFrameGrab8Bit fg = AWTFrameGrab8Bit.createAWTFrameGrab8Bit(ch);
fg.seekToSecondPrecise(startSec);
for (int i = 0; i < frameCount; i++) {
BufferedImage frameImage = grab.getFrame();
if (frameImage != null) {
ImageIO.write(grab.getFrame(), "png",
new File(System.getProperty("user.home"), String.format("Desktop/frame_%08d.png", i)));
} else break;
}
} finally {
NIOUtils.closeQuietly(ch);
}
Feel free to communicate any questions or concerns to us. Dev team email: jcodecproject@gmail.com