Search in sources :

Example 1 with AudioStream

use of com.google.cloud.video.livestream.v1.AudioStream in project java-docs-samples by GoogleCloudPlatform.

the class CreateChannel method createChannel.

public static void createChannel(String projectId, String location, String channelId, String inputId, String outputUri) throws InterruptedException, ExecutionException, TimeoutException, IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
        VideoStream videoStream = VideoStream.newBuilder().setH264(H264CodecSettings.newBuilder().setProfile("main").setBitrateBps(1000000).setFrameRate(30).setHeightPixels(720).setWidthPixels(1280)).build();
        AudioStream audioStream = AudioStream.newBuilder().setCodec("aac").setChannelCount(2).setBitrateBps(160000).build();
        var createChannelRequest = CreateChannelRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).setChannelId(channelId).setChannel(Channel.newBuilder().addInputAttachments(0, InputAttachment.newBuilder().setKey("my-input").setInput(InputName.of(projectId, location, inputId).toString()).build()).setOutput(Output.newBuilder().setUri(outputUri).build()).addElementaryStreams(ElementaryStream.newBuilder().setKey("es_video").setVideoStream(videoStream)).addElementaryStreams(ElementaryStream.newBuilder().setKey("es_audio").setAudioStream(audioStream)).addMuxStreams(MuxStream.newBuilder().setKey("mux_video").addElementaryStreams("es_video").setSegmentSettings(SegmentSettings.newBuilder().setSegmentDuration(Duration.newBuilder().setSeconds(2).build()).build()).build()).addMuxStreams(MuxStream.newBuilder().setKey("mux_audio").addElementaryStreams("es_audio").setSegmentSettings(SegmentSettings.newBuilder().setSegmentDuration(Duration.newBuilder().setSeconds(2).build()).build()).build()).addManifests(Manifest.newBuilder().setFileName("manifest.m3u8").setType(ManifestType.HLS).addMuxStreams("mux_video").addMuxStreams("mux_audio").setMaxSegmentCount(5).build())).build();
        Channel result = livestreamServiceClient.createChannelAsync(createChannelRequest).get(1, TimeUnit.MINUTES);
        System.out.println("Channel: " + result.getName());
    }
}
Also used : AudioStream(com.google.cloud.video.livestream.v1.AudioStream) Channel(com.google.cloud.video.livestream.v1.Channel) VideoStream(com.google.cloud.video.livestream.v1.VideoStream) LivestreamServiceClient(com.google.cloud.video.livestream.v1.LivestreamServiceClient)

Example 2 with AudioStream

use of com.google.cloud.video.livestream.v1.AudioStream in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobFromAdHoc method createJobFromAdHoc.

// Creates a job from an ad-hoc configuration.
public static void createJobFromAdHoc(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(H264CodecSettings.newBuilder().setBitrateBps(550000).setFrameRate(60).setHeightPixels(360).setWidthPixels(640)).build();
        VideoStream videoStream1 = VideoStream.newBuilder().setH264(H264CodecSettings.newBuilder().setBitrateBps(2500000).setFrameRate(60).setHeightPixels(720).setWidthPixels(1280)).build();
        AudioStream audioStream0 = AudioStream.newBuilder().setCodec("aac").setBitrateBps(64000).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("video_stream1").setVideoStream(videoStream1)).addElementaryStreams(ElementaryStream.newBuilder().setKey("audio_stream0").setAudioStream(audioStream0)).addMuxStreams(MuxStream.newBuilder().setKey("sd").setContainer("mp4").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addMuxStreams(MuxStream.newBuilder().setKey("hd").setContainer("mp4").addElementaryStreams("video_stream1").addElementaryStreams("audio_stream0").build()).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) Job(com.google.cloud.video.transcoder.v1.Job) JobConfig(com.google.cloud.video.transcoder.v1.JobConfig)

Example 3 with AudioStream

use of com.google.cloud.video.livestream.v1.AudioStream in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobTemplate method createJobTemplate.

