Search in sources :

Example 11 with AudioStream

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

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