Search in sources :

Example 1 with BasicStreamMuxer

use of org.fagu.fmv.ffmpeg.format.BasicStreamMuxer 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);
    }
}
Also used : BasicStreamMuxer(org.fagu.fmv.ffmpeg.format.BasicStreamMuxer) FFMPEGExecutorBuilder(org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder) MovieMetadatas(org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas) OutputInfos(org.fagu.fmv.core.project.OutputInfos) OutputProcessor(org.fagu.fmv.ffmpeg.operation.OutputProcessor) InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Executable(org.fagu.fmv.core.exec.Executable) File(java.io.File) Source(org.fagu.fmv.core.exec.Source)

Example 2 with BasicStreamMuxer

use of org.fagu.fmv.ffmpeg.format.BasicStreamMuxer in project fmv by f-agu.

the class AbstractExecutable method outputProcessor.

/**
 * @param builder
 * @param outfile
 * @param cache
 * @return
 */
protected OutputProcessor outputProcessor(FFMPEGExecutorBuilder builder, File outfile, Cache cache) {
    OutputInfos outputInfos = getProject().getOutputInfos();
    BasicStreamMuxer muxer = BasicStreamMuxer.to(outfile, outputInfos.getFormat());
    return outputProcessor(builder.mux(muxer), cache);
}
Also used : BasicStreamMuxer(org.fagu.fmv.ffmpeg.format.BasicStreamMuxer) OutputInfos(org.fagu.fmv.core.project.OutputInfos)

Aggregations

OutputInfos (org.fagu.fmv.core.project.OutputInfos)2 BasicStreamMuxer (org.fagu.fmv.ffmpeg.format.BasicStreamMuxer)2 File (java.io.File)1 Executable (org.fagu.fmv.core.exec.Executable)1 Source (org.fagu.fmv.core.exec.Source)1 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)1 MovieMetadatas (org.fagu.fmv.ffmpeg.metadatas.MovieMetadatas)1 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)1 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)1