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();
}
}
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);
}
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()));
}
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");
}
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);
}
Aggregations