Search in sources :

Example 96 with Job

use of com.google.cloud.scheduler.v1.Job in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobFromTemplate method createJobFromTemplate.

// Creates a job from a job template.
public static void createJobFromTemplate(String projectId, String location, String inputUri, String outputUri, String templateId) throws IOException {
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
        var createJobRequest = CreateJobRequest.newBuilder().setJob(Job.newBuilder().setInputUri(inputUri).setOutputUri(outputUri).setTemplateId(templateId).build()).setParent(LocationName.of(projectId, location).toString()).build();
        // Send the job creation request and process the response.
        Job job = transcoderServiceClient.createJob(createJobRequest);
        System.out.println("Job: " + job.getName());
    }
}
Also used : TranscoderServiceClient(com.google.cloud.video.transcoder.v1.TranscoderServiceClient) Job(com.google.cloud.video.transcoder.v1.Job)

Example 97 with Job

use of com.google.cloud.scheduler.v1.Job in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobWithAnimatedOverlay method createJobWithAnimatedOverlay.

// Creates a job from an ad-hoc configuration and adds an animated overlay to it.
public static void createJobWithAnimatedOverlay(String projectId, String location, String inputUri, String overlayImageUri, String outputUri) throws IOException {
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
        VideoStream videoStream0 = VideoStream.newBuilder().setH264(VideoStream.H264CodecSettings.newBuilder().setBitrateBps(550000).setFrameRate(60).setHeightPixels(360).setWidthPixels(640)).build();
        AudioStream audioStream0 = AudioStream.newBuilder().setCodec("aac").setBitrateBps(64000).build();
        // Create the overlay image. Only JPEG is supported. Image resolution is based on output
        // video resolution. This example uses the values x: 0 and y: 0 to maintain the original
        // resolution of the overlay image.
        Overlay.Image overlayImage = Overlay.Image.newBuilder().setUri(overlayImageUri).setResolution(NormalizedCoordinate.newBuilder().setX(0).setY(0).build()).setAlpha(1).build();
        // Create the starting animation (when the overlay starts to fade in). Use the values x: 0.5
        // and y: 0.5 to position the top-left corner of the overlay in the top-left corner of the
        // output video.
        Overlay.Animation animationFadeIn = Animation.newBuilder().setAnimationFade(AnimationFade.newBuilder().setFadeType(FadeType.FADE_IN).setXy(NormalizedCoordinate.newBuilder().setX(0.5).setY(0.5).build()).setStartTimeOffset(Duration.newBuilder().setSeconds(5).build()).setEndTimeOffset(Duration.newBuilder().setSeconds(10).build()).build()).build();
        // Create the ending animation (when the overlay starts to fade out). The overlay will start
        // to fade out at the 12-second mark in the output video.
        Overlay.Animation animationFadeOut = Animation.newBuilder().setAnimationFade(AnimationFade.newBuilder().setFadeType(FadeType.FADE_OUT).setXy(NormalizedCoordinate.newBuilder().setX(0.5).setY(0.5).build()).setStartTimeOffset(Duration.newBuilder().setSeconds(12).build()).setEndTimeOffset(Duration.newBuilder().setSeconds(15).build()).build()).build();
        // Create the overlay and add the image and animations to it.
        Overlay overlay = Overlay.newBuilder().setImage(overlayImage).addAnimations(animationFadeIn).addAnimations(animationFadeOut).build();
        JobConfig config = JobConfig.newBuilder().addInputs(Input.newBuilder().setKey("input0").setUri(inputUri)).setOutput(Output.newBuilder().setUri(outputUri)).addElementaryStreams(ElementaryStream.newBuilder().setKey("video_stream0").setVideoStream(videoStream0)).addElementaryStreams(ElementaryStream.newBuilder().setKey("audio_stream0").setAudioStream(audioStream0)).addMuxStreams(MuxStream.newBuilder().setKey("sd").setContainer("mp4").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addOverlays(// Add the overlay to the job config
        overlay).build();
        var createJobRequest = CreateJobRequest.newBuilder().setJob(Job.newBuilder().setInputUri(inputUri).setOutputUri(outputUri).setConfig(config).build()).setParent(LocationName.of(projectId, location).toString()).build();
        // Send the job creation request and process the response.
        Job job = transcoderServiceClient.createJob(createJobRequest);
        System.out.println("Job: " + job.getName());
    }
}
Also used : TranscoderServiceClient(com.google.cloud.video.transcoder.v1.TranscoderServiceClient) AudioStream(com.google.cloud.video.transcoder.v1.AudioStream) VideoStream(com.google.cloud.video.transcoder.v1.VideoStream) Overlay(com.google.cloud.video.transcoder.v1.Overlay) Animation(com.google.cloud.video.transcoder.v1.Overlay.Animation) Job(com.google.cloud.video.transcoder.v1.Job) JobConfig(com.google.cloud.video.transcoder.v1.JobConfig)

