Search in sources :

Example 1 with ScaleMode

use of org.fagu.fmv.ffmpeg.filter.impl.ScaleMode in project fmv by f-agu.

the class Libx264NotDisibleBy2FFExecFallback method prepare.

/**
 * @see org.fagu.fmv.ffmpeg.executor.FFExecFallback#prepare(org.fagu.fmv.ffmpeg.executor.FFEnv, java.io.IOException)
 */
@Override
public boolean prepare(FFEnv ffEnv, IOException ioException) throws IOException {
    FFExecutor<Object> executor = ffEnv.getExecutor();
    AbstractOperation<?, ?> operation = (AbstractOperation<?, ?>) ffEnv.getOperation();
    for (String line : executor.getOutputReadLine().getLines()) {
        if (line.startsWith("[libx264 @") && line.contains(" not divisible by 2")) {
            for (Filter filter : operation.getFilters()) {
                if (filter instanceof Scale) {
                    Scale scale = (Scale) filter;
                    Size size = scale.getSize();
                    ScaleMode scaleMode = scale.getScaleMode();
                    if (size != null && scaleMode != null) {
                        Size newSize = resize(size);
                        if (newSize == null) {
                            return false;
                        }
                        scale.set(size, scaleMode);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : AbstractOperation(org.fagu.fmv.ffmpeg.operation.AbstractOperation) Filter(org.fagu.fmv.ffmpeg.filter.Filter) Size(org.fagu.fmv.utils.media.Size) Scale(org.fagu.fmv.ffmpeg.filter.impl.Scale) ScaleMode(org.fagu.fmv.ffmpeg.filter.impl.ScaleMode)

Aggregations

Filter (org.fagu.fmv.ffmpeg.filter.Filter)1 Scale (org.fagu.fmv.ffmpeg.filter.impl.Scale)1 ScaleMode (org.fagu.fmv.ffmpeg.filter.impl.ScaleMode)1 AbstractOperation (org.fagu.fmv.ffmpeg.operation.AbstractOperation)1 Size (org.fagu.fmv.utils.media.Size)1