Search in sources :

Example 1 with Parameter

use of org.fagu.fmv.ffmpeg.operation.Parameter 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;
}
Also used : Pattern(java.util.regex.Pattern) OutputParameters(org.fagu.fmv.ffmpeg.operation.OutputParameters) Matcher(java.util.regex.Matcher) Parameter(org.fagu.fmv.ffmpeg.operation.Parameter) IOEntity(org.fagu.fmv.ffmpeg.operation.IOEntity)

Aggregations

Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 IOEntity (org.fagu.fmv.ffmpeg.operation.IOEntity)1 OutputParameters (org.fagu.fmv.ffmpeg.operation.OutputParameters)1 Parameter (org.fagu.fmv.ffmpeg.operation.Parameter)1