use of com.helospark.tactview.core.timeline.VisualTimelineClip in project tactview by helospark.
the class LongProcessRequestor method requestFrames.
public <T extends StatelessVideoEffect & LongProcessVisualImagePushAware> void requestFrames(T target, LongProcessFrameRequest longProcessFrameRequest) {
VisualTimelineClip clip = (VisualTimelineClip) timelineManagerAccessor.findClipForEffect(target.getId()).get();
Optional<Integer> effectChannel = clip.getEffectChannelIndex(target.getId());
LongProcessDescriptor descriptor = new LongProcessDescriptor();
descriptor.setClipId(clip.getId());
descriptor.setEffectId(Optional.of(target.getId()));
descriptor.setJobId(UUID.randomUUID().toString());
if (longProcessFrameRequest.getDuplaceRequestStrategy().equals(ONLY_KEEP_LATEST_REQUEST)) {
removeAndStopAllJobsWithEffectId(target.getId());
}
Runnable runnable = visualLongProcessRunnableFactory.createVisualRunnable(target, clip, effectChannel, descriptor);
descriptor.setRunnable(runnable);
requestedJobs.add(descriptor);
}
use of com.helospark.tactview.core.timeline.VisualTimelineClip in project tactview by helospark.
the class GhostingEffect method createFrame.
@Override
public ReadOnlyClipImage createFrame(StatelessEffectRequest request) {
VisualTimelineClip clip = request.getCurrentTimelineClip();
ReadOnlyClipImage currentFrame = request.getCurrentFrame();
ClipImage result = ClipImage.sameSizeAs(currentFrame);
double endAlpha = alphaProvider.getValueAt(request.getEffectPosition());
int numberOfGhosts = numberOfGhostProvider.getValueAt(request.getEffectPosition());
double timeStep = ghostTimeProvider.getValueAt(request.getEffectPosition());
BigDecimal timeBetweenGhosts = BigDecimal.valueOf(timeStep);
double alpha = endAlpha;
int startIndex = numberOfGhosts - 2;
for (int i = startIndex; i >= 0; --i) {
BigDecimal absoluteEffectPosition = request.getClipPosition().getSeconds().subtract(timeBetweenGhosts.multiply(BigDecimal.valueOf(i + 1)));
if (absoluteEffectPosition.compareTo(BigDecimal.ZERO) < 0) {
// TODO: has to be part of clip
break;
}
GetFrameRequest frameRequest = GetFrameRequest.builder().withApplyEffects(true).withApplyEffectsLessThanEffectChannel(Optional.of(request.getEffectChannel())).withExpectedWidth(currentFrame.getWidth()).withExpectedHeight(currentFrame.getHeight()).withPosition(new TimelinePosition(absoluteEffectPosition)).withScale(request.getScale()).build();
ReadOnlyClipImage frame = clip.getFrame(frameRequest);
if (i == startIndex) {
result.copyFrom(frame);
} else {
mergeWithAlpha(result, frame, alpha);
}
GlobalMemoryManagerAccessor.memoryManager.returnBuffer(frame.getBuffer());
}
mergeWithAlpha(result, currentFrame, endAlpha);
return result;
}
use of com.helospark.tactview.core.timeline.VisualTimelineClip in project tactview by helospark.
the class ClipPatternDrawerListener method updatePatternDelegate.
private Image updatePatternDelegate(TimelineClip clipToUpdate, TimelineInterval interval, double zoom, int pixelWidth) {
if (patternDrawingEnabled) {
LOGGER.debug("Generating pattern for clip={} with the local interval={} and zoom={}", clipToUpdate.getId(), interval, zoom);
double visibleStartPosition = interval.getStartPosition().getSeconds().doubleValue();
double visibleEndPosition = interval.getEndPosition().getSeconds().doubleValue();
Image image = null;
if (clipToUpdate instanceof VisualTimelineClip) {
VisualTimelineClip videoClip = (VisualTimelineClip) clipToUpdate;
image = timelineImagePatternService.createTimelinePattern(videoClip, pixelWidth, visibleStartPosition, visibleEndPosition);
} else if (clipToUpdate instanceof AudibleTimelineClip) {
AudibleTimelineClip audibleTimelineClip = (AudibleTimelineClip) clipToUpdate;
image = audioImagePatternService.createAudioImagePattern(audibleTimelineClip, pixelWidth, visibleStartPosition, visibleEndPosition);
}
return image;
}
return null;
}
use of com.helospark.tactview.core.timeline.VisualTimelineClip in project tactview by helospark.
the class DependentClipProviderChainItem method drawImage.
private Image drawImage(TimelineClip clip, TimelinePosition position) {
if (clip instanceof VisualTimelineClip) {
GetFrameRequest frameRequest = GetFrameRequest.builder().withApplyEffects(true).withUseApproximatePosition(true).withExpectedWidth(// TODO: aspect ratio
IMAGE_PREVIEW_SIZE).withExpectedHeight(27).withPosition(position).withScale(uiProjectRepository.getScaleFactor() / ((double) uiProjectRepository.getPreviewWidth() / IMAGE_PREVIEW_SIZE)).build();
ReadOnlyClipImage result = ((VisualTimelineClip) clip).getFrame(frameRequest);
return imageConverter.convertToJavafxImage(result.getBuffer(), result.getWidth(), result.getHeight());
} else {
throw new IllegalStateException("Other formats not supported");
}
}
use of com.helospark.tactview.core.timeline.VisualTimelineClip in project tactview by helospark.
the class FrameExtender method expandFrame.
public ClipImage expandFrame(FrameExtendRequest request) {
ReadOnlyClipImage frameResult = request.getFrameResult();
TimelinePosition timelinePosition = request.getTimelinePosition();
VisualTimelineClip clip = request.getClip();
int previewHeight = request.getPreviewHeight();
int previewWidth = request.getPreviewWidth();
int anchorOffsetX = clip.getHorizontalAlignment(timelinePosition).apply(frameResult.getWidth(), previewWidth);
int anchorOffsetY = clip.getVerticalAlignment(timelinePosition).apply(frameResult.getHeight(), previewHeight);
double scale = request.getScale();
GetPositionParameters getPositionParameters = new GetPositionParameters(timelinePosition, scale, previewWidth, previewHeight);
int requestedXPosition = anchorOffsetX + clip.getXPosition(getPositionParameters);
int requestedYPosition = anchorOffsetY + clip.getYPosition(getPositionParameters);
request.outBoundPositions.put(clip.getId(), new RegularRectangle(requestedXPosition, requestedYPosition, frameResult.getWidth(), frameResult.getHeight()));
return expandAndTranslate(frameResult, previewWidth, previewHeight, requestedXPosition, requestedYPosition);
}
Aggregations