use of org.apache.commons.exec.CommandLine 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.CommandLine in project ddf by codice.
the class VideoThumbnailPlugin method getFFmpegCreateThumbnailCommand.
private CommandLine getFFmpegCreateThumbnailCommand(final String videoFilePath, final String thumbnailFilePath, final String seek, final int numFrames) {
final String filterChainFlag = "-vf";
final String filterChain = "thumbnail,scale=200:-1";
final String videoFramesToOutputFlag = "-frames:v";
final String videoFramesToOutput = String.valueOf(numFrames);
final String videoSyncFlag = "-vsync";
final String videoSyncVariableFrameRate = "vfr";
final CommandLine command = new CommandLine(ffmpegPath).addArgument(SUPPRESS_PRINTING_BANNER_FLAG);
if (seek != null) {
final String seekFlag = "-ss";
command.addArgument(seekFlag).addArgument(seek);
}
command.addArgument(INPUT_FILE_FLAG).addArgument(videoFilePath, DONT_HANDLE_QUOTING).addArgument(filterChainFlag).addArgument(filterChain).addArgument(videoFramesToOutputFlag).addArgument(videoFramesToOutput).addArgument(videoSyncFlag).addArgument(videoSyncVariableFrameRate);
command.addArgument(thumbnailFilePath, DONT_HANDLE_QUOTING).addArgument(OVERWRITE_EXISTING_FILE_FLAG);
return command;
}
use of org.apache.commons.exec.CommandLine 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.CommandLine in project ddf by codice.
the class VideoThumbnailPlugin method getFFmpegInfoCommand.
private CommandLine getFFmpegInfoCommand(final String videoFilePath) {
CommandLine commandLine = new CommandLine(ffmpegPath).addArgument(SUPPRESS_PRINTING_BANNER_FLAG).addArgument(INPUT_FILE_FLAG).addArgument(videoFilePath, DONT_HANDLE_QUOTING);
LOGGER.debug("FFmpeg command : {}", commandLine.toString());
return commandLine;
}
use of org.apache.commons.exec.CommandLine in project storm by apache.
the class Utils method execCommand.
public static int execCommand(String... command) throws ExecuteException, IOException {
CommandLine cmd = new CommandLine(command[0]);
for (int i = 1; i < command.length; i++) {
cmd.addArgument(command[i]);
}
DefaultExecutor exec = new DefaultExecutor();
return exec.execute(cmd);
}
Aggregations