Search in sources :

Example 1 with SetPTSVideo

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

the class FFHelper method overlay4.

/**
 * @param in1VideoFile
 * @param in2VideoFile
 * @param in3VideoFile
 * @param in4VideoFile
 * @param outFile
 * @param size
 * @throws IOException
 */
public static void overlay4(File in1VideoFile, File in2VideoFile, File in3VideoFile, File in4VideoFile, File outFile, Size size) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    InputProcessor video1InputProcessor = builder.addMediaInputFile(in1VideoFile);
    InputProcessor video2InputProcessor = builder.addMediaInputFile(in2VideoFile);
    InputProcessor video3InputProcessor = builder.addMediaInputFile(in3VideoFile);
    InputProcessor video4InputProcessor = builder.addMediaInputFile(in4VideoFile);
    Size quartSize = size.getRatio().getSizeByWidth(size.getWidth() / 2);
    NullSourceVideo nullSource = NullSourceVideo.build().size(size);
    FilterComplex nullSourceFC = FilterComplex.create(nullSource);
    SetPTSVideo setPTS = SetPTSVideo.createStartAtFirstFrame();
    Scale scale = Scale.to(quartSize, ScaleMode.fitToBox());
    FilterComplex vfc1 = FilterComplex.create(setPTS, scale).addInput(video1InputProcessor);
    FilterComplex vfc2 = FilterComplex.create(setPTS, scale).addInput(video2InputProcessor);
    FilterComplex vfc3 = FilterComplex.create(setPTS, scale).addInput(video3InputProcessor);
    FilterComplex vfc4 = FilterComplex.create(setPTS, scale).addInput(video4InputProcessor);
    builder.filter(nullSourceFC);
    builder.filter(vfc1);
    builder.filter(vfc2);
    builder.filter(vfc3);
    builder.filter(vfc4);
    Overlay overlay1 = Overlay.with(nullSourceFC, vfc1).shortest(true);
    Overlay overlay2 = Overlay.with(overlay1, vfc2).shortest(true).x(quartSize.getWidth());
    Overlay overlay3 = Overlay.with(overlay2, vfc3).shortest(true).y(quartSize.getHeight());
    Overlay.with(overlay3, vfc4).shortest(true).x(quartSize.getWidth()).y(quartSize.getHeight());
    builder.addMediaOutputFile(outFile).overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) NullSourceVideo(org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo) SetPTSVideo(org.fagu.fmv.ffmpeg.filter.impl.SetPTSVideo) Size(org.fagu.fmv.utils.media.Size) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Scale(org.fagu.fmv.ffmpeg.filter.impl.Scale) Overlay(org.fagu.fmv.ffmpeg.filter.impl.Overlay)

Aggregations

FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)1 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)1 NullSourceVideo (org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo)1 Overlay (org.fagu.fmv.ffmpeg.filter.impl.Overlay)1 Scale (org.fagu.fmv.ffmpeg.filter.impl.Scale)1 SetPTSVideo (org.fagu.fmv.ffmpeg.filter.impl.SetPTSVideo)1 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)1 Size (org.fagu.fmv.utils.media.Size)1