Example 98 with Job

use of com.google.cloud.scheduler.v1.Job in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobWithConcatenatedInputs method createJobWithConcatenatedInputs.

// Creates a job from an ad-hoc configuration that concatenates two input videos.
public static void createJobWithConcatenatedInputs(String projectId, String location, String inputUri1, Duration startTimeInput1, Duration endTimeInput1, String inputUri2, Duration startTimeInput2, Duration endTimeInput2, String outputUri) throws IOException {
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
        VideoStream videoStream0 = VideoStream.newBuilder().setH264(VideoStream.H264CodecSettings.newBuilder().setBitrateBps(550000).setFrameRate(60).setHeightPixels(360).setWidthPixels(640)).build();
        AudioStream audioStream0 = AudioStream.newBuilder().setCodec("aac").setBitrateBps(64000).build();
        JobConfig config = JobConfig.newBuilder().addInputs(Input.newBuilder().setKey("input1").setUri(inputUri1)).addInputs(Input.newBuilder().setKey("input2").setUri(inputUri2)).setOutput(Output.newBuilder().setUri(outputUri)).addElementaryStreams(ElementaryStream.newBuilder().setKey("video_stream0").setVideoStream(videoStream0)).addElementaryStreams(ElementaryStream.newBuilder().setKey("audio_stream0").setAudioStream(audioStream0)).addMuxStreams(MuxStream.newBuilder().setKey("sd").setContainer("mp4").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addEditList(// Index in the edit list
        0, EditAtom.newBuilder().setKey("atom1").addInputs("input1").setStartTimeOffset(startTimeInput1).setEndTimeOffset(endTimeInput1).build()).addEditList(// Index in the edit list
        1, EditAtom.newBuilder().setKey("atom2").addInputs("input2").setStartTimeOffset(startTimeInput2).setEndTimeOffset(endTimeInput2).build()).build();
        var createJobRequest = CreateJobRequest.newBuilder().setJob(Job.newBuilder().setOutputUri(outputUri).setConfig(config).build()).setParent(LocationName.of(projectId, location).toString()).build();
        // Send the job creation request and process the response.
        Job job = transcoderServiceClient.createJob(createJobRequest);
        System.out.println("Job: " + job.getName());
    }
}
Also used : TranscoderServiceClient(com.google.cloud.video.transcoder.v1.TranscoderServiceClient) AudioStream(com.google.cloud.video.transcoder.v1.AudioStream) VideoStream(com.google.cloud.video.transcoder.v1.VideoStream) Job(com.google.cloud.video.transcoder.v1.Job) JobConfig(com.google.cloud.video.transcoder.v1.JobConfig)

Example 99 with Job

use of com.google.cloud.scheduler.v1.Job in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobWithStandaloneCaptions method createJobWithStandaloneCaptions.

