Class FFmpegResultFuture
java.lang.Object
com.github.kokorin.jaffree.ffmpeg.FFmpegResultFuture
A
FFmpegResultFuture represents the result of an asynchronous ffmpeg execution.-
Constructor Summary
ConstructorsConstructorDescriptionFFmpegResultFuture(CompletableFuture<FFmpegResult> resultFuture, Stopper stopper) CreatesFFmpegResultFuture. -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean forceStop) Deprecated.This method is left for backward compatibility.voidImmediately stops ffmpeg process.get()Waits if necessary for ffmpeg process to complete, and then retrieves its result.Waits if necessary for at most the given time for ffmpeg process to complete, and then retrieves its result, if available.voidRequests ffmpeg process to stop.booleanReturnstrueif ffmpeg execution was cancelled before it completed normally.booleanisDone()Returnstrueif ffmpeg execution completed.voidstop(boolean forcefully) Stops ffmpeg process.Returns a completion that can be used to chain operations after FFmpeg completes, using theCompletionStageJava 8 API.
-
Constructor Details
-
FFmpegResultFuture
CreatesFFmpegResultFuture.- Parameters:
resultFuture- result futurestopper- stopper
-
-
Method Details
-
forceStop
public void forceStop()Immediately stops ffmpeg process. Note output media may be corrupted. -
graceStop
public void graceStop()Requests ffmpeg process to stop. Note output media finalization may take some time - up to several seconds. -
stop
public void stop(boolean forcefully) Stops ffmpeg process.- Parameters:
forcefully- true to stop immediately
-
cancel
Deprecated.This method is left for backward compatibility. May be removed. Usestop(boolean),forceStop()orgraceStop()- Parameters:
forceStop- true to stop immediately- Returns:
- true
-
get
Waits if necessary for ffmpeg process to complete, and then retrieves its result.- Returns:
- ffmpeg result
- Throws:
CancellationException- if the computation was cancelledExecutionException- if the computation threw an exceptionInterruptedException- if the current thread was interrupted while waiting
-
get
public FFmpegResult get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException Waits if necessary for at most the given time for ffmpeg process to complete, and then retrieves its result, if available.- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
- the computed result
- Throws:
CancellationException- if the computation was cancelledExecutionException- if the computation threw an exceptionInterruptedException- if the current thread was interrupted while waitingTimeoutException- if the wait timed out
-
isCancelled
public boolean isCancelled()Returnstrueif ffmpeg execution was cancelled before it completed normally.- Returns:
trueif ffmpeg execution was cancelled before it completed
-
isDone
public boolean isDone()Returnstrueif ffmpeg execution completed.Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return
true.- Returns:
trueif ffmpeg execution completed
-
toCompletableFuture
Returns a completion that can be used to chain operations after FFmpeg completes, using theCompletionStageJava 8 API.- Returns:
- completion that will complete when ffmpeg completes normally, and will complete
exceptionally with a
CancellationExceptionif ffmpeg is forcefully stopped or with aJaffreeExceptionif an error occurs.
-