Search in sources :

Example 1 with TimelineManagerFramesRequest

use of com.helospark.tactview.core.timeline.TimelineManagerFramesRequest in project tactview by helospark.

the class SingleFullImageViewController method renderFullScreenAtCurrentLocation.

public void renderFullScreenAtCurrentLocation() {
    TimelinePosition currentPosition = uiTimelineManager.getCurrentPosition();
    int height = projectRepository.getHeight();
    int width = projectRepository.getWidth();
    TimelineManagerFramesRequest frameRequest = TimelineManagerFramesRequest.builder().withPosition(currentPosition).withScale(1.0).withPreviewWidth(width).withPreviewHeight(height).build();
    CompletableFuture.supplyAsync(() -> {
        ByteBuffer image = timelineManagerRenderService.getFrame(frameRequest).getAudioVideoFragment().getVideoResult().getBuffer();
        return byteBufferToImageConverter.convertToJavafxImage(image, width, height);
    }).exceptionally(e -> {
        logger.error("Error rendering image", e);
        return null;
    }).thenAccept(image -> {
        Platform.runLater(() -> {
            ImageShowDialog dialog = new ImageShowDialog(image, stylesheetAdderService);
            dialog.show();
        });
    });
}
Also used : Component(com.helospark.lightdi.annotation.Component) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) CompletableFuture(java.util.concurrent.CompletableFuture) ByteBuffer(java.nio.ByteBuffer) TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) ScrollPane(javafx.scene.control.ScrollPane) ContextMenu(javafx.scene.control.ContextMenu) ImageIO(javax.imageio.ImageIO) ByteBufferToJavaFxImageConverter(com.helospark.tactview.ui.javafx.util.ByteBufferToJavaFxImageConverter) UiTimelineManager(com.helospark.tactview.ui.javafx.UiTimelineManager) JavaFXUiMain(com.helospark.tactview.ui.javafx.JavaFXUiMain) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) MenuItem(javafx.scene.control.MenuItem) BufferedImage(java.awt.image.BufferedImage) GraphicsContext(javafx.scene.canvas.GraphicsContext) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Canvas(javafx.scene.canvas.Canvas) IOException(java.io.IOException) TimelineManagerRenderService(com.helospark.tactview.core.timeline.TimelineManagerRenderService) Slf4j(com.helospark.tactview.core.util.logger.Slf4j) File(java.io.File) Platform(javafx.application.Platform) FileChooser(javafx.stage.FileChooser) Stage(javafx.stage.Stage) StylesheetAdderService(com.helospark.tactview.ui.javafx.stylesheet.StylesheetAdderService) SwingFXUtils(javafx.embed.swing.SwingFXUtils) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) Image(javafx.scene.image.Image) TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) ByteBuffer(java.nio.ByteBuffer)

Example 2 with TimelineManagerFramesRequest

use of com.helospark.tactview.core.timeline.TimelineManagerFramesRequest in project tactview by helospark.

the class SubtimelineAudioClip method requestAudioFrameInternal.

@Override
protected AudioFrameResult requestAudioFrameInternal(AudioRequest audioRequest) {
    TimelineManagerFramesRequest channelFrameRequest = TimelineManagerFramesRequest.builder().withAudioBytesPerSample(Optional.of(audioRequest.getBytesPerSample())).withAudioLength(Optional.of(audioRequest.getLength())).withAudioSampleRate(Optional.of(audioRequest.getSampleRate())).withPosition(audioRequest.getPosition()).withNeedSound(true).withNeedVideo(false).withPreviewWidth(// TODO: find why these dummy values are needed
    800).withPreviewHeight(600).build();
    AudioVideoFragment audioVideoFragment = timelineManagerRenderService.getFrame(channelFrameRequest).getAudioVideoFragment();
    audioVideoFragment.freeVideoResult();
    return audioVideoFragment.getAudioResult();
}
Also used : TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) AudioVideoFragment(com.helospark.tactview.core.timeline.AudioVideoFragment)

Example 3 with TimelineManagerFramesRequest

use of com.helospark.tactview.core.timeline.TimelineManagerFramesRequest in project tactview by helospark.

the class RectangleProceduralClipIT method testRectangleProviderWithFullscreen.

@Test
public void testRectangleProviderWithFullscreen() {
    TimelineClip clip = fakeUi.dragProceduralClipToFirstChannel("rectangle", TimelinePosition.ofZero());
    fakeUi.selectClipAndFindSettingByName(clip.getId(), "Area").addKeyframe(new InterpolationLine(new Point(0.0, 0.0), new Point(1.0, 1.0)));
    fakeUi.selectClipAndFindSettingByName(clip.getId(), "Fuzziness").addKeyframe(0.5);
    fakeUi.selectClipAndFindSettingByName(clip.getId(), "Color").addKeyframe(new Color(1.0, 0.0, 0.0));
    TimelineManagerFramesRequest frameRequest = IntegrationTestUtil.getDefaultFrameRequest().build();
    AudioVideoFragment frame = fakeUi.requestFrame(frameRequest);
    ReadOnlyClipImage videoFrame = frame.getVideoResult();
    IntegrationTestUtil.pixelEquals(videoFrame, 0, 200, new ColorWithAlpha(0, 0, 0, 0));
    IntegrationTestUtil.pixelEquals(videoFrame, 300, 200, new ColorWithAlpha(255, 0, 0, 255));
    IntegrationTestUtil.pixelEquals(videoFrame, 100, 200, new ColorWithAlpha(127, 0, 0, 127));
}
Also used : Color(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Color) ReadOnlyClipImage(com.helospark.tactview.core.timeline.image.ReadOnlyClipImage) InterpolationLine(com.helospark.tactview.core.timeline.effect.interpolation.pojo.InterpolationLine) TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) Point(com.helospark.tactview.core.timeline.effect.interpolation.pojo.Point) ColorWithAlpha(com.helospark.tactview.core.it.util.ui.ColorWithAlpha) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip) AudioVideoFragment(com.helospark.tactview.core.timeline.AudioVideoFragment) Test(org.junit.jupiter.api.Test)