// Creates a job from an ad-hoc configuration that can use captions from a standalone file.
public static void createJobWithStandaloneCaptions(String projectId, String location, String inputVideoUri, String inputCaptionsUri, String outputUri) throws IOException {
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
        VideoStream videoStream0 = VideoStream.newBuilder().setH264(VideoStream.H264CodecSettings.newBuilder().setBitrateBps(550000).setFrameRate(60).setHeightPixels(360).setWidthPixels(640)).build();
        AudioStream audioStream0 = AudioStream.newBuilder().setCodec("aac").setBitrateBps(64000).build();
        TextStream textStream0 = TextStream.newBuilder().setCodec("webvtt").addMapping(0, TextMapping.newBuilder().setAtomKey("atom0").setInputKey("caption_input0").setInputTrack(0).build()).build();
        JobConfig config = JobConfig.newBuilder().addInputs(Input.newBuilder().setKey("input0").setUri(inputVideoUri)).addInputs(Input.newBuilder().setKey("caption_input0").setUri(inputCaptionsUri)).addEditList(// Index in the edit list
        0, EditAtom.newBuilder().setKey("atom0").addInputs("input0").addInputs("caption_input0").build()).setOutput(Output.newBuilder().setUri(outputUri)).addElementaryStreams(ElementaryStream.newBuilder().setKey("video_stream0").setVideoStream(videoStream0)).addElementaryStreams(ElementaryStream.newBuilder().setKey("audio_stream0").setAudioStream(audioStream0)).addElementaryStreams(ElementaryStream.newBuilder().setKey("vtt_stream0").setTextStream(textStream0)).addMuxStreams(0, MuxStream.newBuilder().setKey("sd_hls_fmp4").setContainer("fmp4").addElementaryStreams("video_stream0").build()).addMuxStreams(1, MuxStream.newBuilder().setKey("audio_hls_fmp4").setContainer("fmp4").addElementaryStreams("audio_stream0").build()).addMuxStreams(2, MuxStream.newBuilder().setKey("text_vtt").setContainer("vtt").addElementaryStreams("vtt_stream0").setSegmentSettings(SegmentSettings.newBuilder().setSegmentDuration(Duration.newBuilder().setSeconds(6).build()).setIndividualSegments(true).build()).build()).addManifests(0, Manifest.newBuilder().setFileName("manifest.m3u8").setType(ManifestType.HLS).addMuxStreams("sd_hls_fmp4").addMuxStreams("audio_hls_fmp4").addMuxStreams("text_vtt").build()).build();
        var createJobRequest = CreateJobRequest.newBuilder().setJob(Job.newBuilder().setOutputUri(outputUri).setConfig(config).build()).setParent(LocationName.of(projectId, location).toString()).build();
        // Send the job creation request and process the response.
        Job job = transcoderServiceClient.createJob(createJobRequest);
        System.out.println("Job: " + job.getName());
    }
}
Also used : TranscoderServiceClient(com.google.cloud.video.transcoder.v1.TranscoderServiceClient) AudioStream(com.google.cloud.video.transcoder.v1.AudioStream) VideoStream(com.google.cloud.video.transcoder.v1.VideoStream) Job(com.google.cloud.video.transcoder.v1.Job) TextStream(com.google.cloud.video.transcoder.v1.TextStream) JobConfig(com.google.cloud.video.transcoder.v1.JobConfig)

Example 100 with Job

use of com.google.cloud.scheduler.v1.Job in project java-docs-samples by GoogleCloudPlatform.

the class GetJob method getJob.

// Gets a job.
public static void getJob(String projectId, String location, String jobId) throws IOException {
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
        JobName jobName = JobName.newBuilder().setProject(projectId).setLocation(location).setJob(jobId).build();
        var getJobRequest = GetJobRequest.newBuilder().setName(jobName.toString()).build();
        // Send the get job request and process the response.
        Job job = transcoderServiceClient.getJob(getJobRequest);
        System.out.println("Job: " + job.getName());
    }
}
Also used : TranscoderServiceClient(com.google.cloud.video.transcoder.v1.TranscoderServiceClient) JobName(com.google.cloud.video.transcoder.v1.JobName) Job(com.google.cloud.video.transcoder.v1.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)89 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)38 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)24 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)20 HashMap (java.util.HashMap)20 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)16 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)13 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Map (java.util.Map)11 Test (org.junit.jupiter.api.Test)10