Search in sources :

Example 1 with VisualTimelineClip

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);
}
Also used : VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip)

Example 2 with VisualTimelineClip

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;
}
Also used : GetFrameRequest(com.helospark.tactview.core.timeline.GetFrameRequest) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) BigDecimal(java.math.BigDecimal)

Example 3 with VisualTimelineClip

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;
}
Also used : VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) Image(javafx.scene.image.Image) AudibleTimelineClip(com.helospark.tactview.core.timeline.AudibleTimelineClip)

Example 4 with VisualTimelineClip

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");
    }
}
Also used : GetFrameRequest(com.helospark.tactview.core.timeline.GetFrameRequest) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip)

Example 5 with VisualTimelineClip

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);
}
Also used : GetPositionParameters(com.helospark.tactview.core.timeline.GetPositionParameters) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) VisualTimelineClip(com.helospark.tactview.core.timeline.VisualTimelineClip) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) RegularRectangle(com.helospark.tactview.core.timeline.TimelineRenderResult.RegularRectangle)

Aggregations

VisualTimelineClip (com.helospark.tactview.core.timeline.VisualTimelineClip)11 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)6 CreateEffectRequest (com.helospark.tactview.core.timeline.effect.CreateEffectRequest)4 GetFrameRequest (com.helospark.tactview.core.timeline.GetFrameRequest)3 StatelessVideoEffect (com.helospark.tactview.core.timeline.StatelessVideoEffect)3 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)3 EffectFactory (com.helospark.tactview.core.timeline.effect.EffectFactory)3 LightDiContext (com.helospark.lightdi.LightDiContext)2 VisualMediaMetadata (com.helospark.tactview.core.decoder.VisualMediaMetadata)2 FakeUi (com.helospark.tactview.core.it.util.ui.FakeUi)2 AudibleTimelineClip (com.helospark.tactview.core.timeline.AudibleTimelineClip)2 StatelessEffect (com.helospark.tactview.core.timeline.StatelessEffect)2 BigDecimal (java.math.BigDecimal)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Bean (com.helospark.lightdi.annotation.Bean)1 ConditionalOnProperty (com.helospark.lightdi.annotation.ConditionalOnProperty)1 Configuration (com.helospark.lightdi.annotation.Configuration)1 VideoMetadata (com.helospark.tactview.core.decoder.VideoMetadata)1 LoadMetadata (com.helospark.tactview.core.save.LoadMetadata)1 SaveMetadata (com.helospark.tactview.core.save.SaveMetadata)1