Search in sources :

Example 1 with Duration

use of org.fagu.fmv.utils.time.Duration in project fmv by f-agu.

the class Append method appendAudioOrVideo.

/**
 * @param sourceNum
 * @param args
 */
private void appendAudioOrVideo(int sourceNum, String[] args) {
    if (args.length != 3) {
        getPrinter().println("usage: append <num-source> <start-time> <duration>");
        return;
    }
    try {
        Time startTime = Time.parse(args[1]);
        Duration duration = Duration.parse(args[2]);
        ConcatExecutable concatExecutable = getConcatExecutable();
        if (concatExecutable == null) {
            return;
        }
        CutExecutable cutExecutable = new CutExecutable(project, startTime, duration);
        cutExecutable.setSource(new SourceSource(project, sourceNum));
        concatExecutable.add(cutExecutable);
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ConcatExecutable(org.fagu.fmv.core.exec.executable.ConcatExecutable) Time(org.fagu.fmv.utils.time.Time) Duration(org.fagu.fmv.utils.time.Duration) SourceSource(org.fagu.fmv.core.exec.source.SourceSource) CutExecutable(org.fagu.fmv.core.exec.executable.CutExecutable)

Example 2 with Duration

use of org.fagu.fmv.utils.time.Duration in project fmv by f-agu.

the class FadeAudioVideo method run.

/**
 * @see org.fagu.fmv.cli.Command#run(java.lang.String[])
 */
@Override
public void run(String[] args) {
    if (args.length != 4) {
        help();
        return;
    }
    // TEST
    Optional<Identifiable> identifiableOpt = BaseIdentifiable.findById(project, args[1]);
    if (!identifiableOpt.isPresent()) {
        println("not found: " + args[1]);
        return;
    }
    FadeType fadeType = FadeType.valueOf(args[0].toUpperCase());
    Time startTime = Time.parse(args[2]);
    Duration duration = Duration.parse(args[2]);
    Identifiable identifiable = identifiableOpt.get();
    FadeAudioVideoFilterExec filterExec = new FadeAudioVideoFilterExec(project, fadeType, startTime, duration);
    filterExec.add(identifiable);
}
Also used : Time(org.fagu.fmv.utils.time.Time) Duration(org.fagu.fmv.utils.time.Duration) FadeAudioVideoFilterExec(org.fagu.fmv.core.exec.filter.FadeAudioVideoFilterExec) FadeType(org.fagu.fmv.ffmpeg.filter.impl.FadeType) Identifiable(org.fagu.fmv.core.exec.Identifiable) BaseIdentifiable(org.fagu.fmv.core.exec.BaseIdentifiable)

Example 3 with Duration

use of org.fagu.fmv.utils.time.Duration in project fmv by f-agu.

the class Stream method countEstimateFrames.

/**
 * @return
 */
public OptionalInt countEstimateFrames() {
    OptionalInt count = numberOfFrames();
    if (count.isPresent()) {
        return count;
    }
    FrameRate frameRate = frameRate().orElse(null);
    if (frameRate == null) {
        frameRate = averageFrameRate().orElse(null);
    }
    if (frameRate == null) {
        return OptionalInt.empty();
    }
    Duration duration = duration().orElse(null);
    if (duration == null) {
        Optional<Object> totDurObj = movieMetadatas.getFormat().tag("totalduration");
        if (totDurObj.isPresent()) {
            int totDur = NumberUtils.toInt(String.valueOf(totDurObj.get()));
            if (totDur > 0) {
                duration = Duration.valueOf(totDur);
            }
        }
    }
    if (duration == null) {
        duration = movieMetadatas.getFormat().duration().orElse(null);
    }
    if (duration == null) {
        OptionalInt dts = durationTimeBase();
        if (!dts.isPresent()) {
            return OptionalInt.empty();
        }
        Fraction timeBase = timeBase().orElse(null);
        if (timeBase == null) {
            return OptionalInt.empty();
        }
        duration = Duration.valueOf(dts.getAsInt() * timeBase.doubleValue());
    }
    return OptionalInt.of((int) (frameRate.doubleValue() * duration.toSeconds()));
}
Also used : FrameRate(org.fagu.fmv.ffmpeg.utils.FrameRate) Duration(org.fagu.fmv.utils.time.Duration) JSONObject(net.sf.json.JSONObject) Fraction(org.fagu.fmv.ffmpeg.utils.Fraction) OptionalInt(java.util.OptionalInt)

Example 4 with Duration

use of org.fagu.fmv.utils.time.Duration in project fmv by f-agu.

the class FFMPEGExecutorBuilderTestCase method testInputProcessor_duration.

// ======================== INPUT PROCESSOR ========================
/**
 */
@Test
public void testInputProcessor_duration() {
    MediaInput input = mockInput("/path/file");
    InputProcessor inputProcessor = ffmpegExecutorBuilder.addMediaInput(input);
    inputProcessor.duration(new Duration(1, 2, 3.4));
    assertArgs("-t", "01:02:03.400", "-i", "/path/file");
}
Also used : InputProcessor(org.fagu.fmv.ffmpeg.operation.InputProcessor) Duration(org.fagu.fmv.utils.time.Duration) MediaInput(org.fagu.fmv.ffmpeg.operation.MediaInput) Test(org.junit.Test)

Example 5 with Duration

use of org.fagu.fmv.utils.time.Duration in project fmv by f-agu.

the class RipperTestCase method mPlayerTitles_1.

/**
 * @return
 */
private MPlayerTitles mPlayerTitles_1() {
    Map<String, String> properties = Collections.emptyMap();
    NavigableMap<Integer, MPlayerTitle> mPlayerTitleMap = new TreeMap<>();
    NavigableSet<Duration> chapters = new TreeSet<>();
    chapters.add(Duration.valueOf(10 * 60));
    chapters.add(Duration.valueOf(20 * 60));
    chapters.add(Duration.valueOf(30 * 60));
    MPlayerTitle mPlayerTitle = new MPlayerTitle(1, Duration.valueOf(84 * 60), chapters);
    mPlayerTitleMap.put(4, mPlayerTitle);
    return new MPlayerTitles(properties, mPlayerTitleMap);
}
Also used : TreeSet(java.util.TreeSet) MPlayerTitle(org.fagu.fmv.soft.mplayer.MPlayerTitle) Duration(org.fagu.fmv.utils.time.Duration) TreeMap(java.util.TreeMap) MPlayerTitles(org.fagu.fmv.soft.mplayer.MPlayerTitles)

Aggregations

Duration (org.fagu.fmv.utils.time.Duration)20 Time (org.fagu.fmv.utils.time.Time)7 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)5 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)5 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)5 Test (org.junit.Test)5 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)4 AudioGenerator (org.fagu.fmv.ffmpeg.filter.impl.AudioGenerator)4 MixAudioDuration (org.fagu.fmv.ffmpeg.filter.impl.AudioMix.MixAudioDuration)4 Blend (org.fagu.fmv.ffmpeg.filter.impl.Blend)4 Concat (org.fagu.fmv.ffmpeg.filter.impl.Concat)4 Format (org.fagu.fmv.ffmpeg.filter.impl.Format)4 NullSourceVideo (org.fagu.fmv.ffmpeg.filter.impl.NullSourceVideo)4 SetSAR (org.fagu.fmv.ffmpeg.filter.impl.SetSAR)4 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)4 PixelFormat (org.fagu.fmv.ffmpeg.utils.PixelFormat)4 TreeSet (java.util.TreeSet)2 ConcatExecutable (org.fagu.fmv.core.exec.executable.ConcatExecutable)2 SourceSource (org.fagu.fmv.core.exec.source.SourceSource)2 File (java.io.File)1