Search in sources :

Example 1 with Time

use of org.fagu.fmv.utils.time.Time 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 Time

use of org.fagu.fmv.utils.time.Time 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 Time

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

the class ByDuration method etaPart.

/**
 * @return
 */
@Override
public Part etaPart() {
    double durTotal = duration.toSeconds();
    long startTime = System.currentTimeMillis();
    return new ETAPart(status -> {
        Time time = progress.getTime();
        if (time != null) {
            double currentSeconds = time.toSeconds();
            if (currentSeconds > 0) {
                double remainSeconds = durTotal - currentSeconds;
                int milliseconds = (int) (remainSeconds * (int) (System.currentTimeMillis() - startTime) / currentSeconds);
                return milliseconds / 1000;
            }
        }
        return null;
    });
}
Also used : Time(org.fagu.fmv.utils.time.Time) ETAPart(org.fagu.fmv.textprogressbar.part.ETAPart)

Example 4 with Time

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

the class CropDetection method add.

/**
 * @param log
 */
void add(String log) {
    Matcher matcher = LOG_PATTERN.matcher(log);
    if (matcher.matches()) {
        CropSize cropSize = new CropSize(matcher, totalCount);
        int pts = Integer.parseInt(matcher.group(9));
        Time time = Time.parse(matcher.group(10));
        // parse crop=...:...:...:... ?
        cropSize.startPTS = pts;
        cropSize.startTime = time;
        totalCount.incrementAndGet();
        if (cropSizes.isEmpty()) {
            cropSizes.add(cropSize);
        } else {
            CropSize previousCropSize = cropSizes.get(cropSizes.size() - 1);
            previousCropSize.endPTS = pts;
            previousCropSize.endTime = time;
            if (previousCropSize.equals(cropSize)) {
                previousCropSize.count++;
            } else {
                cropSizes.add(cropSize);
                doneCropSize.forEach(c -> c.accept(previousCropSize));
            }
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) Time(org.fagu.fmv.utils.time.Time)

Example 5 with Time

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

the class Drawtext method enableTime.

/**
 * @param startTime
 * @param duration
 * @return
 */
public Drawtext enableTime(Time startTime, Duration duration) {
    Time endTime = Time.valueOf(startTime.toSeconds() + duration.toSeconds());
    parameter("enable", "'between(t," + startTime.toSeconds() + "," + endTime.toSeconds() + ")'");
    return this;
}
Also used : Time(org.fagu.fmv.utils.time.Time)

Aggregations

Time (org.fagu.fmv.utils.time.Time)16 Duration (org.fagu.fmv.utils.time.Duration)7 InputProcessor (org.fagu.fmv.ffmpeg.operation.InputProcessor)5 FilterComplex (org.fagu.fmv.ffmpeg.filter.FilterComplex)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 VideoStream (org.fagu.fmv.ffmpeg.metadatas.VideoStream)4 PixelFormat (org.fagu.fmv.ffmpeg.utils.PixelFormat)4 File (java.io.File)3 FFMPEGExecutorBuilder (org.fagu.fmv.ffmpeg.executor.FFMPEGExecutorBuilder)3 Test (org.junit.Test)3 OutputProcessor (org.fagu.fmv.ffmpeg.operation.OutputProcessor)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1