Search in sources :

Example 31 with FFMPEGExecutorBuilder

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

the class FFHelper method audioVolumeAdjustToMax.

/**
 * @param inFile
 * @param outFile
 * @throws IOException
 */
public static void audioVolumeAdjustToMax(File inFile, File outFile) throws IOException {
    VolumeDetected volumeDetected = audioVolumeDetect(inFile);
    System.out.println(volumeDetected);
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.addMediaInputFile(inFile);
    Volume volume = Volume.build().increaseToMax(volumeDetected);
    builder.filter(volume);
    builder.addMediaOutputFile(outFile).videoCodecCopy().overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) Volume(org.fagu.fmv.ffmpeg.filter.impl.Volume) VolumeDetected(org.fagu.fmv.ffmpeg.filter.impl.VolumeDetected)

Example 32 with FFMPEGExecutorBuilder

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

the class FFHelper method audioConvert2AAC.

/**
 * @param inFile
 * @param outFile
 * @throws IOException
 */
public static void audioConvert2AAC(File inFile, File outFile) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.addMediaInputFile(inFile);
    builder.mux(BasicStreamMuxer.to(outFile).movflags(Movflags.FASTSTART)).codec(LibFDK_AAC.build()).overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)

Example 33 with FFMPEGExecutorBuilder

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

the class FFHelper method m4aToMp3.

/**
 * @param inFile
 * @param outFile
 * @throws IOException
 */
public static void m4aToMp3(File inFile, File outFile) throws IOException {
    final int SAMPLE_RATE = 44100;
    final String bitRate = "128k";
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.hideBanner();
    InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
    MovieMetadatas movieMetadatas = inputProcessor.getMovieMetadatas();
    int sampleRate = Math.min(movieMetadatas.getAudioStream().sampleRate().orElse(SAMPLE_RATE), SAMPLE_RATE);
    FilterComplex filter = FilterComplex.create(ResampleAudio.build().frequency(sampleRate));
    builder.filter(filter);
    OutputProcessor outputProcessor = builder.addMediaOutputFile(outFile).audioChannel(2).audioBitRate(bitRate).format("mp3").overwrite();
    outputProcessor.map().allStreams().input(filter);
    FFExecutor<Object> executor = builder.build();
    System.out.println(executor.getCommandLine());
// Integer numberOfFrames =
// movieMetadatas.getAudioStream().countEstimateFrames();
// prepareProgressBar(numberOfFrames, executor, consolePrefixMessage);
// executor.execute();
}
Also used : FilterComplex(org.fagu.fmv.ffmpeg.filter.FilterComplex) 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)

Example 34 with FFMPEGExecutorBuilder

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

the class FFHelper method fade1.

/**
 * @param inFile
 * @param outFile
 * @param fadeType
 * @param duration
 * @throws IOException
 */
public static void fade1(File inFile, File outFile, FadeType fadeType, Duration duration) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    builder.addMediaInputFile(inFile);
    FadeVideo fadeVideo = FadeVideo.build().type(fadeType).startTime(Time.valueOf(0)).duration(duration);
    FadeAudio fadeAudio = FadeAudio.build().type(fadeType).startTime(Time.valueOf(0)).duration(duration);
    builder.filter(fadeVideo).filter(fadeAudio);
    builder.addMediaOutputFile(outFile).overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FadeVideo(org.fagu.fmv.ffmpeg.filter.impl.FadeVideo) FadeAudio(org.fagu.fmv.ffmpeg.filter.impl.FadeAudio) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)

Example 35 with FFMPEGExecutorBuilder

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

the class FFHelper method mixAudio.

/**
 * @param inVideoFile
 * @param inAudioFile
 * @param outFile
 * @throws IOException
 */
public static void mixAudio(File inVideoFile, File inAudioFile, File outFile, Time audioStart) throws IOException {
    FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
    InputProcessor videoInputProcessor = builder.addMediaInputFile(inVideoFile);
    InputProcessor audioInputProcessor = builder.addMediaInputFile(inAudioFile);
    // audioInputProcessor.timeSeek(audioStart);
    AudioMix audioMix = AudioMix.build();
    audioMix.addInput(audioInputProcessor, audioStart);
    audioMix.addInput(videoInputProcessor);
    audioMix.duration(MixAudioDuration.SHORTEST);
    builder.filter(audioMix);
    builder.addMediaOutputFile(outFile).videoCodecCopy().overwrite();
    FFExecutor<Object> executor = builder.build();
    executor.execute();
}
Also used : FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) AudioMix(org.fagu.fmv.ffmpeg.filter.impl.AudioMix) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor)

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