use of org.apache.commons.exec.DefaultExecuteResultHandler in project ddf by codice.
the class VideoThumbnailPlugin method generateThumbnailsWithoutDuration.
private void generateThumbnailsWithoutDuration(final String videoFilePath) throws IOException, InterruptedException {
final CommandLine command = getFFmpegCreateThumbnailCommand(videoFilePath, getThumbnailFilePath(), null, THUMBNAIL_COUNT);
final DefaultExecuteResultHandler resultHandler = executeFFmpeg(command, 15, DEV_NULL);
resultHandler.waitFor();
if (resultHandler.getException() != null) {
throw resultHandler.getException();
}
}
use of org.apache.commons.exec.DefaultExecuteResultHandler in project ddf by codice.
the class VideoThumbnailPlugin method createGifThumbnailWithDuration.
private byte[] createGifThumbnailWithDuration(final String videoFilePath, final Duration duration) throws IOException, InterruptedException {
final Duration durationFraction = duration.dividedBy(THUMBNAIL_COUNT);
// Start numbering files with 1 to match FFmpeg's convention.
for (int clipNum = FFMPEG_FILE_NUMBERING_START; clipNum <= THUMBNAIL_COUNT; ++clipNum) {
final String thumbnailPath = String.format(getThumbnailFilePath(), clipNum);
final String seek = durationToString(durationFraction.multipliedBy(clipNum - 1));
final CommandLine command = getFFmpegCreateThumbnailCommand(videoFilePath, thumbnailPath, seek, 1);
final DefaultExecuteResultHandler resultHandler = executeFFmpeg(command, 15, DEV_NULL);
resultHandler.waitFor();
}
return createGifFromThumbnailFiles();
}
use of org.apache.commons.exec.DefaultExecuteResultHandler in project ddf by codice.
the class VideoThumbnailPlugin method executeFFmpeg.
private DefaultExecuteResultHandler executeFFmpeg(final CommandLine command, final int timeoutSeconds, final PumpStreamHandler streamHandler) throws IOException {
final ExecuteWatchdog watchdog = new ExecuteWatchdog(timeoutSeconds * 1000);
final Executor executor = new DefaultExecutor();
executor.setWatchdog(watchdog);
if (streamHandler != null) {
executor.setStreamHandler(streamHandler);
}
final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
executor.execute(command, resultHandler);
return resultHandler;
}
use of org.apache.commons.exec.DefaultExecuteResultHandler in project ddf by codice.
the class VideoThumbnailPlugin method createGifFromThumbnailFiles.
private byte[] createGifFromThumbnailFiles() throws IOException, InterruptedException {
final DefaultExecuteResultHandler resultHandler = executeFFmpeg(getFFmpegCreateAnimatedGifCommand(), 15, DEV_NULL);
resultHandler.waitFor();
if (resultHandler.getException() == null) {
return FileUtils.readFileToByteArray(new File(getGifFilePath()));
} else {
throw resultHandler.getException();
}
}
use of org.apache.commons.exec.DefaultExecuteResultHandler in project xwiki-platform by xwiki.
the class XWikiExecutor method stopInternal.
private void stopInternal() throws Exception {
String stopCommand = getDefaultStopCommand(getPort(), getStopPort());
LOGGER.debug("Executing command: [{}]", stopCommand);
DefaultExecuteResultHandler stopProcessHandler = executeCommand(stopCommand);
// First wait for the stop process to have stopped, waiting a max of 5 minutes!
// It's going to stop the start process...
waitForProcessToFinish(stopProcessHandler, PROCESS_FINISH_TIMEOUT);
}
Aggregations