Stream video using OCI Media Services

December 1, 2022 | 6 minute read
Sathya Velir
Principal Product Manager
Text Size 100%:

In this blog, we show key concepts to help you stream video in Oracle Cloud Infrastructure (OCI) using Media Services, including resources and LiveLabs to take your knowledge further.

OCI offers two services under Media Services: OCI Media Flow and OCI Media Streams. OCI Media Flow is a platform to encode and transcode videos into different renditions, containers, and formats. After the video is processed, you can stream it through OCI Edge in your region or content delivery network (CDN) using the other service, OCI Media Streams. OCI Media Services are cost-effective, scalable, AI-enabled, API-rich services.

On top of streaming the data, video content analysis using AI services has become critical in the following processes:

  • Validate if the content is appropriate for viewers

  • Detect objects or text in the video

  • Perform audio transcription

The following graphic shows a typical workflow. Read on to learn about each service.

A graphic depicting a typical workflow of media streaming.

OCI Media Flow

The foundation of streaming a video is optimally transcoding data based on the user base and the different renditions needed. OCI Media Flow is a workflow-based video processing service to encode or transcode a video file to a different codec and containers, generate thumbnails, and integrate OCI AI Speech, AI-Language, and AI Vision services. The workflow consists of tasks that define the individual pieces of work.

The video is dropped into an OCI Object Storage bucket, and the Media Workflow task pulls the file to transcode and process the file with core tasks. All resultant files are placed back into an Object Storage bucket.

The tasks are discrete, but each has a prerequisite that needs to be met. For example, the transcode task can’t happen without getting the file from Object Storage. A set of combined tasks defined with configuration is called a media workflow. A media workflow job is an instance of Media Workflow that runs the defined tasks with the input file provided as a media workflow job parameter.

A media workflow can contain the following tasks:

  • getFiles: Gets the file from the OCI Object Storage bucket into the OCI Media Flow service.

  • transcode: The file gets transcoded to the requested codec and container using one of the following options:

    • Standard transcode: Standard parameters are applied for a balanced quality and speed.

    • Speed optimized: The transcode is optimized to bring output content optimized for speedy content delivery.

    • Quality optimized: The transcode parameters concentrate on providing the best quality outputs.

     

  • transcribe: Audio is extracted and sent to OCI AI Speech service to get back a JSON object with the transcribed speech-to-text content.

  • visionDetection: Frames are extracted from the video and transmitted to OCI AI Vision service to get back JSON data with the object detection information.

  • thumbnail: Thumbnails are generated from the video with sizes configured.

  • ingest: Valid if the transcode task creates OCI Media Streams-supported files. For example, the transcode creating HLS packaging is valid for ingesting into a distribution channel in OCI Media Streams.

  • putFiles: All output files generated from tasks of transcoding and thumbnail are stored back to OCI Object storage.

You can manage the media workflow using JSON and access it with the help of instructions from the documentation.

A media workflow job takes parameters, such as bucket name or video file name, at run time and a media workflow configuration as a predefined parameter that the media workflow job parameter can override.

One of the critical elements in OCI Media Services is that you can register each video and its outputs to OCI Media Services to get a unique asset ID. You can also map assets to parent-child relationships to ease operations.

In the putFiles task, you can convey if the asset registration is required through ““registerMetadata”: true.”

A graphic depicting the components of a media flow.

For a Java sample code for building a media workflow with task definition and running a media workflow job, see Media Flow.

OCI Media Streams

After the video is transcoded, we can ready it for streaming over standard technology. OCI Media Streams delivers the media content authorized with the OCI Media Streams session token using HTTP Live Streaming HLS and Dynamic Adaptive Streaming over HTTPs (DASH) through a content delivery network (CDN) or OCI Edge locations. OCI Media Streams has Akamai CDN integration options within the service. However, other CDNs also work for OCI Media Streams. Today, this supports video-on-demand (VOD) content only. Let’s define the following important terms:

  • Distribution channel: An HTTP streaming endpoint with CDN or Edge configuration definition

  • Packaging: Defines how the content is packaged for delivery, such as how many seconds the segment needs to be in the HLS streaming, encrypted with AES128.

  • For AES 128 symmetric encryption, you can manage the keys can with Oracle- or customer-managed keys.

  • Ingest: Takes the provided master playlist to validate its child contents and keep it ready for just-in-time packaging. This process takes only the master playlist as input, or it returns an error. With post processing, it produces an asset ID.

  • Session token: An alpha-numeric value that provides access to a specific video for streaming through OCI Media Streams. The session token is valid for up to 24 hours, and a new session token must be generated after that period.

A distribution channel can have multiple packaging configuration, such as one with AES128 encryption and another without AES128 encryption, and multiple videos ingested. To play back the video, the session token must be generated with asset ID and packaging configuration ID as parameters.

A graphic depicting the components of a media stream.

For a Java code sample for creating Media Streams components, ingesting an asset produced by Media Flow, and generating the URL for playback, see Media Streams. The generated URL works on HLS players like video.js and Safari web browser natively.

The following diagram visualizes the overall consumption:

A graphic depicting the overall consumption of files through Media Flow, Media Streams, and to consumers.

Conclusion

Media and Entertainment is a constantly growing, continuously innovating, and competing industry. Many startup companies are generating a huge wave of innovations through ground-up development with limited budgets. OCI provides an easy-to-use platform for startups to focus on innovation and worry less on the technology spend. OCI Media Services is priced for a highly competitive market while offering the extensive benefits of OCI AI integrations in easy way for media application developer consumption.

You can use the OCI LiveLab instructional walkthrough for Media Services to try through the Oracle Cloud Console or other options like working with the APIs using Postman, OCI CLI, Python SDK, Java SDK, Terraform, and other configuration examples of Akamai CDN setups with OCI Media Streams.

For more information, see the following resources:

Sathya Velir

Principal Product Manager


Previous Post

Zero Trust Security – Not a buzz word; but elixir of Cyber Security

Krithiga Gopalan | 5 min read

Next Post


OCI releases Fall 2022 compliance reports with 19 added services and two new regions

Molly Donahue | 2 min read