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();
}
Aggregations