question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CompletableFuture doesn't raise exceptions for runtime errors

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kokorincommented, Jan 31, 2022

You could create a branch from develop branch. Usually with GitHub one creates a branch in own fork project. When it’s done, PR could be created.

0reactions
k2r79commented, Jan 31, 2022

Which branch must I start from ? I can see develop is behind master. Do I need specific rights to push my branch ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling Runtime Exception in CompletableFuture in java8
Question is Lets say if i want to throw runtime exception and want application to stop. Basically if i throw Runtime exception ,...
Read more >
3 Ways to Handle Exception In Completable Future
Exception handling is important when writing code with CompletableFuture . CompletableFuture provides three methods to handle them: handle() , ...
Read more >
Handling Errors in CompletableFuture java 8 - YouTube
In this video tutorial we will learn how to handle exception in CompletableFuture in java 8 using a demo project.Below is the GitHub...
Read more >
Java's CompletableFuture and typed exception handling
One thing that most asynchronous computing models suffer from – and Java's CompletableFuture is no exception – is the loss of typed ...
Read more >
CompletableFuture (Java SE 17 & JDK 17) - Oracle Help Center
Returns a new CompletableFuture that is completed when any of the given CompletableFutures complete, with the same result. Otherwise, if it completed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found