Search in sources :

Example 1 with SplitVideo

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

the class FFHelper method splitTo3.

/**
 * @param inFile
 * @param outFile1
 * @param outFile2
 * @throws IOException
 */
public static void splitTo3(File inFile, File outFile1, File outFile2, File outFile3) throws IOException {
    // outFile1 : no fade
    // outFile2 : fade in
    // outFile3 : fade out
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
    SplitVideo splitVideo = SplitVideo.build();
    splitVideo.addInput(inputProcessor);
    OutputKey outv1 = splitVideo.addOutput();
    OutputKey outv2 = splitVideo.addOutput();
    OutputKey outv3 = splitVideo.addOutput();
    SplitAudio splitAudio = SplitAudio.build();
    splitAudio.addInput(inputProcessor);
    OutputKey outa1 = splitAudio.addOutput();
    OutputKey outa2 = splitAudio.addOutput();
    OutputKey outa3 = splitAudio.addOutput();
    Fade fade2 = Fade.create(FadeType.IN, Time.valueOf(0), Duration.valueOf(1));
    Fade fade3 = Fade.create(FadeType.OUT, Time.valueOf(0), Duration.valueOf(1));
    fade2.addInput(outv2).addInput(outa2);
    fade3.addInput(outv3).addInput(outa3);
    builder.filter(splitVideo);
    builder.filter(splitAudio);
    builder.filter(fade2);
    builder.filter(fade3);
    OutputProcessor outputProcessor1 = builder.addMediaOutputFile(outFile1);
    outputProcessor1.map().allStreams().label(outv1.getLabel()).label(outa1.getLabel());
    outputProcessor1.overwrite();
    OutputProcessor outputProcessor2 = builder.addMediaOutputFile(outFile2);
    outputProcessor2.map().allStreams().input(fade2);
    outputProcessor2.overwrite();
    OutputProcessor outputProcessor3 = builder.addMediaOutputFile(outFile3);
    outputProcessor3.map().allStreams().input(fade3);
    outputProcessor3.overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) SplitAudio(org.fagu.fmv.ffmpeg.filter.impl.SplitAudio) OutputProcessor(org.fagu.fmv.ffmpeg.operation.OutputProcessor) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) SplitVideo(org.fagu.fmv.ffmpeg.filter.impl.SplitVideo) Fade(org.fagu.fmv.ffmpeg.filter.impl.Fade) OutputKey(org.fagu.fmv.ffmpeg.filter.OutputKey)

Aggregations

FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)1 OutputKey (org.fagu.fmv.ffmpeg.filter.OutputKey)1 Fade (org.fagu.fmv.ffmpeg.filter.impl.Fade)1 SplitAudio (org.fagu.fmv.ffmpeg.filter.impl.SplitAudio)1 SplitVideo (org.fagu.fmv.ffmpeg.filter.impl.SplitVideo)1 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)1 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)1