Skip to content

Commit

Permalink
Update README.md with error management.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Kelleher committed Jan 31, 2022
1 parent 0186c42 commit 12bac01
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Inspired by [ffmpeg-cli-wrapper](https://github.com/bramp/ffmpeg-cli-wrapper)

## Checking media streams with ffprobe

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

```java
FFprobeResult result = FFprobe.atPath()
Expand All @@ -60,7 +60,7 @@ for (Stream stream : result.getStreams()) {

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

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

```java
final AtomicLong durationMillis = new AtomicLong();
Expand All @@ -83,7 +83,7 @@ System.out.println("Exact duration: " + durationMillis.get() + " milliseconds");

## Re-encode and track progress

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

```java
final AtomicLong duration = new AtomicLong();
Expand Down Expand Up @@ -118,7 +118,7 @@ FFmpeg.atPath()

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

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

```java
FFmpeg.atPath()
Expand All @@ -139,7 +139,7 @@ FFmpeg.atPath()

## Custom parsing of ffmpeg output

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

```java
// StringBuffer - because it's thread safe
Expand All @@ -165,7 +165,7 @@ System.out.println("Loudnorm report:\n" + loudnormReport);
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.

See whole example [here](/src/test/java/examples/UsingChannelsExample.java).
See whole example [here](src/test/java/examples/UsingChannelsExample.java).
```java
try (SeekableByteChannel inputChannel =
Files.newByteChannel(pathToSrc, StandardOpenOption.READ);
Expand All @@ -188,7 +188,7 @@ requires seekable output for many formats.

Under the hood pipes are not OS pipes, but TCP Sockets. This allows much higher bandwidth.

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

```java
try (InputStream inputStream =
Expand All @@ -209,7 +209,7 @@ try (InputStream inputStream =

## Screen Capture

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

```java
FFmpeg.atPath()
Expand Down Expand Up @@ -239,8 +239,8 @@ Files.move(pathToOptimized, pathToVideo, StandardCopyOption.REPLACE_EXISTING);

## 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
See whole example [here](src/test/java/examples/ProduceVideoExample.java).
Check also more [advanced example](src/test/java/examples/BouncingBallExample.java) which produce
both audio and video

```java
Expand Down Expand Up @@ -283,11 +283,11 @@ FFmpeg.atPath()

Here is an output of the above example:

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

### Consume Video in Pure Java Code

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

```java
FFmpeg.atPath()
Expand Down Expand Up @@ -333,10 +333,28 @@ FFmpeg.atPath()
.execute();
```

## Managing errors

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

In some cases an error can occur but FFmpeg manages to catch it and exit correctly. This can be a
convenient case, although sometimes one would prefer an exception to be raised to Jaffree.

To do so, the [`-xerror`](https://ffmpeg.org/ffmpeg.html#Advanced-options) argument can be used to
tell FFmpeg to exit the process with an error status when an error occurs.

```java
FFmpeg.atPath()
.addArgument("-xerror")
// ...
```

Please see [Issue 276](https://github.com/kokorin/Jaffree/issues/276) for more details on an actual
usecase.

## FFmpeg stop

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

### Grace stop

Expand Down Expand Up @@ -398,7 +416,7 @@ thread.interrupt();

## Java 8 Completion API

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

```java
ffmpeg.executeAsync().toCompletableFuture()
Expand Down Expand Up @@ -500,7 +518,7 @@ FFmpegResult result = FFmpeg.atPath(BIN)
## 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).
You can find details in Mosaic [example](src/test/java/examples/MosaicExample.java).

# Build & configuration

Expand Down

0 comments on commit 12bac01

Please sign in to comment.