Example 4 with TimelineManagerFramesRequest

use of com.helospark.tactview.core.timeline.TimelineManagerFramesRequest in project tactview by helospark.

the class AbstractRenderService method queryFrameAt.

protected AudioVideoFragment queryFrameAt(RenderRequestFrameRequest request) {
    RenderRequest renderRequest = request.renderRequest;
    TimelinePosition currentPosition = request.currentPosition;
    Optional<Integer> sampleRate = request.sampleRate;
    Optional<Integer> bytesPerSample = request.bytesPerSample;
    Optional<Integer> numberOfChannels = request.numberOfChannels;
    boolean needsVideo = request.needsVideo;
    boolean needsSound = request.needsSound;
    double upscale = renderRequest.getUpscale().doubleValue();
    double scaleMultiplier = (double) renderRequest.getWidth() / projectRepository.getWidth();
    TimelineManagerFramesRequest frameRequest = TimelineManagerFramesRequest.builder().withPosition(currentPosition).withPreviewWidth((int) (request.expectedWidth * upscale)).withPreviewHeight((int) (request.expectedHeight * upscale)).withScale(scaleMultiplier * upscale).withAudioSampleRate(sampleRate).withAudioBytesPerSample(bytesPerSample).withNeedVideo(needsVideo).withNeedSound(needsSound).withNumberOfChannels(numberOfChannels).withAudioLength(request.audioLength).build();
    AudioVideoFragment frame = timelineManagerRenderService.getFrame(frameRequest).getAudioVideoFragment();
    if (frame.getVideoResult() != null && (renderRequest.getUpscale().compareTo(BigDecimal.ONE) > 0.0 || // due to +1 for width/height on odd size
    frame.getVideoResult().getWidth() != request.expectedWidth || frame.getVideoResult().getHeight() != request.expectedHeight)) {
        ScaleRequest scaleRequest = ScaleRequest.builder().withImage(frame.getVideoResult()).withNewWidth(request.expectedWidth).withNewHeight(request.expectedHeight).build();
        ClipImage scaledImage = scaleService.createScaledImage(scaleRequest);
        frame = frame.butFreeAndReplaceVideoFrame(scaledImage);
    }
    return frame;
}
Also used : ClipImage(com.helospark.tactview.core.timeline.image.ClipImage) TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) AudioVideoFragment(com.helospark.tactview.core.timeline.AudioVideoFragment) ScaleRequest(com.helospark.tactview.core.timeline.effect.scale.service.ScaleRequest)

Example 5 with TimelineManagerFramesRequest

use of com.helospark.tactview.core.timeline.TimelineManagerFramesRequest in project tactview by helospark.

the class SubtimelineVisualClip method requestFrame.

@Override
public ReadOnlyClipImage requestFrame(RequestFrameParameter request) {
    TimelineManagerFramesRequest channelFrameRequest = TimelineManagerFramesRequest.builder().withPosition(request.getPosition()).withScale(request.getScale()).withPreviewWidth(request.getWidth()).withPreviewHeight(request.getHeight()).withNeedSound(false).withNeedVideo(true).build();
    AudioVideoFragment audioVideoFragment = timelineManagerRenderService.getFrame(channelFrameRequest).getAudioVideoFragment();
    audioVideoFragment.getAudioResult().free();
    return audioVideoFragment.getVideoResult();
}
Also used : TimelineManagerFramesRequest(com.helospark.tactview.core.timeline.TimelineManagerFramesRequest) AudioVideoFragment(com.helospark.tactview.core.timeline.AudioVideoFragment)

Aggregations

TimelineManagerFramesRequest (com.helospark.tactview.core.timeline.TimelineManagerFramesRequest)9 AudioVideoFragment (com.helospark.tactview.core.timeline.AudioVideoFragment)7 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)3 ReadOnlyClipImage (com.helospark.tactview.core.timeline.image.ReadOnlyClipImage)3 ByteBuffer (java.nio.ByteBuffer)3 Component (com.helospark.lightdi.annotation.Component)2 ColorWithAlpha (com.helospark.tactview.core.it.util.ui.ColorWithAlpha)2 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)2 AudioFrameResult (com.helospark.tactview.core.timeline.AudioFrameResult)2 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)2 TimelineManagerRenderService (com.helospark.tactview.core.timeline.TimelineManagerRenderService)2 ByteBufferToJavaFxImageConverter (com.helospark.tactview.ui.javafx.util.ByteBufferToJavaFxImageConverter)2 ArrayList (java.util.ArrayList)2 Image (javafx.scene.image.Image)2 Color (javafx.scene.paint.Color)2 Test (org.junit.jupiter.api.Test)2 GlobalMemoryManagerAccessor (com.helospark.tactview.core.decoder.framecache.GlobalMemoryManagerAccessor)1 TimelineLength (com.helospark.tactview.core.timeline.TimelineLength)1 TimelineRenderResult (com.helospark.tactview.core.timeline.TimelineRenderResult)1 RegularRectangle (com.helospark.tactview.core.timeline.TimelineRenderResult.RegularRectangle)1