Skip to content

CompletableFuture doesn't raise exceptions for runtime errors #276

@vincentkelleher

Description

@vincentkelleher

Description

Errors happening after FFMpeg's startup don't raise exceptions.
FFMpeg startup errors are raised correctly.

Steps to reproduce

  1. Run an Nginx server with nginx-rtmp-module installed (such as the alfg/nginx-rtmp docker image)
  2. Run an FFMpeg process with the following command ffmpeg -f lavfi -i testsrc=size=1920x1080:rate=25 -f lavfi -i sine=f=1:b=2000 -shortest -f flv rtmp://localhost:1935/proxy/source
  3. Run the following test class
import com.github.kokorin.jaffree.StreamType;
import com.github.kokorin.jaffree.ffmpeg.FFmpeg;
import com.github.kokorin.jaffree.ffmpeg.UrlInput;
import com.github.kokorin.jaffree.ffmpeg.UrlOutput;

class TestClass {
    public static void main(String[] args) {
        FFmpeg.atPath()
              .addInput(UrlInput.fromUrl("rtmp://localhost:1935/hls/source"))
              .addOutput(UrlOutput.toUrl("rtmp://localhost:1935/hls/target")
                                  .setFormat("flv")
                                  .addMap(0, StreamType.AUDIO)
                                  .addMap(0, StreamType.VIDEO)
                                  .setCodec(StreamType.AUDIO, "copy")
                                  .setCodec(StreamType.VIDEO, "copy")
              )
              .executeAsync()
              .toCompletableFuture()
              .exceptionally(error -> {
                  System.err.println("An error has occured");
                  error.printStackTrace();

                  return null;
              })
              .join();
    }
}
  1. Stop the Nginx server

This error message will come up but no exception will be raised.

c.g.k.jaffree.ffmpeg.FFmpegResultReader : [error] rtmp://localhost:1935/hls/source: Input/output error

Expected behavior

An exception should be raised because this issue causes FFMpeg to be stopped.

Logs

c.g.k.jaffree.ffmpeg.FFmpegResultReader : [error] rtmp://localhost:1935/hls/source: Input/output error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions