Search in sources :

Example 1 with FFExecFallback

use of org.fagu.fmv.ffmpeg.executor.FFExecFallback in project fmv by f-agu.

the class FFHelper method resize.

/**
 * @param inFile
 * @param size
 * @param outFile
 * @throws IOException
 */
public static void resize(File inFile, Size size, File outFile) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
    builder.filter(Scale.to(size, ScaleMode.fitToBoxKeepAspectRatio()));
    builder.mux(MP4Muxer.to(outFile)).qualityScaleVideo(0).codecCopy(Type.AUDIO).codecCopy(Type.SUBTITLE).mapAllStreams(inputProcessor).overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.addListener(new FFExecListener() {

        @Override
        public void eventExecFailed(IOException e, CommandLine command) {
            System.out.println("FAILED: " + CommandLineUtils.toLine(command));
        }

        @Override
        public void eventPreExecFallbacks(CommandLine command, Collection<FFExecFallback> fallbacks) {
            System.out.println("With fallback: " + fallbacks);
            System.out.println(" -->: " + CommandLineUtils.toLine(command));
        }
    });
    executor.execute();
}
Also used : FFExecListener(org.fagu.fmv.ffmpeg.executor.FFExecListener) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) CommandLine(org.apache.commons.exec.CommandLine) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) IOException(java.io.IOException) FFExecFallback(org.fagu.fmv.ffmpeg.executor.FFExecFallback)

Aggregations

IOException (java.io.IOException)1 CommandLine (org.apache.commons.exec.CommandLine)1 FFExecFallback (org.fagu.fmv.ffmpeg.executor.FFExecFallback)1 FFExecListener (org.fagu.fmv.ffmpeg.executor.FFExecListener)1 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)1 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)1