Search in sources :

Example 86 with Job

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

the class CreateJobWithPeriodicImagesSpritesheet method createJobWithPeriodicImagesSpritesheet.

// Creates a job from an ad-hoc configuration and generates two spritesheets from the input video.
// Each spritesheet contains images that are captured periodically based on a user-defined time
// interval.
public static void createJobWithPeriodicImagesSpritesheet(String projectId, String location, String inputUri, 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();
        // Generates a spritesheet of small images taken periodically from the input video. To
        // preserve the source aspect ratio, you should set the spriteWidthPixels field or the
        // spriteHeightPixels field, but not both.
        SpriteSheet smallSpriteSheet = SpriteSheet.newBuilder().setFilePrefix(smallSpritesheetFilePrefix).setSpriteHeightPixels(32).setSpriteWidthPixels(64).setInterval(Duration.newBuilder().setSeconds(7).build()).build();
        // Generates a spritesheet of larger images taken periodically from the input video. To
        SpriteSheet largeSpriteSheet = SpriteSheet.newBuilder().setFilePrefix(largeSpritesheetFilePrefix).setSpriteHeightPixels(72).setSpriteWidthPixels(128).setInterval(Duration.newBuilder().setSeconds(7).build()).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()).addSpriteSheets(// Add the spritesheet config to the job config
        smallSpriteSheet).addSpriteSheets(// Add the spritesheet config to the job config
        largeSpriteSheet).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) SpriteSheet(com.google.cloud.video.transcoder.v1.SpriteSheet) 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 87 with Job

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

the class CreateJobWithSetNumberImagesSpritesheet method createJobWithSetNumberImagesSpritesheet.

// Creates a job from an ad-hoc configuration and generates two spritesheets from the input video.
// Each spritesheet contains a set number of images.
public static void createJobWithSetNumberImagesSpritesheet(String projectId, String location, String inputUri, 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();
        // Generates a 10x10 spritesheet of small images from the input video. To preserve the source
        // aspect ratio, you should set the spriteWidthPixels field or the spriteHeightPixels
        // field, but not both.
        SpriteSheet smallSpriteSheet = SpriteSheet.newBuilder().setFilePrefix(smallSpritesheetFilePrefix).setSpriteHeightPixels(32).setSpriteWidthPixels(64).setColumnCount(10).setRowCount(10).setTotalCount(100).build();
        // Generates a 10x10 spritesheet of larger images from the input video.
        SpriteSheet largeSpriteSheet = SpriteSheet.newBuilder().setFilePrefix(largeSpritesheetFilePrefix).setSpriteHeightPixels(72).setSpriteWidthPixels(128).setColumnCount(10).setRowCount(10).setTotalCount(100).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()).addSpriteSheets(// Add the spritesheet config to the job config
        smallSpriteSheet).addSpriteSheets(// Add the spritesheet config to the job config
        largeSpriteSheet).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) SpriteSheet(com.google.cloud.video.transcoder.v1.SpriteSheet) 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 88 with Job

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

the class CreateJobWithStaticOverlay method createJobWithStaticOverlay.

// Creates a job from an ad-hoc configuration and adds a static overlay to it.
public static void createJobWithStaticOverlay(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. To respect the original image aspect ratio, set either x or y to 0.0.
        // This example stretches the overlay image the full width and half of the height of the
        // output video.
        Overlay.Image overlayImage = Overlay.Image.newBuilder().setUri(overlayImageUri).setResolution(NormalizedCoordinate.newBuilder().setX(1).setY(0.5).build()).setAlpha(1).build();
        // Create the starting animation (when the overlay appears). Use the values x: 0 and y: 0 to
        // position the top-left corner of the overlay in the top-left corner of the output video.
        Overlay.Animation animationStart = Overlay.Animation.newBuilder().setAnimationStatic(AnimationStatic.newBuilder().setXy(NormalizedCoordinate.newBuilder().setX(0).setY(0).build()).setStartTimeOffset(Duration.newBuilder().setSeconds(0).build()).build()).build();
        // Create the ending animation (when the overlay disappears). In this example, the overlay
        // disappears at the 10-second mark in the output video.
        Overlay.Animation animationEnd = Overlay.Animation.newBuilder().setAnimationEnd(AnimationEnd.newBuilder().setStartTimeOffset(Duration.newBuilder().setSeconds(10).build()).build()).build();
        // Create the overlay and add the image and animations to it.
        Overlay overlay = Overlay.newBuilder().setImage(overlayImage).addAnimations(animationStart).addAnimations(animationEnd).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) Job(com.google.cloud.video.transcoder.v1.Job) JobConfig(com.google.cloud.video.transcoder.v1.JobConfig)

Example 89 with Job

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

the class GetJobState method getJobState.

// Gets the state of a job.
public static void getJobState(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 state: " + job.getState());
    }
}
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)

Example 90 with Job

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

the class ListJobs method listJobs.

// Lists the jobs for a given location.
public static void listJobs(String projectId, String location) throws IOException {
    // once, and can be reused for multiple requests.
    try (TranscoderServiceClient transcoderServiceClient = TranscoderServiceClient.create()) {
        var listJobsRequest = ListJobsRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).build();
        // Send the list jobs request and process the response.
        TranscoderServiceClient.ListJobsPagedResponse response = transcoderServiceClient.listJobs(listJobsRequest);
        System.out.println("Jobs:");
        for (Job job : response.iterateAll()) {
            System.out.println(job.getName());
        }
    }
}
Also used : TranscoderServiceClient(com.google.cloud.video.transcoder.v1.TranscoderServiceClient) Job(com.google.cloud.video.transcoder.v1.Job)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)91 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)38 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)22 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)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