Package ws.schild.jave.process
Class ProcessWrapper
java.lang.Object
ws.schild.jave.process.ProcessWrapper
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
FFMPEGProcess
A ffmpeg process wrapper.
- Author:
- Carlo Pelliccia
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArgument(String arg) Adds an argument to the ffmpeg executable call.voidclose()voiddestroy()If there's a ffmpeg execution in progress, it kills it.enhanceArguments(Stream<String> execArgs) Provide an opportunity for subclasses to enhance the argument list before passing off to execute.voidexecute()Executes the ffmpeg process with the previous given arguments.voidexecute(boolean destroyOnRuntimeShutdown, boolean openIOStreams) Executes the ffmpeg process with the previous given arguments.Returns a stream reading from the ffmpeg process standard error channel.Returns a stream reading from the ffmpeg process standard output channel.Returns a stream writing in the ffmpeg process standard input channel.intReturn the exit code of the ffmpeg process If the process is not yet terminated, it waits for the termination of the process
-
Constructor Details
-
ProcessWrapper
It build the executor.- Parameters:
ffmpegExecutablePath- The path of the ffmpeg executable.
-
-
Method Details
-
addArgument
Adds an argument to the ffmpeg executable call.- Parameters:
arg- The argument.
-
execute
Executes the ffmpeg process with the previous given arguments.- Parameters:
destroyOnRuntimeShutdown- destroy process if the runtime VM is shutdownopenIOStreams- Open IO streams for input/output and errorout, should be false when destroyOnRuntimeShutdown is false too- Throws:
IOException- If the process call fails.
-
enhanceArguments
Provide an opportunity for subclasses to enhance the argument list before passing off to execute.- Parameters:
execArgs- The current Stream of arguments- Returns:
- A possibly enhanced stream of arguments
-
execute
Executes the ffmpeg process with the previous given arguments. Default to kill processes when the JVM terminates, and the various IOStreams are opened as required- Throws:
IOException- If the process call fails.
-
getInputStream
Returns a stream reading from the ffmpeg process standard output channel.- Returns:
- A stream reading from the ffmpeg process standard output channel.
-
getOutputStream
Returns a stream writing in the ffmpeg process standard input channel.- Returns:
- A stream writing in the ffmpeg process standard input channel.
-
getErrorStream
Returns a stream reading from the ffmpeg process standard error channel.- Returns:
- A stream reading from the ffmpeg process standard error channel.
-
destroy
public void destroy()If there's a ffmpeg execution in progress, it kills it. -
getProcessExitCode
public int getProcessExitCode()Return the exit code of the ffmpeg process If the process is not yet terminated, it waits for the termination of the process- Returns:
- process exit code
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-