Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:metaloom/video4j
Browse files Browse the repository at this point in the history
  • Loading branch information
Jotschi committed Feb 5, 2023
2 parents dd0e2b7 + 720c89f commit 7313885
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 81 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.settings
target
/out
.vscode
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Video4j is a highlevel library ontop of `org.openpnp:opencv` which provides APIs
<dependency>
<groupId>io.metaloom.video</groupId>
<artifactId>video4j</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```

Expand All @@ -30,7 +30,7 @@ try (Video video = Videos.open(BIG_BUCK_BUNNY2_PATH)) {
video.fps();

// Total frames of the video
video.length()
video.length();

// Seek to specific frame
video.seekToFrame(1020);
Expand All @@ -48,7 +48,7 @@ try (Video video = Videos.open(BIG_BUCK_BUNNY2_PATH)) {
BufferedImage image = video.frameToImage();

// Read the frame and resize it to a width of 256 pixel.
BufferdImage image2 = video.boxedFrameToImage(256);
BufferedImage image2 = video.boxedFrameToImage(256);

// Display the frame in a window
ImageUtils.show(image);
Expand Down Expand Up @@ -158,13 +158,25 @@ while (true) {

## Requirements / Limitations

The library uses OpenCV via JNI. Thus the JNI library `libopencv4.5-jni` must be installed on the host system.
The library uses OpenCV via JNI. Thus the JNI library `libopencv406-jni` must be installed on the host system.
Currently only Linux is supported.

The JNI libraries need to be manually be loaded once via
```Video4j.init()```. This method will try its best to locate the library itself.

On Debian Linux the JNI library can be installed via the `libopencv4.5-jni` package. Version `4.5.1+dfsg-5` has been used for testing. Video4j expects the library to be locatable in the library path. Or via `/usr/lib/jni/libopencv_java451.so`.
You can set `-Djava.library.path` for your application if the `libopencv_java451.so` file is located in a different directory.
On Debian Linux the JNI library can be installed via the `libopencv406-jni` package. Version `4.6.0+dfsg-9+b1` has been used for testing. Video4j expects the library to be locatable in the library path. Or via `/usr/lib/jni/libopencv_java460.so`.
You can set `-Djava.library.path` for your application if the `libopencv_java460.so` file is located in a different directory.

The capabilities of the OpenCV code and thus this library is linked to the installed OpenCV library. If you are unable to open a specific video format this might be related to `libavcodec` library that was used to build the OpenCV library.
The capabilities of the OpenCV code and thus this library is linked to the installed OpenCV library. If you are unable to open a specific video format this might be related to `libavcodec` library that was used to build the OpenCV library.

## Releasing

```bash
# Run tests
mvn clean package
# Invoke release to maven central
mvn clean deploy -Drelease
# Publish release on github
jreleaser config
jreleaser full:release
```
5 changes: 2 additions & 3 deletions jreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project:
name: video4j
version: 1.1.0
version: 1.2.0
versionPattern: SEMVER

description: Video4j Java Video Processing Library
Expand All @@ -10,8 +10,7 @@ project:
authors:
- Johannes Schüth
license: Apache-2.0
extraProperties:
inceptionYear: 2022
inceptionYear: 2022

release:
github:
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.metaloom.video</groupId>
<artifactId>video4j</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>1.2.0</version>

<parent>
<groupId>io.metaloom</groupId>
Expand All @@ -30,7 +30,7 @@
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.5.1-2</version>
<version>4.6.0-0</version>
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
Expand Down Expand Up @@ -86,7 +86,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<release>11</release>
<release>17</release>
</configuration>
</plugin>
</plugins>
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/io/metaloom/video4j/Video.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static Video open(String path) {
/**
* Open the video.
*
* @return Fluent APOI
* @return Fluent API
*/
Video open();

Expand Down Expand Up @@ -141,6 +141,22 @@ static Video open(String path) {
*/
String path();

/**
* Return metadata for the video.
*
* @param <T>
* @return
*/
<T> T getMeta();

/**
* Set metadata for the video.
*
* @param <T>
* @param meta
*/
<T> void setMeta(T meta);

/**
* Return a stream of {@link Mat} frames for this video.
*
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/io/metaloom/video4j/impl/VideoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ public class VideoImpl implements Video {

private final String path;
private final ExtendedVideoCapture capture;
private Object meta;

public VideoImpl(String path, ExtendedVideoCapture capture) {
this.path = path;
this.capture = capture;
}

public Video open() {
capture.open(path);
if (!capture.open(path)) {
throw new RuntimeException("Video " + path + " could not be opened.");
}
return this;
}

Expand Down Expand Up @@ -76,6 +79,17 @@ public int width() {
return capture.width();
}

@Override
@SuppressWarnings("unchecked")
public <T> T getMeta() {
return (T) meta;
}

@Override
public <T> void setMeta(T meta) {
this.meta = meta;
}

@Override
public void seekToFrame(long frame) {
assertOpen();
Expand Down
Loading

0 comments on commit 7313885

Please sign in to comment.