Search in sources :

Example 6 with DefaultExecuteResultHandler

use of org.apache.commons.exec.DefaultExecuteResultHandler in project ddf by codice.

the class VideoThumbnailPlugin method getVideoDuration.

private Duration getVideoDuration(final String videoFilePath) throws IOException, InterruptedException {
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    final PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
    final CommandLine command = getFFmpegInfoCommand(videoFilePath);
    final DefaultExecuteResultHandler resultHandler = executeFFmpeg(command, 15, streamHandler);
    resultHandler.waitFor();
    return parseVideoDuration(outputStream.toString(StandardCharsets.UTF_8.name()));
}
Also used : CommandLine(org.apache.commons.exec.CommandLine) PumpStreamHandler(org.apache.commons.exec.PumpStreamHandler) DefaultExecuteResultHandler(org.apache.commons.exec.DefaultExecuteResultHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

DefaultExecuteResultHandler (org.apache.commons.exec.DefaultExecuteResultHandler)6 CommandLine (org.apache.commons.exec.CommandLine)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DefaultExecutor (org.apache.commons.exec.DefaultExecutor)2 ExecuteWatchdog (org.apache.commons.exec.ExecuteWatchdog)2 Executor (org.apache.commons.exec.Executor)2 PumpStreamHandler (org.apache.commons.exec.PumpStreamHandler)2 File (java.io.File)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1 ExecuteException (org.apache.commons.exec.ExecuteException)1