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 sakuli by ConSol.
the class SahiCommandExecutionAspect method getCommandTokens.
/**
* Due to the fact, the parsing of the sahi method {@link net.sf.sahi.util.Utils#getCommandTokens(String)} won't
* work correctly, this {@link Around} advice use the Apache libary {@link CommandLine#parse(String)} to modify it.
* See http://community.sahipro.com/forums/discussion/8552/sahi-os-5-0-and-chrome-user-data-dir-containing-spaces-not-working.
*
* @param joinPoint the {@link ProceedingJoinPoint} of the invoked method
* @param commandString the original argument as{@link String}
* @return the result of {@link CommandLine#parse(String)}
*/
@Around("execution(* net.sf.sahi.util.Utils.getCommandTokens(..)) && args(commandString)")
public String[] getCommandTokens(ProceedingJoinPoint joinPoint, String commandString) {
Logger LOGGER = getLogger(joinPoint);
CommandLine parsed = CommandLine.parse(commandString);
String[] tokens = new String[] { parsed.getExecutable() };
tokens = ArrayUtils.addAll(tokens, parsed.getArguments());
try {
Object result = joinPoint.proceed();
if (result instanceof String[] && !Arrays.equals(tokens, (String[]) result)) {
if (commandString.startsWith("sh -c \'")) {
//LOGGER.info("SAKULI-RESULT {}", printArray(tokens));
return (String[]) result;
}
LOGGER.info("MODIFIED SAHI COMMAND TOKENS: {} => {}", printArray((String[]) result), printArray(tokens));
}
} catch (Throwable e) {
LOGGER.error("Exception during execution of JoinPoint net.sf.sahi.util.Utils.getCommandTokens", e);
}
return tokens;
}
Aggregations