use of org.fagu.fmv.ffmpeg.operation.IOEntity in project fmv by f-agu.
the class MP4TagCodecNotFoundFFExecFallback method prepare.
/**
* @see org.fagu.fmv.ffmpeg.executor.FFExecFallback#prepare(java.io.IOException)
*/
@Override
public boolean prepare(FFEnv ffEnv, IOException ioException) throws IOException {
FFExecutor<Object> executor = ffEnv.getExecutor();
Pattern pattern = Pattern.compile(".* stream #([0-9]+).*");
boolean change = false;
for (String line : executor.getOutputReadLine().getLines()) {
if (line.startsWith("[mp4 @") && line.contains("Could not find tag for codec")) {
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
int stream = Integer.parseInt(matcher.group(1));
OutputParameters outputParameters = executor.getOperation().getOutputParameters();
for (IOEntity ioEntity : outputParameters.getIOEntities()) {
List<Parameter> parameters = outputParameters.getParameters(ioEntity, Way.BEFORE);
for (Parameter parameter : parameters) {
if ("-map".equals(parameter.getName()) && parameter.hasValue() && parameter.getValue().endsWith(":" + stream)) {
change = outputParameters.removeParameter(parameter);
}
}
}
}
}
}
return change;
}
Aggregations