Search in sources :

Example 16 with FFMPEGExecutorBuilder

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

the class FFHelper method audioGenerator.

/**
 * @param outFile
 * @throws IOException
 */
public static void audioGenerator(File outFile) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    AudioGenerator ag = AudioGenerator.build().expr("sin(440*2*PI*t)").sampleRate(44100).duration(Duration.valueOf(5));
    builder.addMediaInput(ag.forInput());
    builder.addMediaOutputFile(outFile).overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) AudioGenerator(org.fagu.fmv.ffmpeg.filter.impl.AudioGenerator)

Example 17 with FFMPEGExecutorBuilder

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

the class FFHelper method encodeTox264_KeepChaptersAndSubtitles.

/**
 * @param inMkvFile
 * @param outMp4File
 * @param locales
 * @throws IOException
 */
public static void encodeTox264_KeepChaptersAndSubtitles(File inFile, File outFile, Collection<Locale> locales) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.hideBanner();
    InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
    MovieMetadatas videoMetadatas = inputProcessor.getMovieMetadatas();
    OutputProcessor outputProcessor = builder.addMediaOutputFile(outFile);
    for (Stream stream : videoMetadatas.getStreams()) {
        // exclude some subtitles
        // if(stream.is(Type.SUBTITLE) && ! locales.contains(stream.locale())) {
        // continue;
        // }
        // if(stream.is(Type.AUDIO) && ! locales.contains(stream.locale())) {
        // continue;
        // }
        outputProcessor.map().streams(stream).input(inputProcessor);
    }
    outputProcessor.codec(H264.findRecommanded().strict(Strict.EXPERIMENTAL).quality(23)).codecAutoSelectAAC().codecCopy(Type.SUBTITLE).overwrite();
    FFExecutor<Object> executor = builder.build();
    // System.out.println(executor.getCommandLine());
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) OutputProcessor(org.fagu.fmv.ffmpeg.operation.OutputProcessor) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Stream(org.fagu.fmv.ffmpeg.metadatas.Stream) VideoStream(org.fagu.fmv.ffmpeg.metadatas.VideoStream)

Example 18 with FFMPEGExecutorBuilder

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

the class FFHelper method captureWebCam.

/**
 * @param outFile
 * @param duration
 * @throws IOException
 */
public static void captureWebCam(File outFile, Duration duration) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.addMediaInputWebCam().duration(duration);
    builder.addMediaOutputFile(outFile);
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)

Example 19 with FFMPEGExecutorBuilder

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

the class FFHelper method speed.

/**
 * @param inFile
 * @param outFile
 * @param multiplyBy
 * @throws IOException
 */
public static void speed(File inFile, File outFile, float multiplyBy) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
    Speed speed = Speed.multiply(multiplyBy);
    speed.addInput(inputProcessor);
    builder.filter(speed);
    builder.addMediaOutputFile(outFile).overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : Speed(org.fagu.fmv.ffmpeg.filter.impl.Speed) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor)

Example 20 with FFMPEGExecutorBuilder

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

the class FFHelper method reencodeToH264.

/**
 * @param inFile
 * @throws IOException
 */
public static void reencodeToH264(File inFile, File outFile) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.addMediaInputFile(inFile);
    // 
    builder.mux(MP4Muxer.to(outFile)).codec(// 
    H264.findRecommanded().mostCompatible()).overwrite();
    FFExecutor<Object> executor = builder.build();
    System.out.println(executor.getCommandLine());
    long startTime = System.currentTimeMillis();
    executor.execute();
    long endTime = System.currentTimeMillis();
    System.out.println(endTime - startTime);
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)

Aggregations

FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)55 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)27 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)19 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)16 File (java.io.File)12 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)11 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)9 Size (org.fagu.fmv.utils.media.Size)6 Concat (org.fagu.fmv.ffmpeg.filter.impl.Concat)5 IOException (java.io.IOException)4 OptionalInt (java.util.OptionalInt)4 AudioGenerator (org.fagu.fmv.ffmpeg.filter.impl.AudioGenerator)4 NullSourceVideo (org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo)4 Progress (org.fagu.fmv.ffmpeg.operation.Progress)4 Duration (org.fagu.fmv.utils.time.Duration)4 Executable (org.fagu.fmv.core.exec.Executable)3 Source (org.fagu.fmv.core.exec.Source)3 OutputInfos (org.fagu.fmv.core.project.OutputInfos)3 MixAudioDuration (org.fagu.fmv.ffmpeg.filter.impl.AudioMix.MixAudioDuration)3 Blend (org.fagu.fmv.ffmpeg.filter.impl.Blend)3