// Creates a job template.
public static void createJobTemplate(String projectId, String location, String templateId) 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();
        VideoStream videoStream1 = VideoStream.newBuilder().setH264(VideoStream.H264CodecSettings.newBuilder().setBitrateBps(2500000).setFrameRate(60).setHeightPixels(720).setWidthPixels(1280)).build();
        AudioStream audioStream0 = AudioStream.newBuilder().setCodec("aac").setBitrateBps(64000).build();
        JobConfig config = JobConfig.newBuilder().addElementaryStreams(ElementaryStream.newBuilder().setKey("video_stream0").setVideoStream(videoStream0)).addElementaryStreams(ElementaryStream.newBuilder().setKey("video_stream1").setVideoStream(videoStream1)).addElementaryStreams(ElementaryStream.newBuilder().setKey("audio_stream0").setAudioStream(audioStream0)).addMuxStreams(MuxStream.newBuilder().setKey("sd").setContainer("mp4").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addMuxStreams(MuxStream.newBuilder().setKey("hd").setContainer("mp4").addElementaryStreams("video_stream1").addElementaryStreams("audio_stream0").build()).build();
        var createJobTemplateRequest = CreateJobTemplateRequest.newBuilder().setParent(LocationName.of(projectId, location).toString()).setJobTemplateId(templateId).setJobTemplate(JobTemplate.newBuilder().setConfig(config).build()).build();
        // Send the job template creation request and process the response.
        JobTemplate jobTemplate = transcoderServiceClient.createJobTemplate(createJobTemplateRequest);
        System.out.println("Job template: " + jobTemplate.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) JobTemplate(com.google.cloud.video.transcoder.v1.JobTemplate) JobConfig(com.google.cloud.video.transcoder.v1.JobConfig)

Example 4 with AudioStream

use of com.google.cloud.video.livestream.v1.AudioStream in project java-docs-samples by GoogleCloudPlatform.

the class CreateJobWithEmbeddedCaptions method createJobWithEmbeddedCaptions.

// Creates a job from an ad-hoc configuration that embeds captions in the output video.
public static void createJobWithEmbeddedCaptions(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("cea608").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("cea_stream0").setTextStream(textStream0)).addMuxStreams(0, MuxStream.newBuilder().setKey("sd").setContainer("mp4").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addMuxStreams(1, MuxStream.newBuilder().setKey("sd_hls").setContainer("ts").addElementaryStreams("video_stream0").addElementaryStreams("audio_stream0").build()).addMuxStreams(2, MuxStream.newBuilder().setKey("sd_dash").setContainer("fmp4").addElementaryStreams("video_stream0").build()).addMuxStreams(3, MuxStream.newBuilder().setKey("audio_dash").setContainer("fmp4").addElementaryStreams("audio_stream0").build()).addManifests(0, Manifest.newBuilder().setFileName("manifest.m3u8").setType(ManifestType.HLS).addMuxStreams("sd_hls").build()).addManifests(1, Manifest.newBuilder().setFileName("manifest.mpd").setType(ManifestType.DASH).addMuxStreams("sd_dash").addMuxStreams("audio_dash").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 5 with AudioStream

use of com.google.cloud.video.livestream.v1.AudioStream 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)

Aggregations

AudioStream (com.google.cloud.video.transcoder.v1.AudioStream)9 JobConfig (com.google.cloud.video.transcoder.v1.JobConfig)9 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)9 VideoStream (com.google.cloud.video.transcoder.v1.VideoStream)9 Job (com.google.cloud.video.transcoder.v1.Job)8 AudioStream (com.google.cloud.video.livestream.v1.AudioStream)2 Channel (com.google.cloud.video.livestream.v1.Channel)2 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)2 VideoStream (com.google.cloud.video.livestream.v1.VideoStream)2 Overlay (com.google.cloud.video.transcoder.v1.Overlay)2 SpriteSheet (com.google.cloud.video.transcoder.v1.SpriteSheet)2 TextStream (com.google.cloud.video.transcoder.v1.TextStream)2 JobTemplate (com.google.cloud.video.transcoder.v1.JobTemplate)1 Animation (com.google.cloud.video.transcoder.v1.Overlay.Animation)1