use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class FFHelper method audioHalfVolume.
/**
* @param inFile
* @param outFile
* @throws IOException
*/
public static void audioHalfVolume(File inFile, File outFile) throws IOException {
FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
AudioModifier audioModifier = AudioModifier.build().halfVolume().channelLayout(ChannelLayout.SAME);
FilterComplex filtercomplex = FilterComplex.create(audioModifier);
filtercomplex.addInput(inputProcessor);
builder.filter(filtercomplex);
builder.addMediaOutputFile(outFile).overwrite();
FFExecutor<Object> executor = builder.build();
executor.execute();
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class FFHelper method backgroundBlurOverlayScale.
/**
* @param inFile
* @param outFile
* @throws IOException
*/
public static void backgroundBlurOverlayScale(File inFile, File outFile) throws IOException {
FFMPEGExecutorBuilder builder = FFMPEGExecutorBuilder.create();
// inFile is in HD720
InputProcessor inputProcessor = builder.addMediaInputFile(inFile);
// builder.filter(FilterComplex.create(AudioGenerator.build().silence()));
Boxblur boxblur = Boxblur.build().lumaRadius("8").lumaPower(8);
Hue hue = Hue.build().blackAndWhite();
FilterComplex blurAndBW = FilterComplex.create(boxblur, hue).addInput(inputProcessor);
FilterComplex scale = FilterComplex.create(Scale.build().size(Size.HD480)).addInput(inputProcessor);
Overlay overlay = Overlay.with(blurAndBW, scale).shortest(true).positionMiddle();
FilterComplex scale2 = FilterComplex.create(Scale.build().size(Size.HD480)).addInput(overlay);
builder.filter(scale2);
builder.addMediaOutputFile(outFile).overwrite();
FFExecutor<Object> executor = builder.build();
executor.execute();
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor 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();
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor 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();
}
use of org.fagu.fmv.ffmpeg.operation.InputProcessor in project fmv by f-agu.
the class CutExecutable method execute.
/**
* @see org.fagu.fmv.core.exec.Executable#execute(java.io.File, Cache)
*/
@Override
public void execute(File toFile, Cache cache) throws IOException {
Source source = getSource();
Executable executable = getExecutable();
if (executable == null && source == null) {
return;
}
OutputInfos outputInfos = getProject().getOutputInfos();
FFMPEGExecutorBuilder builder = FFUtils.builder(getProject());
InputProcessor inputProcessor = null;
if (executable != null) {
File childExec = getProject().getFileCache().getFile(executable, cache);
// executable.execute(childExec, cache);
inputProcessor = builder.addMediaInputFile(childExec);
} else if (source != null) {
inputProcessor = (InputProcessor) source.createAndAdd(builder);
} else {
throw new IllegalArgumentException("Source or executable not defined !");
}
inputProcessor.timeSeek(startTime);
// SetPTS videoSetPTS = new SetPTSVideo();
// videoSetPTS.setStartAtFirstFrame();
// FilterComplex videoSetPTSComplex = FilterComplex.createWith(videoSetPTS);
// videoSetPTSComplex.addInput(inputProcessor, Type.VIDEO);
// builder.add(videoSetPTSComplex);
//
// SetPTS audioSetPTS = new SetPTSAudio();
// audioSetPTS.setStartAtFirstFrame();
// FilterComplex audioSetPTSComplex = FilterComplex.createWith(audioSetPTS);
// audioSetPTSComplex.addInput(inputProcessor, Type.AUDIO);
// builder.add(audioSetPTSComplex);
BasicStreamMuxer muxer = BasicStreamMuxer.to(toFile, outputInfos.getFormat()).avoidNegativeTs(AvoidNegativeTs.MAKE_NON_NEGATIVE);
OutputProcessor outputProcessor = builder.mux(muxer);
outputProcessor.duration(duration);
outputProcessor(outputProcessor, cache);
FFExecutor<Object> executor = builder.build();
executor.execute();
if (cache == Cache.MAKE) {
MovieMetadatas movieMetadatas = MovieMetadatas.with(toFile).extract();
MovieMetadatasUtils.getDuration(movieMetadatas).ifPresent(this::setDuration);
}
}
Aggregations