Skip to content

Commit

Permalink
chore: Small updates, preparing for Kotlin code
Browse files Browse the repository at this point in the history
  • Loading branch information
vemilyus committed Aug 4, 2023
1 parent ef59e8d commit ade80fc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

# jaffree

Jaffree stands for JAva FFmpeg and FFprobe FREE command line wrapper. Jaffree supports programmatic video production and consumption (with transparency)
Expand All @@ -13,6 +11,7 @@ Inspired by [ffmpeg-cli-wrapper](https://github.com/bramp/ffmpeg-cli-wrapper)
## Dependencies

- JDK 17
- FFmpeg 4+

## License

Expand All @@ -29,7 +28,7 @@ distributed under the GNU General Public License Version 3.

**JDK**: 17 (and soon 21)

# Usage
## Usage

[![Maven Central](https://img.shields.io/maven-central/v/io.v47.jaffree/jaffree.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.v47.jaffree%22%20AND%20a:%22jaffree%22)

Expand All @@ -41,9 +40,13 @@ distributed under the GNU General Public License Version 3.
</dependency>
```

# Examples
---

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

## Examples

## Checking media streams with ffprobe
### Checking media streams with ffprobe

See whole example [here](src/test/java/examples/ShowStreamsExample.java).

Expand All @@ -60,7 +63,7 @@ for (Stream stream : result.getStreams()) {
}
```

## Detecting exact media file duration
### Detecting exact media file duration

Sometimes ffprobe can't show exact duration, use ffmpeg trancoding to NULL output to get it.

Expand All @@ -85,7 +88,7 @@ FFmpegResult ffmpegResult = FFmpeg.atPath()
System.out.println("Exact duration: " + durationMillis.get() + " milliseconds");
```

## Re-encode and track progress
### Re-encode and track progress

See whole example [here](src/test/java/examples/ReEncodeExample.java).

Expand Down Expand Up @@ -118,7 +121,7 @@ FFmpeg.atPath()
.execute();
```

## Cut and scale media file
### Cut and scale media file

Pay attention that arguments related to Input must be set at Input, not at FFmpeg.

Expand All @@ -141,7 +144,7 @@ FFmpeg.atPath()
.execute();
```

## Custom parsing of ffmpeg output
### Custom parsing of ffmpeg output

See whole example [here](src/test/java/examples/ParsingOutputExample.java).

Expand All @@ -164,7 +167,7 @@ FFmpeg.atPath()
System.out.println("Loudnorm report:\n" + loudnormReport);
```

## Supplying and consuming data with SeekableByteChannel
### Supplying and consuming data with SeekableByteChannel

Ability to interact with SeekableByteChannel is one of the features, which distinct Jaffree from
similar libraries. Under the hood Jaffree uses tiny FTP server to interact with SeekableByteChannel.
Expand All @@ -185,7 +188,7 @@ try (SeekableByteChannel inputChannel =
}
```

## Supplying and consuming data with InputStream and OutputStream
### Supplying and consuming data with InputStream and OutputStream

**Notice** It's recommended to use `ChannelInput` & `ChannelOutput` since ffmpeg leverage seeking in input and
requires seekable output for many formats.
Expand All @@ -211,7 +214,7 @@ try (InputStream inputStream =
}
```

## Live Stream Re-Streaming (HLS)
### Live Stream Re-Streaming (HLS)

See whole example [here](src/test/java/examples/ReStreamWithHls.java).

Expand All @@ -236,7 +239,7 @@ FFmpeg.atPath()
.execute();
```

## Screen Capture
### Screen Capture

See whole example [here](src/test/java/examples/ScreenCaptureExample.java).

Expand Down Expand Up @@ -266,7 +269,7 @@ FFmpeg.atPath()
Files.move(pathToOptimized, pathToVideo, StandardCopyOption.REPLACE_EXISTING);
```

## Produce Video in Pure Java Code
### Produce Video in Pure Java Code

See whole example [here](src/test/java/examples/ProduceVideoExample.java).
Check also more [advanced example](src/test/java/examples/BouncingBallExample.java) which produce
Expand Down Expand Up @@ -314,7 +317,7 @@ Here is an output of the above example:

![example output](src/test/resources/examples/programmatic.gif)

### Consume Video in Pure Java Code
#### Consume Video in Pure Java Code

See whole example [here](src/test/java/examples/ExtractFramesExample.java).

Expand Down Expand Up @@ -362,7 +365,7 @@ FFmpeg.atPath()
.execute();
```

## Managing errors
### Managing errors

Jaffree will raise exceptions when a fatal error that causes a non-zero exit code occurs.

Expand All @@ -381,11 +384,11 @@ FFmpeg.atPath()
Please see [Issue 276](https://github.com/kokorin/Jaffree/issues/276) for more details on an actual
usecase.

## FFmpeg stop
### FFmpeg stop

See whole examples [here](src/test/java/examples/StopExample.java).

### Grace stop
#### Grace stop

Start ffmpeg with `FFmpeg#executeAsync` and stop it with `FFmpegResultFuture#graceStop` (ffmpeg only).
This will pass `q` symbol to ffmpeg's stdin.
Expand All @@ -399,7 +402,7 @@ Thread.sleep(5_000);
future.graceStop();
```

### Force stop
#### Force stop

There are 3 ways to stop ffmpeg forcefully.

Expand Down Expand Up @@ -443,7 +446,7 @@ Thread.sleep(5_000);
thread.interrupt();
```

## Java 8 Completion API
### Java 8 Completion API

See whole examples [here](src/test/java/examples/CompletionExample.java).

Expand All @@ -457,7 +460,7 @@ ffmpeg.executeAsync().toCompletableFuture()
});
```

## Complex Filtergraph (mosaic video)
### Complex Filtergraph (mosaic video)

More details about this example can be found on ffmpeg wiki:
[Create a mosaic out of several input videos](https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos)
Expand Down Expand Up @@ -544,7 +547,7 @@ FFmpegResult result = FFmpeg.atPath(BIN)
.execute();
```

## Programmatic mosaic video creation
### Programmatic mosaic video creation

Jaffree allows simultaneous reading from several sources (with one instance per every source and target).
You can find details in Mosaic [example](src/test/java/examples/MosaicExample.java).
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
commons-io = "2.13.0"
junitJupiter = "5.10.0"
kotlin = "1.9.0"
license = "0.6.1"
logback = "1.4.8"
maven-publish-ossrh = "1.5.0"
Expand All @@ -18,6 +19,7 @@ nanojson = { module = "com.grack:nanojson", version.ref = "nanojson" }
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }

[plugins]
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
license = { id = "org.cadixdev.licenser", version.ref = "license" }
mavenPublishOssrh = { id = "name.remal.maven-publish-ossrh", version.ref = "maven-publish-ossrh" }
release = { id = "net.researchgate.release", version.ref = "release" }
2 changes: 2 additions & 0 deletions src/main/java/com/github/kokorin/jaffree/ffprobe/Packet.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public Float getDurationTime() {
* @deprecated description from ffmpeg source code: this was required for Matroska subtitles,
* whose duration values could overflow when the duration field was still an int.
*/
@Deprecated
public Long getConvergenceDuration() {
return probeData.getLong("convergence_duration");
}
Expand All @@ -157,6 +158,7 @@ public Long getConvergenceDuration() {
* @deprecated description from ffmpeg source code: this was required for Matroska subtitles,
* whose duration values could overflow when the duration field was still an int.
*/
@Deprecated
public Float getConvergenceDurationTime() {
return probeData.getFloat("convergence_duration_time");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public final void run() {
*/
protected abstract void serve(Socket socket) throws IOException;

@SuppressWarnings("deprecation")
@Override
protected final void finalize() throws Throwable {
super.finalize();
Expand Down

0 comments on commit ade80fc

Please sign in to comment.